-
Notifications
You must be signed in to change notification settings - Fork 1.3k
xenserver: attempt eject and destroying patch VBD separately #5053
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1507,13 +1507,13 @@ public void destroyPatchVbd(final Connection conn, final Set<VM> vms) throws Xml | |
| final VDI patchVDI = findPatchIsoVDI(conn, sr); | ||
| for (final VM vm : vms) { | ||
| final String vmName = vm.getNameLabel(conn); | ||
| try { | ||
| if (!vmName.startsWith("r-") && !vmName.startsWith("s-") && !vmName.startsWith("v-")) { | ||
| return; | ||
| } | ||
| final Set<VBD> vbds = vm.getVBDs(conn); | ||
| for (final VBD vbd : vbds) { | ||
| if (Types.VbdType.CD.equals(vbd.getType(conn))) { | ||
| if (!vmName.startsWith("r-") && !vmName.startsWith("s-") && !vmName.startsWith("v-")) { | ||
| continue; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @shwstppr this was the fix :( cc @vladimirpetrov @borisstoyanov |
||
| } | ||
| final Set<VBD> vbds = vm.getVBDs(conn); | ||
| for (final VBD vbd : vbds) { | ||
| if (Types.VbdType.CD.equals(vbd.getType(conn))) { | ||
| try { | ||
| if (!vbd.getEmpty(conn)) { | ||
| vbd.eject(conn); | ||
| } | ||
|
|
@@ -1522,12 +1522,16 @@ public void destroyPatchVbd(final Connection conn, final Set<VM> vms) throws Xml | |
| vbd.insert(conn, patchVDI); | ||
| vbd.eject(conn); | ||
| } | ||
| } catch (Exception e) { | ||
| s_logger.debug("Cannot eject CD-ROM device for VM " + vmName + " due to " + e.toString(), e); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should an exception be logged in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignorable errors, not logged to avoid confusion for admin/user. 99.99% we'll never hit that. |
||
| } | ||
| try { | ||
| vbd.destroy(conn); | ||
| break; | ||
| } catch (Exception e) { | ||
| s_logger.debug("Cannot destroy CD-ROM device for VM " + vmName + " due to " + e.toString(), e); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ignorable errors, not logged to avoid confusion for admin/user. 99.99% we'll never hit that. |
||
| } | ||
| break; | ||
| } | ||
| } catch (final Exception e) { | ||
| s_logger.debug("Cannot destroy CD-ROM device for VM " + vmName + " due to " + e.toString(), e); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To simplify the validation, we could use
StringUtils.startsWithAny, fromcommons.lang3:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would hesitate to make any further changes at this point. Feel free to raise a PR.