From 7e3f87671721033dfde747fc5ef9eef1c92838a0 Mon Sep 17 00:00:00 2001 From: justinsb Date: Sun, 27 Apr 2025 14:57:48 -0400 Subject: [PATCH] gce: normalize scopes in comparison The order of scopes should not matter here, so do not force a new instance template just because the order is different. --- upup/pkg/fi/cloudup/gcetasks/instancetemplate.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go b/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go index 6fc7efec3ece8..c74c99bac75ab 100644 --- a/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go +++ b/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "reflect" + "slices" "sort" "strconv" "strings" @@ -411,6 +412,12 @@ func (a ByKey) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func (a ByKey) Less(i, j int) bool { return a[i].Key < a[j].Key } func matches(l, r *compute.InstanceTemplate) bool { + normalizeServiceAccount := func(v *compute.ServiceAccount) *compute.ServiceAccount { + c := *v + c.Scopes = slices.Clone(c.Scopes) + sort.Strings(c.Scopes) + return &c + } normalizeInstanceProperties := func(v *compute.InstanceProperties) *compute.InstanceProperties { c := *v if c.Metadata != nil { @@ -419,6 +426,11 @@ func matches(l, r *compute.InstanceTemplate) bool { c.Metadata.Fingerprint = "" sort.Sort(ByKey(c.Metadata.Items)) } + if c.ServiceAccounts != nil { + for i, serviceAccount := range c.ServiceAccounts { + c.ServiceAccounts[i] = normalizeServiceAccount(serviceAccount) + } + } // Ignore output fields for _, ni := range c.NetworkInterfaces { ni.Name = ""