-
Notifications
You must be signed in to change notification settings - Fork 42
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
Catching exception when running stat on non-existent volume #14
Conversation
@@ -31,7 +31,7 @@ def volume_to_attributes(vol) | |||
:format_type => format_type, | |||
:allocation => bytes_to_gb(vol.info.allocation), | |||
:capacity => bytes_to_gb(vol.info.capacity), | |||
} | |||
} rescue nil # If there are issues during stat of volume file |
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.
Could you define an exception instead of rescue everything?
Otherwise this code will just swallow any other issues in that code.
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.
Perhaps Libvirt::RetrieveError
?
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.
This is related to issue #13 .
I don't know that much Ruby to pinpoint the exception that's being raised.
If you can name the exception, I can change the code easily to comply.
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 say to define it like:
def volume_to_attributes(vol)
format_type = xml_element(vol.xml_desc, "/volume/target/format", "type") rescue nil # not all volumes have types, e.g. LVM
return nil if format_type == "dir"
{
:pool_name => vol.pool.name,
:key => vol.key,
:id => vol.key,
:path => vol.path,
:name => vol.name,
:format_type => format_type,
:allocation => bytes_to_gb(vol.info.allocation),
:capacity => bytes_to_gb(vol.info.capacity),
}
rescue Libvirt::RetrieveError
nil
end
How about this new version? |
Seems good to me. Can you confirm it is working with this change? |
I tested it by allowing jenkins to run multiple configurations and multiple projects in parallel. I got a similar error from the list_domains.rb file (I added the comment in the issue) but it was rare. I think vagrant/libvirt takes a lot more time time bringing up a volume than a domain, so it makes a lot of sense that list_volumes should fail a lot more often than list_domains. |
👍 |
Catching exception when running stat on non-existent volume
Thank you for your time working on this! |
Remember to bump the version.... I don't know how you handle that in this project |
@arielsalvo Yeah. I'm actually part of the @strzibny is your man here. =) |
Yeah, I can do a release with this included. Edit: And we should inctroduce CHANGELOG. |
Awesome. Thx. Let US know when The realeas is out please. Thanks! Em sex, 19 de fev de 2016 03:54, Josef Strzibny notifications@github.com
|
No description provided.