Skip to content

Commit 046459b

Browse files
fix: do not copy nil values from primary to secondary configs (#4158)
* fix: do not copy nil values from primary to secondary configs * fix: keep loadBalanacerBackendAddressPools
1 parent 5332db0 commit 046459b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

test/integration/cilium-nodesubnet/ipconfigupdate.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,21 @@ func main() {
100100
}
101101

102102
if primaryIPConfig != nil {
103-
for i := 2; i <= secondaryConfigCount+1; i++ {
103+
ipConfigurations = []interface{}{}
104+
for i := 1; i <= secondaryConfigCount+1; i++ {
104105
ipConfig := make(map[string]interface{})
105106
for k, v := range primaryIPConfig {
107+
// Skip nil values.
108+
if v == nil {
109+
continue
110+
}
111+
106112
// only the primary config needs loadBalancerBackendAddressPools. Azure doesn't allow
107113
// secondary IP configs to be associated load balancer backend pools.
108-
if k == "loadBalancerBackendAddressPools" {
114+
if i > 1 && k == "loadBalancerBackendAddressPools" {
109115
continue
110116
}
117+
111118
ipConfig[k] = v
112119
}
113120

@@ -117,6 +124,8 @@ func main() {
117124
ipConfig["primary"] = false
118125
usedIPConfigNames = append(usedIPConfigNames, ipConfigName)
119126
secondaryConfigs = append(secondaryConfigs, ipConfig)
127+
} else {
128+
ipConfigurations = append(ipConfigurations, ipConfig)
120129
}
121130
}
122131
}

0 commit comments

Comments
 (0)