-
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
Add DiffSuppressFunc to GKE cluster networks #419
Conversation
google/resource_container_cluster.go
Outdated
Optional: true, | ||
Default: "default", | ||
ForceNew: true, | ||
DiffSuppressFunc: linkDiffSuppress, |
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.
You should use compareSelfLinkOrResourceName
.
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.
Hum. This method assume that the API always return a self-link... It wouldn't work and updating linkDiffSuppress is dangerous because moving a resource to a different zone wouldn't trigger a diff like explained below.
You can either create a new method. Or when you store the network in the Read method, you can generate the relative part of the network and use compareSelfLinkOrResourceName
.
google/utils.go
Outdated
@@ -251,8 +251,9 @@ func isConflictError(err error) bool { | |||
} | |||
|
|||
func linkDiffSuppress(k, old, new string, d *schema.ResourceData) bool { | |||
parts := strings.Split(old, "/") | |||
if parts[len(parts)-1] == new { | |||
oldParts := strings.Split(old, "/") |
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.
The problem with updating this method is that this will cause issue for zonal or regional self-link
If field was "regions/us-east1/someResource/myResource" and now is "regions/us-west1/someResource/myResource" this would suppress the diff.
I wouldn't update this method and use the other more robust compareSelfLinkOrResourceName
All right, I solved it in a slightly different way from your suggestion (used a StateFunc instead), let me know what you think.
(if you're happy with this feel free to merge instead of waiting for me since time zones / travel and whatnot) |
* fix gke network test * use a state func to store the resource name
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! |
TestAccContainerCluster_network
was failing with a perma-diff after #391 because GKE returns the network as a name only, but we allow users to set it to the URL. Add a DiffSuppressFunc to fix the test: