Skip to content

Conversation

@erik-bock-silva
Copy link
Contributor

Description

This PR makes the id parameter from isAccountAllowedToCreateOfferingsWithTags api required to prevent a NullPointerException when trying to execute the command without an id.

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?

I've created a test environment with a CloudStack setup. When I tried to execute the command without the id parameter, the following exception was thrown:

2025-02-03 15:00:11,909 ERROR [c.c.a.ApiServer] (qtp1507118393-20:[ctx-de956cc8, ctx-37d7a594]) (logid:5e002cf6) unhandled exception executing api command: [Ljava.lang.String;@588ef940 java.lang.NullPointerException: Cannot invoke "java.lang.Long.longValue()" because the return value of "org.apache.cloudstack.api.command.admin.offering.IsAccountAllowedToCreateOfferingsWithTagsCmd.getId()" is null
	at com.cloud.configuration.ConfigurationManagerImpl.isAccountAllowedToCreateOfferingsWithTags(ConfigurationManagerImpl.java:8076)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
	at jdk.proxy3/jdk.proxy3.$Proxy149.isAccountAllowedToCreateOfferingsWithTags(Unknown Source)
	at org.apache.cloudstack.api.command.admin.offering.IsAccountAllowedToCreateOfferingsWithTagsCmd.execute(IsAccountAllowedToCreateOfferingsWithTagsCmd.java:37)

Then I built and applied the updated packages to my environment. After that, I tried to force the same error to ensure my fix was working. The response shown was now the message: Missing required parameters: id

@DaanHoogland DaanHoogland added this to the 4.20.1 milestone Feb 6, 2025
@DaanHoogland
Copy link
Contributor

If it was impossible to execute the query before without id, I am alright with it. Otherwise this is a backwards incompatibility.

@codecov
Copy link

codecov bot commented Feb 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 16.00%. Comparing base (96b757c) to head (d24a8b3).
Report is 71 commits behind head on 4.20.

Additional details and impacted files
@@             Coverage Diff              @@
##               4.20   #10338      +/-   ##
============================================
- Coverage     16.13%   16.00%   -0.14%     
- Complexity    12972    13062      +90     
============================================
  Files          5639     5644       +5     
  Lines        494297   494915     +618     
  Branches      59908    59960      +52     
============================================
- Hits          79773    79188     -585     
- Misses       405698   406890    +1192     
- Partials       8826     8837      +11     
Flag Coverage Δ
uitests 4.01% <ø> (-0.01%) ⬇️
unittests 16.83% <ø> (-0.15%) ⬇️

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.

@bernardodemarco
Copy link
Member

If it was impossible to execute the query before without id, I am alright with it. Otherwise this is a backwards incompatibility.

@DaanHoogland, yes, previously, it was impossible to execute the API without an id.

When the API's service layer method is executed, the flow tries to retrieve the account with the specified id from the DB:

public Boolean isAccountAllowedToCreateOfferingsWithTags(IsAccountAllowedToCreateOfferingsWithTagsCmd cmd) {
Account caller = CallContext.current().getCallingAccount();
Account targetAccount = _accountMgr.getAccount(cmd.getId());

However, the getAccount method expects the accountId parameter as the long primitive:

@Override
public Account getAccount(long accountId) {
return _accountDao.findByIdIncludingRemoved(accountId);
}

Therefore, when the method is executed specifying null as argument, a NPE is thrown.

Copy link
Member

@bernardodemarco bernardodemarco left a comment

Choose a reason for hiding this comment

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

clgtm

@bernardodemarco
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@bernardodemarco 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.

@blueorangutan
Copy link

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

@JoaoJandre
Copy link
Contributor

@DaanHoogland could we run the CI here?

@DaanHoogland
Copy link
Contributor

@DaanHoogland could we run the CI here?

yes, but I'll run the last 4.19.2 tests first. hopefully end of the weekend.

@Pearl1594
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_11_isolated_network_with_dynamic_routed_mode Error 2.27 test_ipv4_routing.py
test_12_vpc_and_tier_with_dynamic_routed_mode Error 2.38 test_ipv4_routing.py
test_12_vpc_and_tier_with_dynamic_routed_mode Error 2.38 test_ipv4_routing.py
test_06_purge_expunged_vm_background_task Failure 393.60 test_purge_expunged_vms.py
test_12_start_vm_multiple_volumes_allocated Error 14.97 test_vm_life_cycle.py

@JoaoJandre JoaoJandre merged commit 5204960 into apache:4.20 Feb 14, 2025
24 of 25 checks passed
@Pearl1594 Pearl1594 moved this to Done in ACS 4.20.1 Mar 17, 2025
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Jun 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants