Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Usage job not executing successfully #10244

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

winterhazel
Copy link
Collaborator

@winterhazel winterhazel commented Jan 22, 2025

Description

The Usage job does not execute successfully in 4.20.1 because cloud_usage.account is missing the column api_key_access (introduced in #9741). This PR fixes the issue.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

  1. Before the changes, I tried to execute the Usage job. However, I got an exception and no usage records were generated
2025-01-26 00:13:58,470 INFO  [cloud.usage.UsageManagerImpl_EnhancerByCloudStack_bc7085c8] (Usage-Job-1:[]) (logid:) Parsing usage records between [2024-11-27T11:50:00+0000] and [2025-01-26T00:12:59+0000].
2025-01-26 00:13:58,838 ERROR [user.dao.AccountDaoImpl_EnhancerByCloudStack_90169b7f] (Usage-Job-1:[]) (logid:) DB Exception on: HikariProxyPreparedStatement@1912723807 wrapping com.mysql.cj.jdbc.ClientPreparedStatement: SELECT account.id, account.account_name, account.type, account.role_id, account.domain_id, account.state, account.created, account.removed, account.cleanup_needed, account.network_domain, account.uuid, account.default_zone_id, account.default, account.api_key_access FROM account WHERE account.id = 1 java.sql.SQLSyntaxErrorException: Unknown column 'account.api_key_access' in 'field list'
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:121)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916)
	at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:972)
	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
	at com.cloud.utils.db.GenericDaoBase.findById(GenericDaoBase.java:1074)
	at com.cloud.user.dao.AccountDaoImpl_EnhancerByCloudStack_90169b7f.CGLIB$findById$48(<generated>)
	at com.cloud.user.dao.AccountDaoImpl_EnhancerByCloudStack_90169b7f_FastClassByCloudStack_ef992de4.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at com.cloud.utils.component.ComponentInstantiationPostProcessor$InterceptorDispatcher.intercept(ComponentInstantiationPostProcessor.java:123)
	at com.cloud.user.dao.AccountDaoImpl_EnhancerByCloudStack_90169b7f.findById(<generated>)
	at com.cloud.utils.db.GenericDaoBase.findByIdIncludingRemoved(GenericDaoBase.java:1029)
	at com.cloud.user.dao.AccountDaoImpl_EnhancerByCloudStack_90169b7f.CGLIB$findByIdIncludingRemoved$99(<generated>)
	at com.cloud.user.dao.AccountDaoImpl_EnhancerByCloudStack_90169b7f_FastClassByCloudStack_ef992de4.invoke(<generated>)
	at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at com.cloud.utils.component.ComponentInstantiationPostProcessor$InterceptorDispatcher.intercept(ComponentInstantiationPostProcessor.java:123)
	at com.cloud.user.dao.AccountDaoImpl_EnhancerByCloudStack_90169b7f.findByIdIncludingRemoved(<generated>)
	at com.cloud.usage.UsageManagerImpl.handleNetworkEvent(UsageManagerImpl.java:2152)
	at com.cloud.usage.UsageManagerImpl.createHelperRecord(UsageManagerImpl.java:1100)
	at com.cloud.usage.UsageManagerImpl.parse(UsageManagerImpl.java:726)
	at com.cloud.usage.UsageManagerImpl.runInContextInternal(UsageManagerImpl.java:442)
	at com.cloud.usage.UsageManagerImpl$1.runInContext(UsageManagerImpl.java:379)
	at org.apache.cloudstack.managed.context.ManagedContextRunnable$1.run(ManagedContextRunnable.java:49)
	at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
	at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
	at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
	at org.apache.cloudstack.managed.context.ManagedContextRunnable.run(ManagedContextRunnable.java:46)
	at com.cloud.usage.UsageManagerImpl.run(UsageManagerImpl.java:381)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
  1. I executed the query manually and tried to execute the Usage job. This time, it finished successfully

Copy link

codecov bot commented Jan 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 16.14%. Comparing base (bf1ff10) to head (dc113ed).
Report is 29 commits behind head on 4.20.

Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #10244   +/-   ##
=========================================
  Coverage     16.13%   16.14%           
- Complexity    12966    12973    +7     
=========================================
  Files          5639     5639           
  Lines        494251   494297   +46     
  Branches      59899    59908    +9     
=========================================
+ Hits          79766    79788   +22     
- Misses       405664   405684   +20     
- Partials       8821     8825    +4     
Flag Coverage Δ
uitests 4.02% <ø> (ø)
unittests 16.99% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

@winterhazel winterhazel changed the title Fix Usage job not executing Fix Usage job not executing successfully Jan 22, 2025
Copy link
Contributor

@harikrishna-patnala harikrishna-patnala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DaanHoogland
Copy link
Contributor

@winterhazel , can you confirm this is not a problem in older versions?

@weizhouapache
Copy link
Member

#9741 was introduced in 4.20.1

Copy link
Contributor

@lucas-a-martins lucas-a-martins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you for the PR. I'm working on a Usage related PR and this bug is blocking my progression.

I tested the proposed fix in my local environment and the Usage job executed successfully.

@weizhouapache weizhouapache merged commit 4201a2d into apache:4.20 Jan 30, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants