-
Notifications
You must be signed in to change notification settings - Fork 129
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
Add function to validate cidr superset #562
base: master
Are you sure you want to change the base?
Conversation
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, and I ran integration tests locally so safe to merge
Is there a way we can / should test this in an automated fashion? Wanted to ask in case we can verify this behavior via CI in the future before I merge.
|
||
if request_vals['ipCidrRange']: | ||
try: | ||
result_superset = cidr_superset(request_vals['ipCidrRange'], response_vals['ipCidrRange']) |
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.
nit: i'd suggest something like result_is_superset
to indicate that the value is a boolean (It's hard to infer the type of result_superset).
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 @toumorokoshi for the suggestion, I changed it to result_is_superset
.
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.
actually looks like lint failed. Can you fix your styling and ensure integration tests pass before I merge?
SUMMARY
GCP doesn't allow to shrink of the CIDR of a subnet but the original module doesn't throw an error if the requested new CIDR is not a superset of the original IP range. This PR suggests adding a condition check and error out for this scenario.
Fixes #563
ISSUE TYPE
COMPONENT NAME
This PR suggests adding a condition check to error out the above-mentioned scenario, by comparing the requested new CIDR is not a superset of the original IP range of the subnet.
ADDITIONAL INFORMATION
GCP API will throw an error on this case which the current ansible module doesn't handle. Refer the API guide for details. https://cloud.google.com/compute/docs/reference/rest/v1/subnetworks/insert