Skip to content

Commit 7e3f876

Browse files
committed
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.
1 parent 852f012 commit 7e3f876

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

upup/pkg/fi/cloudup/gcetasks/instancetemplate.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222
"reflect"
23+
"slices"
2324
"sort"
2425
"strconv"
2526
"strings"
@@ -411,6 +412,12 @@ func (a ByKey) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
411412
func (a ByKey) Less(i, j int) bool { return a[i].Key < a[j].Key }
412413

413414
func matches(l, r *compute.InstanceTemplate) bool {
415+
normalizeServiceAccount := func(v *compute.ServiceAccount) *compute.ServiceAccount {
416+
c := *v
417+
c.Scopes = slices.Clone(c.Scopes)
418+
sort.Strings(c.Scopes)
419+
return &c
420+
}
414421
normalizeInstanceProperties := func(v *compute.InstanceProperties) *compute.InstanceProperties {
415422
c := *v
416423
if c.Metadata != nil {
@@ -419,6 +426,11 @@ func matches(l, r *compute.InstanceTemplate) bool {
419426
c.Metadata.Fingerprint = ""
420427
sort.Sort(ByKey(c.Metadata.Items))
421428
}
429+
if c.ServiceAccounts != nil {
430+
for i, serviceAccount := range c.ServiceAccounts {
431+
c.ServiceAccounts[i] = normalizeServiceAccount(serviceAccount)
432+
}
433+
}
422434
// Ignore output fields
423435
for _, ni := range c.NetworkInterfaces {
424436
ni.Name = ""

0 commit comments

Comments
 (0)