Added capacity checks for reservations#4372
Conversation
ccae270 to
4605f3d
Compare
SwarnaBharathiMantena
left a comment
There was a problem hiding this comment.
Please review this PR: #4057
This is a feature that lets a user specify a reservation that does not exist when the node count is 0.
Please update this validator to not conflict with this feature.
Also, is there a reason for adding this validator here instead of the module, under preconditions?
|
@PayalJakhar Let's maintain the existing structure and validate this condition using a preconditions block. We can leverage Terraform's data sources to check the available reservation capacity during the terraform plan phase. |
parulbajaj01
left a comment
There was a problem hiding this comment.
Can you please mention how did you test the changes
|
I tried deploying gke-a3-mega cluster with static_node_count value to be greater than the available capacity of the specified reservation, which resulted in following error being thrown :- |
|
/gcbrun |
1 similar comment
|
/gcbrun |
|
/gcbrun |
|
/gcbrun |
c0755fb
into
GoogleCloudPlatform:develop
Submission Checklist
NOTE: Community submissions can take up to 2 weeks to be reviewed.
Please take the following actions before submitting this pull request.
What this change does
This change adds an early check (pre-validation) to make sure there's enough space (capacity) in a specific machine reservation before we try to create the cluster's nodes.
Why this is important
Right now, if you ask for more machines than are available in a reservation, the cluster setup process only fails much later, when it tries to actually create those machines. This is a problem because:
How it was implemented
I added a new section of code to the google_container_node_pool resource block to implement robust validation for reservation affinity. This involved creating two new precondition blocks. One to ensure a single reservation is specified when required, and another to verify that the requested node count does not exceed the available capacity of that reservation.