-
Notifications
You must be signed in to change notification settings - Fork 71
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
Fix not found error checks #327
Fix not found error checks #327
Conversation
Since the error message has been changed only one year ago (canonical/lxd@ce7b3fb), maybe we should keep both options for now (for those who are still running older versions of LXD): if err != nil && (err.Error() == "No such object" || err.Error() == "Storage pool not found") {
// ...
} @simondeziel @adamcstephens Any thoughts on that? |
Thanks for thinking about backward compat! The commit you found was backported to 5.0 LTS (canonical/lxd@d442d20) but not to 4.0 LTS, so yeah, I think it's worth checking for both error strings. Excuse my ignorance but isn't there a HTTP return code accompanying the error? I'd expect the old and new errors to both come with a |
You are right, we could check if the error is of type |
675c0d9
to
d8db345
Compare
I have replaced the string comparison error checks with the status code error checks. This approach works both for LXD version In addition, I have replaced most of the |
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.
Thanks!
Currently, when the provider retrieves LXD storage pool (or tries to delete it), it checks whether an error equals to
No such object
. In such case it detects that the storage pool does not exist and an error is not reported.However, LXD returns different error in such cases (https://github.com/canonical/lxd/blob/7f46f71133411a66be20fce1a2b92de3923db705/lxd/db/storage_pools.go#L666) -
Storage pool not found
.