Repository navigation
Report unsupported GCP machine types as a user error - #30
Open
arpitjain099 wants to merge 1 commit into
Open
arpitjain099 wants to merge 1 commit into
arpitjain099 wants to merge 1 commit into
Conversation
get_machine_properties raises KeyError for a well formed machine type whose series is not in GCP_MACHINES (c2d, t2d, n4, c3 and so on), since those match the regex and never reach the NotImplementedError branch. Both user-facing callers only caught NotImplementedError, so the user saw a bare KeyError traceback instead of the intended message. The low-level function is unchanged, so the existing test_not_found still holds. Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Collaborator
|
Thanks! We'll look into incorporating this into the next release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requesting a real GCP machine type that ElasticBLAST has not catalogued gives an uncaught
KeyErrortraceback rather than the friendly message the code clearly intends:gcp_traits.get_machine_propertiesmatches the type against([^-]+-[^-]+)-([0-9]+)and then indexesGCP_MACHINES[series]. A well formed type from a series that is not in that dict (c2d, t2d, n4, c3, and the other newer families) matches the regex, so it never reaches theelsebranch that raisesNotImplementedError; it dies on the dict lookup instead. Both user-facing callers,tuner.gcp_get_mem_limitandelb_config.get_instance_props, catch onlyNotImplementedError, so theKeyErrorescapes to the user during config validation.I left the low-level function alone on purpose.
tests/gcp_traits/test_gcp_traits.py::test_not_foundasserts thatget_machine_properties("n1-nonstandard-32")raisesKeyError, so that behavior is part of the tested contract. Widening the two callers toexcept (NotImplementedError, KeyError)is the smaller change and keeps that test passing.Added a test that asserts
c2d-standard-4,t2d-standard-8andn4-standard-16raiseUserReportErrorwithINPUT_ERROR. It fails before the change withKeyError: 'c2d-standard'and passes after.tests/tuner tests/gcp_traits tests/base tests/elb_configrun 74 passed with the fix in place.