-
Notifications
You must be signed in to change notification settings - Fork 926
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
DimensionData - Handle exception when powering off a node that is already powered off #912
Conversation
@@ -561,7 +563,7 @@ def wait_for_state(self, state, func, poll_interval=2, timeout=60, *args, | |||
sleep(poll_interval) | |||
cnt += 1 | |||
|
|||
msg = 'Status check for object %s timed out' % (result) | |||
msg = 'Status check for object %s timed out' % result |
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.
For safety reasons I would leave parenthesis there - if you add another format string and format to add parenthesis there it will break during run-time so it's usually safer to just always include parenthesis (this way it's impossible to forget to add them later if and when you add another format string argument).
r = self.ex_get_node_by_id(node.id) | ||
response_code = r.state.upper() | ||
|
||
return response_code in ['IN_PROGRESS', 'OK', 'STOPPED', 'STOPPING'] |
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 looks good to me, but maybe we should consider throwing an exception if node is already in stopping / stopped state.
That's more just me thinking out loud, I'm also fine with current approach.
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.
Thx @Kami for your comment. My intension is to make it more user friendly; As long as the aim is achieved, doesn't matter if the state a precondition or the result of the operation, as long as it is 'STOPPED', I'm happy, no exception.
Throwing exception will means one will have to check the state every time. More code. Open for discussion.
LGTM, thanks. |
👍 |
Changes Title (replace this with a logical title for your changes)
Description
-Handle exception when powering off a node that is already stopped
Status
Checklist (tick everything that applies)