Skip to content

Conversation

@PolonaM
Copy link
Collaborator

@PolonaM PolonaM commented Apr 14, 2023

Use ConnectionRefusedError in cluster shutdown instead of error description comparison

Closes #137

Copy link
Collaborator

@justinc1 justinc1 left a comment

Choose a reason for hiding this comment

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

Change is ok, but more such changes are needed.

# raise errors.ScaleComputingError(f"Request timed out: {e}")
except ScaleComputingError as e:
# To avoid timeout when there are a lot of VMs to shutdown
if "Request timed out" in str(e):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we also detect exception root cause from string, not from type. Are the more places with this pattern?

We should have a dedicated exception, like ScaleRequestTimedOut. Then you refactor the RestClient, and you need to check if there is any other module that needs to know about your new exception.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But this error will never cause a problem right? The string is generated inside the client, so the string comparison will never fail due to formatting (like it would when we compared the string directly from the http response - in case of "connection refused")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As discussed, I implemented ScaleTimeoutError in rest_client

@PolonaM PolonaM force-pushed the module_exception_handling branch from e988bae to 1f387ef Compare April 14, 2023 11:19
@PolonaM PolonaM requested a review from justinc1 April 14, 2023 11:25
Copy link
Collaborator

@justinc1 justinc1 left a comment

Choose a reason for hiding this comment

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

ok and thank you.

@PolonaM PolonaM merged commit 862b762 into main Apr 14, 2023
@PolonaM PolonaM deleted the module_exception_handling branch April 14, 2023 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raise exception within module

3 participants