This repository has been archived by the owner on Nov 9, 2020. It is now read-only.
Catch all vim exceptions in disk_detach #460
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
import signal | ||
import subprocess | ||
import sys | ||
import traceback | ||
import threading | ||
import time | ||
from ctypes import * | ||
|
@@ -307,13 +308,14 @@ def listVMDK(path): | |
|
||
# Return VM managed object, reconnect if needed. Throws if fails twice. | ||
def findVmByUuid(vm_uuid): | ||
vm = None | ||
try: | ||
vm = si.content.searchIndex.FindByUuid(None, vm_uuid, True, False) | ||
if vm: | ||
return vm | ||
except Exception as e: | ||
logging.exception("Failed to find VM uuid=%s (traceback below), " \ | ||
"retrying...", vm_uuid) | ||
except Exception as ex: | ||
logging.warning("Failed to find VM by uuid=%s, retrying...\n%s", | ||
vm_uuid, str(ex)) | ||
if vm: | ||
return vm | ||
# | ||
# Retry. It can throw if connect/search fails. But search can't return None | ||
# since we get UUID from VMM so VM must exist | ||
|
@@ -648,10 +650,11 @@ def disk_detach(vmdk_path, vm): | |
|
||
try: | ||
wait_for_tasks(si, [vm.ReconfigVM_Task(spec=spec)]) | ||
except vim.fault.GenericVmConfigFault as ex: | ||
for f in ex.faultMessage: | ||
logging.warning(f.message) | ||
return err("Failed to detach " + vmdk_path) | ||
except vim.Fault.VimFault as ex: | ||
ex_type, ex_value, ex_traceback = sys.exc_info() | ||
msg = "Failed to detach %s: %s" % (vmdk_path, ex.msg) | ||
logging.warning("%s\n%s", msg, "".join(traceback.format_tb(ex_traceback))) | ||
return err(msg) | ||
|
||
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. This will leave the disk attached to the VM. Like I'd mentioned in PR #433 (original set of changes) there is nothing the plugin can do to help this situation except log the error. Does the error notify docker that the unmount has failed and docker must keep track that the volume is still in use? The volume remains in attached state if docker doesn't care to unmount again. 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. i am not sure what is your question ? |
||
setStatusDetached(vmdk_path) | ||
logging.info("Disk detached %s", vmdk_path) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is there a guarantee that the second search will always complete without exception?
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.
there is no guarantee, but we know that on connection timeout retry fixes it, and on other issues we want to rethrow if we fail in retry