Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Log exceptions in ESX service #447

Merged
merged 1 commit into from Jun 8, 2016
Merged

Log exceptions in ESX service #447

merged 1 commit into from Jun 8, 2016

Conversation

pdhamdhere
Copy link
Contributor

Log exceptions to make debugging easier.

Testing Done:
Manually verified exceptions in log file for e.g.

  • Before
[WARNING] Failed to open /vmfs/volumes/4bad174b-b67f5cfc-2fc6-0026b966a303/dockvols/myvol1.vmdk for descriptor check
  • After
[ERROR  ] Failed to open /vmfs/volumes/4bad174b-b67f5cfc-2fc6-0026b966a303/dockvols/myvol1.vmdk for descriptor check
Traceback (most recent call last):
  File "/usr/lib/vmware/vmdkops/Python/vmdk_utils.py", line 96, in vmdk_is_a_descriptor
    with open(filepath) as f:
IOError: [Errno 16] Device or resource busy: '/vmfs/volumes/4bad174b-b67f5cfc-2fc6-0026b966a303/dockvols/myvol1.vmdk'

@@ -94,7 +94,7 @@ def vmdk_is_a_descriptor(filepath):
line = f.readline()
return line.startswith('# Disk DescriptorFile')
except:
logging.warning("Failed to open %s for descriptor check", filepath)
logging.exception("Failed to open %s for descriptor check", filepath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we aren't catching a specific exception any idea what message we get in this case? Can we catch a generic exception that will get logged?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added this specific one in PR description. What do you mean by catch generic exception? "except:" will cause any exception in this case rt?

import logging to vsan_policy.py

log exceptions in find_child

make golint happy by adding comment

Log exceptions in ESX service
@kerneltime
Copy link
Contributor

LGTM

@@ -87,6 +89,7 @@ def delete(name):
try:
os.remove(policy_path(name))
except:
logging.exception("Failed to remove %s policy file", name)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: not sure this one is needed , if the file does not exist silent fail is better. But it's good as is as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thought about it and decided to leave it there just in case for other OSErrors.

@msterin
Copy link
Contributor

msterin commented Jun 8, 2016

Thanks for taking on this !

LGTM

@andrewjstone
Copy link
Contributor

LGTM

@pdhamdhere
Copy link
Contributor Author

Thanks everyone for quick review!

@pdhamdhere pdhamdhere merged commit 762be39 into master Jun 8, 2016
@pdhamdhere pdhamdhere deleted the log-exceptions branch June 8, 2016 20:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants