Skip to content

Adding vmId as part of error response when vm create fails.#8484

Merged
yadvr merged 11 commits intoapache:mainfrom
anniejili:Adding_uuid_as_part_of_error_response_when_vm_fails
Feb 8, 2024
Merged

Adding vmId as part of error response when vm create fails.#8484
yadvr merged 11 commits intoapache:mainfrom
anniejili:Adding_uuid_as_part_of_error_response_when_vm_fails

Conversation

@anniejili
Copy link
Contributor

Description

This PR fixes the difficulty in cleaning up failed VM resources.
If there is a failure during VM create after vm entity is persisted, Vm UUID will be included as part of the error response.

{
"deployvirtualmachineresponse": {
"uuidList": [
{
"serialVersionUID": -7514266713085362000,
"uuid": "f1a9a209-20a8-42ce-8f5c-457f2f560e95",
"description": "vmId"

}
],
"errorcode": 530,
"cserrorcode": 4250,
"errortext": “Error text”
}
}

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)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

DeployVm API response without fix:

{
"deployvirtualmachineresponse": {
"uuidList": [],
"errorcode": 530,
"cserrorcode": 4250,
"errortext": “Error text”
}
}

After Fix:
{
"deployvirtualmachineresponse": {
"uuidList": [
{
"serialVersionUID": -7514266713085362000,
"uuid": "f1a9a209-20a8-42ce-8f5c-457f2f560e95",
"description": "vmId"

}
],
"errorcode": 530,
"cserrorcode": 4250,
"errortext": “Error text”
}
}

How Has This Been Tested?

Change was tested in my own development environment.

@anniejili
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@anniejili 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8259

@codecov
Copy link

codecov bot commented Jan 10, 2024

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (399bd0a) 30.90% compared to head (ed03888) 30.78%.
Report is 7 commits behind head on main.

Files Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 48.27% 13 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8484      +/-   ##
============================================
- Coverage     30.90%   30.78%   -0.12%     
+ Complexity    34142    34014     -128     
============================================
  Files          5353     5353              
  Lines        375900   375935      +35     
  Branches      54629    54633       +4     
============================================
- Hits         116158   115749     -409     
- Misses       244428   244975     +547     
+ Partials      15314    15211     -103     
Flag Coverage Δ
simulator-marvin-tests 24.50% <48.27%> (-0.21%) ⬇️
uitests 4.38% <ø> (ø)
unit-tests 16.62% <0.00%> (-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
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

@anniejili , it makes function sense what you are trying to do. I have some requests though.

  • can you make methods for the new code, especially try to avoid having nested try-catch blocks in a single method?
  • as @harikrishna-patnala requested, please remove commented code? We have source control and can always get the code back if we need to.
  • you submitted and closed another PR for a similar attempt. There is no reason to open a new one, you can push --force to the same branch to update the PR with your new method of implementation. This will aid in keeping track of discussions on the subject.

That all said, thanks you for you effort and welcome ;) . once again it makes total sense and also seems to do what you suggested on the PR description.

@DaanHoogland
Copy link
Contributor

@anniejili , please have a look at https://github.com/apache/cloudstack/actions/runs/7467774820/job/20329156779?pr=8484#step:6:9822 (some line endings were disapproved of by the robots ruling our lives)

@anniejili
Copy link
Contributor Author

Ack.

@anniejili
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@anniejili
Copy link
Contributor Author

@anniejili , it makes function sense what you are trying to do. I have some requests though.

  • can you make methods for the new code, especially try to avoid having nested try-catch blocks in a single method?

@DaanHoogland Hi Dahn, Thank you for reviewing my code. As far as I can tell, there is no nested try-catch introduced by this change. Can you please double check?

  • as @harikrishna-patnala requested, please remove commented code? We have source control and can always get the code back if we need to.

Done. Thank you @harikrishna-patnala!

  • you submitted and closed another PR for a similar attempt. There is no reason to open a new one, you can push --force to the same branch to update the PR with your new method of implementation. This will aid in keeping track of discussions on the subject.

My bad, will make sure it won't happen next time.

That all said, thanks you for you effort and welcome ;) . once again it makes total sense and also seems to do what you suggested on the PR description.

@blueorangutan
Copy link

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

@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

@DaanHoogland
Copy link
Contributor

@anniejili , it makes function sense what you are trying to do. I have some requests though.

  • can you make methods for the new code, especially try to avoid having nested try-catch blocks in a single method?

@DaanHoogland Hi Dahn, Thank you for reviewing my code. As far as I can tell, there is no nested try-catch introduced by this change. Can you please double check?

You are right,I cannot see that nesting of try-catch blocks anymore, maybe I was confusing different PRs. The request remains however; can you make methods for the new code? for readability sake, verbs and nouns are easier to read (given proper method naming) than curls and braces. Also this commitUserVm method is now 150 lines long (not your fault) so let's reduce that a bit.

In no way is this a deprecation of your code, just a suggestion for improvement. (not a 👎 !!)

@anniejili
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

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

@DaanHoogland
Copy link
Contributor

@anniejili , I accidenntly updated your PR. Hope you don't mind.

@anniejili
Copy link
Contributor Author

@anniejili , I accidenntly updated your PR. Hope you don't mind.

No worries.

@anniejili
Copy link
Contributor Author

@DaanHoogland Does the PR look okay now? Thank you!

@DaanHoogland
Copy link
Contributor

@DaanHoogland Does the PR look okay now? Thank you!

code looks good @anniejili , but I would still request that you extract the new code into a new method with a clear name.

@anniejili
Copy link
Contributor Author

@DaanHoogland Does the PR look okay now? Thank you!

code looks good @anniejili , but I would still request that you extract the new code into a new method with a clear name.

It is moved to a new method line #4582.

Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm, thanks @anniejili

@yadvr
Copy link
Member

yadvr commented Feb 7, 2024

Conflicts resolving, re kicking packaging for a final check

@blueorangutan package

@blueorangutan
Copy link

@rohityadavcloud 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]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 8564

@yadvr yadvr modified the milestones: 4.19.1.0, 4.20.0.0 Feb 7, 2024
@yadvr
Copy link
Member

yadvr commented Feb 7, 2024

Thanks @weizhouapache I've addressed some of the cosmetics changes, cc @anniejili
@blueorangutan package

@blueorangutan
Copy link

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

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

@blueorangutan
Copy link

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

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@weizhouapache 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-9117)
Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
Total time taken: 42855 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr8484-t9117-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

@yadvr yadvr merged commit 4de2f38 into apache:main Feb 8, 2024
dhslove pushed a commit to ablecloud-team/ablestack-cloud that referenced this pull request Feb 20, 2024
)

* Adding vmId as part of error response when vm create fails.

* Removed unneeded comments.

* Fixed code review comments.

* Update server/src/test/java/com/cloud/vm/UserVmManagerImplTest.java

Co-authored-by: dahn <daan.hoogland@gmail.com>

* Fixed code review comments.

* Update server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

* Update server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

* Update server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

* Update server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

---------

Co-authored-by: Annie Li <ji_li@apple.com>
Co-authored-by: dahn <daan.hoogland@gmail.com>
Co-authored-by: dahn <daan@onecht.net>
Co-authored-by: Rohit Yadav <rohit.yadav@shapeblue.com>
Co-authored-by: Rohit Yadav <rohityadav89@gmail.com>
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.

7 participants