Skip to content

Fix npe when migrating vm with volume#4698

Merged
DaanHoogland merged 3 commits intoapache:masterfrom
GutoVeronezi:fix-npe-when-migrating-vm-with-volume
Mar 8, 2021
Merged

Fix npe when migrating vm with volume#4698
DaanHoogland merged 3 commits intoapache:masterfrom
GutoVeronezi:fix-npe-when-migrating-vm-with-volume

Conversation

@GutoVeronezi
Copy link
Contributor

Description

In the execution flow of the API migrateVirtualMachineWithVolume, there is a step that copies the volume's template to the target storage, if it is needed.
In some cases when the volume is a data type, it (the volume) does not have a template; therefore, it is going to generate an NPE when it tries to get the template's ID (Long to long auto conversion).

This PR intends to validate if the volume being copied has a template, before trying to copy the template.

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

How Has This Been Tested?

It has been tested locally in a test lab.

  1. I had created a VM and attached 2 volumes to it.
  2. I had migrated the VM to another host and the volumes to different storage to see if it migrates accordingly.

@shwstppr
Copy link
Contributor

@GutoVeronezi which hypervisor this NPE was seen because I didn't face it on VMware.
Also, since this is a bug fix it should go to 4.15.1

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result: ✔centos7 ✔centos8 ✔debian. JID-2728

@rafaelweingartner
Copy link
Member

@abhinandanprateek this happens on KVM.

I would like to highlight one thing here. The contributor is willing to send the changes/patch to master. We (as the ACS community) can never force the contributor to do anything he/she does not want (and that is not a technical part of the contribution). We can review the code and ask for improvement/changes; we can try to convince the contributor to send the code to an already release version, but we can not say "it is a bug fix, so send it to x.y.z" (this sounds like an order). However, as the name says, it is a contribution. Therefore, it is non-paid work dedicated to ACS that somebody is providing (unless you somehow are providing this contribution by supporting the contributor). I have seen this happening in other PRs, and as a member of the PMC I would like to highlight that this is not part of the Apache Way.

If somebody/some company in the community liked the changes and would like to see it in a specific branch, they can cherry-pick/back-port from master to the version branch they want.

Please, it is nothing personal or anything. It is just something I noticed, and that we (as a community) should pay attention to.

Copy link
Member

@GabrielBrascher GabrielBrascher 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

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. I also like the logging even though (in some of these cases) if(LOGGER.isDebugEnabled) would make the code more readible!

Copy link
Contributor

@Pearl1594 Pearl1594 left a comment

Choose a reason for hiding this comment

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

Verified behavior. LGTM

@GabrielBrascher GabrielBrascher added this to the 4.16.0.0 milestone Mar 8, 2021
@DaanHoogland DaanHoogland merged commit 59fba49 into apache:master Mar 8, 2021
GabrielBrascher pushed a commit to CLDIN/cloudstack that referenced this pull request Mar 9, 2021
yadvr pushed a commit that referenced this pull request Apr 6, 2021
Cherry-pick commit 59fba49 and fix conflict.

Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
nlgordon pushed a commit to ippathways/cloudstack that referenced this pull request Aug 2, 2022
Cherry-pick commit 59fba49 and fix conflict.

Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.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