Skip to content

Conversation

@GutoVeronezi
Copy link
Contributor

Description

The Quota processing occurs on the Management Server (via API) and Usage Server (via task). It uses the class PresetVariableHelper to retrieve data from the database and inject it into the Quota tariff's activation rules. To retrieve the data, some DAOs are mapped as dependencies for the Usage Server and injected in that class.

PR #8302 injected org.apache.cloudstack.reservation.dao.ReservationDao in com.cloud.storage.dao.VolumeDao (which is also injected in PresetVariableHelper); however, org.apache.cloudstack.reservation.dao.ReservationDao was not added as dependency for the Usage Server, causing errors to start the Usage Server:

Logs
04:51:35,224  INFO Transaction:1030 - Is Data Base High Availiability enabled? Ans : false
04:51:35,224  INFO Transaction:1158 - Using the following URI to connect to cloud database [jdbc:mysql://localhost:3306/cloud?autoReconnect=true&prepStmtCacheSize=517&cachePrepStmts=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'&serverTimezone=UTC&scrollTolerantForwardOnly=true].
04:51:35,245  INFO Transaction:1158 - Using the following URI to connect to usage database [jdbc:mysql://localhost:3306/cloud_usage?autoReconnect=true&serverTimezone=UTC&scrollTolerantForwardOnly=true].
04:51:37,470  INFO ComponentContext:61 - Setup Spring Application context
04:51:38,677 ERROR ComponentContext:81 - Could not load bean due to: [Error creating bean with name 'volumeDaoImpl': Unsatisfied dependency expressed through field 'reservationDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.cloudstack.reservation.dao.ReservationDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}]. The service will be stopped. Please investigate the cause of the error or contact your support team. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'volumeDaoImpl': Unsatisfied dependency expressed through field 'reservationDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.cloudstack.reservation.dao.ReservationDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.configureBean(AbstractAutowireCapableBeanFactory.java:364)
  at com.cloud.utils.component.ComponentContext.initComponentsLifeCycle(ComponentContext.java:79)
  at com.cloud.usage.UsageServer.start(UsageServer.java:55)
  at com.cloud.usage.UsageServer.main(UsageServer.java:42)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.cloudstack.reservation.dao.ReservationDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657)
  ... 8 more

This PR adds the org.apache.cloudstack.reservation.dao.ReservationDao as dependency for the Usage Server.

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

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

I applied the changes and tried to start the Usage Server:

Logs
04:53:02,726  INFO LogUtils:59 - log4j configuration found at /etc/cloudstack/usage/log4j-cloud.xml
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
04:53:03,333  INFO Transaction:1030 - Is Data Base High Availiability enabled? Ans : false
04:53:03,334  INFO Transaction:1158 - Using the following URI to connect to cloud database [jdbc:mysql://localhost:3306/cloud?autoReconnect=true&prepStmtCacheSize=517&cachePrepStmts=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'&serverTimezone=UTC&scrollTolerantForwardOnly=true].
04:53:03,346  INFO Transaction:1158 - Using the following URI to connect to usage database [jdbc:mysql://localhost:3306/cloud_usage?autoReconnect=true&serverTimezone=UTC&scrollTolerantForwardOnly=true].
04:53:04,288  INFO ComponentContext:61 - Setup Spring Application context
04:53:04,873  INFO ComponentContext:116 - Configuring org.apache.cloudstack.framework.config.dao.ConfigurationDaoImpl_EnhancerByCloudStack_2634113
04:53:04,875  INFO ComponentContext:116 - Configuring com.cloud.storage.dao.SnapshotDaoImpl_EnhancerByCloudStack_569da26d
04:53:04,875  INFO ComponentContext:116 - Configuring org.apache.cloudstack.quota.dao.QuotaEmailConfigurationDaoImpl_EnhancerByCloudStack_8006895b
04:53:04,875  INFO ComponentContext:116 - Configuring com.cloud.usage.dao.UsageVMSnapshotDaoImpl_EnhancerByCloudStack_c98c579
04:53:04,875  INFO ComponentContext:116 - Configuring com.cloud.storage.dao.VolumeDaoImpl_EnhancerByCloudStack_ace675e7

@GutoVeronezi
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@GutoVeronezi a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 30.95%. Comparing base (a0b642c) to head (a8632f1).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8868      +/-   ##
============================================
+ Coverage     30.91%   30.95%   +0.03%     
- Complexity    33734    33770      +36     
============================================
  Files          5404     5404              
  Lines        380289   380289              
  Branches      55489    55489              
============================================
+ Hits         117550   117702     +152     
+ Misses       247104   246978     -126     
+ Partials      15635    15609      -26     
Flag Coverage Δ
simulator-marvin-tests 24.56% <ø> (+0.03%) ⬆️
uitests 4.34% <ø> (ø)
unit-tests 16.88% <ø> (+<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

@vishesh92 vishesh92 left a comment

Choose a reason for hiding this comment

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

clgtm

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9117

@DaanHoogland
Copy link
Contributor

@blueorangutan test alma9 kvm-alma9

@blueorangutan
Copy link

@DaanHoogland a [SL] Trillian-Jenkins test job (alma9 mgmt + kvm-alma9) has been kicked to run smoke tests

Copy link
Member

@winterhazel winterhazel left a comment

Choose a reason for hiding this comment

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

LGTM. I verified that Usage was indeed not initializing successfully in the latest commit from main, and that it started as expected after applying these changes.

Before
2024-04-02T21:48:52,507 INFO  [db.Transaction.Transaction] (main:[]) (logid:) Using the following URI to connect to cloud database [jdbc:mysql://192.168.201.160:3306/cloud?autoReconnect=true&prepStmtCacheSize=517&cachePrepStmts=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'&serverTimezone=UTC&scrollTolerantForwardOnly=true].
2024-04-02T21:48:52,524 DEBUG [utils.db.DriverLoader] (main:[]) (logid:) Successfully loaded DB driver com.mysql.cj.jdbc.Driver
2024-04-02T21:48:52,594 INFO  [db.Transaction.Transaction] (main:[]) (logid:) Using the following URI to connect to usage database [jdbc:mysql://192.168.201.160:3306/cloud_usage?autoReconnect=true&serverTimezone=UTC&scrollTolerantForwardOnly=true].
2024-04-02T21:48:52,596 DEBUG [utils.db.DriverLoader] (main:[]) (logid:) DB driver com.mysql.cj.jdbc.Driver was already loaded.
2024-04-02T21:48:52,626 DEBUG [utils.db.DriverLoader] (main:[]) (logid:) DB driver com.mysql.cj.jdbc.Driver was already loaded.
2024-04-02T21:49:02,190 INFO  [utils.component.ComponentContext] (main:[]) (logid:) Setup Spring Application context
2024-04-02T21:49:06,317 ERROR [utils.component.ComponentContext] (main:[]) (logid:) Could not load bean due to: [Error creating bean with name 'volumeDaoImpl': Unsatisfied dependency expressed through field 'reservationDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.cloudstack.reservation.dao.ReservationDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}]. The service will be stopped. Please investigate the cause of the error or contact your support team. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'volumeDaoImpl': Unsatisfied dependency expressed through field 'reservationDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.cloudstack.reservation.dao.ReservationDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:660)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.configureBean(AbstractAutowireCapableBeanFactory.java:364)
	at com.cloud.utils.component.ComponentContext.initComponentsLifeCycle(ComponentContext.java:79)
	at com.cloud.usage.UsageServer.start(UsageServer.java:55)
	at com.cloud.usage.UsageServer.main(UsageServer.java:42)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.cloudstack.reservation.dao.ReservationDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.inject.Inject()}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:657)
	... 8 more
After
2024-04-02T21:55:12,724 INFO  [db.Transaction.Transaction] (main:[]) (logid:) Using the following URI to connect to cloud database [jdbc:mysql://192.168.201.160:3306/cloud?autoReconnect=true&prepStmtCacheSize=517&cachePrepStmts=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'&serverTimezone=UTC&scrollTolerantForwardOnly=true].
2024-04-02T21:55:12,735 DEBUG [utils.db.DriverLoader] (main:[]) (logid:) Successfully loaded DB driver com.mysql.cj.jdbc.Driver
2024-04-02T21:55:12,778 INFO  [db.Transaction.Transaction] (main:[]) (logid:) Using the following URI to connect to usage database [jdbc:mysql://192.168.201.160:3306/cloud_usage?autoReconnect=true&serverTimezone=UTC&scrollTolerantForwardOnly=true].
2024-04-02T21:55:12,780 DEBUG [utils.db.DriverLoader] (main:[]) (logid:) DB driver com.mysql.cj.jdbc.Driver was already loaded.
2024-04-02T21:55:12,791 DEBUG [utils.db.DriverLoader] (main:[]) (logid:) DB driver com.mysql.cj.jdbc.Driver was already loaded.
2024-04-02T21:55:21,496 INFO  [utils.component.ComponentContext] (main:[]) (logid:) Setup Spring Application context
2024-04-02T21:55:26,164 INFO  [utils.component.ComponentContext] (main:[]) (logid:) Configuring org.apache.cloudstack.framework.config.dao.ConfigurationDaoImpl_EnhancerByCloudStack_9f179332
2024-04-02T21:55:26,169 INFO  [utils.component.ComponentContext] (main:[]) (logid:) Configuring com.cloud.storage.dao.SnapshotDaoImpl_EnhancerByCloudStack_f351f48c
2024-04-02T21:55:26,170 INFO  [utils.component.ComponentContext] (main:[]) (logid:) Configuring org.apache.cloudstack.quota.dao.QuotaEmailConfigurationDaoImpl_EnhancerByCloudStack_1cbadb7a
2024-04-02T21:55:26,177 INFO  [utils.component.ComponentContext] (main:[]) (logid:) Configuring com.cloud.usage.dao.UsageVMSnapshotDaoImpl_EnhancerByCloudStack_a94d1798
2024-04-02T21:55:26,178 INFO  [utils.component.ComponentContext] (main:[]) (logid:) Configuring com.cloud.storage.dao.VolumeDaoImpl_EnhancerByCloudStack_499ac806
...

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-9671)

@DaanHoogland
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@DaanHoogland a [SL] Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-9677)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 59787 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8868-t9677-kvm-centos7.zip
Smoke tests completed. 129 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@DaanHoogland DaanHoogland merged commit 9072f8e into apache:main Apr 4, 2024
@yadvr yadvr added this to the 4.20.0.0 milestone Apr 4, 2024
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants