-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Don't recreate container_cluster when maintenance_window changes #893
Don't recreate container_cluster when maintenance_window changes #893
Conversation
), | ||
}, | ||
{ | ||
Config: testAccContainerCluster_withMaintenanceWindow(clusterName, ""), | ||
Check: resource.ComposeTestCheckFunc( |
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.
I'm not sure if this extra step is worth it. I wanted to add something to prove that the cluster had not been torn down & recreated, but couldn't find a neat way to do this.
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.
I also tried to add code to testAccCheckContainerCluster
to prove the absence of a maintenance window:
if cluster.MaintenancePolicy == nil {
clusterTests = append(clusterTests, clusterTestField{"maintenance_policy", []string{}})
} else {
clusterTests = append(clusterTests, clusterTestField{"maintenance_policy.0.daily_maintenance_window.0.start_time", cluster.MaintenancePolicy.Window.DailyMaintenanceWindow.StartTime})
clusterTests = append(clusterTests, clusterTestField{"maintenance_policy.0.daily_maintenance_window.0.duration", cluster.MaintenancePolicy.Window.DailyMaintenanceWindow.Duration})
}
but it turned out not really to prove anything: if I failed to correctly implement the "update MaintenanceWindow to nil" call, the state passed into the TestCheckFunc was the actual state (i.e. still with a non-nil MaintenanceWindow) so the test passed even though the apply hadn't done what I wanted.
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.
Yeah, our test infrastructure definitely leaves something to be desired. I do think having the test to check that you can remove a maintenance window is good to have. For the "check that it was a real update", https://github.com/hashicorp/terraform/issues/15126. And for proving the absence, you could use resource.TestCheckNoResourceAttr
- then we have those sorts of checks making sure our state is what we expect it to be, and testAccCheckContainerCluster
to (mostly) check that the state matches what GCP says.
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.
Wooooo thanks for this @michaelbannister!
google/resource_container_cluster.go
Outdated
@@ -175,21 +175,21 @@ func resourceContainerCluster() *schema.Resource { | |||
"maintenance_policy": { | |||
Type: schema.TypeList, | |||
Optional: true, | |||
ForceNew: true, | |||
ForceNew: false, |
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 is fine, but the pattern we tend to use is to just not set ForceNew
at all if it's false.
google/resource_container_cluster.go
Outdated
if d.HasChange("maintenance_policy") { | ||
var req *container.SetMaintenancePolicyRequest | ||
if mp, ok := d.GetOk("maintenance_policy"); ok { | ||
maintenancePolicy := mp.([]interface{})[0].(map[string]interface{}) |
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.
I won't block on this, but if you wanted you could add an expandMaintenancePolicy
func that you could call from both here and Create
), | ||
}, | ||
{ | ||
Config: testAccContainerCluster_withMaintenanceWindow(clusterName, ""), | ||
Check: resource.ComposeTestCheckFunc( |
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.
Yeah, our test infrastructure definitely leaves something to be desired. I do think having the test to check that you can remove a maintenance window is good to have. For the "check that it was a real update", https://github.com/hashicorp/terraform/issues/15126. And for proving the absence, you could use resource.TestCheckNoResourceAttr
- then we have those sorts of checks making sure our state is what we expect it to be, and testAccCheckContainerCluster
to (mostly) check that the state matches what GCP says.
Review comments for PR hashicorp#893
Review comments for PR hashicorp#893
Review comments for PR hashicorp#893
Thanks @danawillow for the comments & suggestions… |
Happy Holidays to you too!
|
Signed-off-by: Modular Magician <[email protected]>
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Fixes #727