Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/controller/infrastructureconfig/sync_specstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ func syncVips(spec *[]configv1.IP, status *[]string) error {
if spec == nil || status == nil {
return fmt.Errorf("passed nil value as spec or status vip")
}

// If status is not initialized, it will cause issues when committing "null" value to update
if *status == nil {
*status = []string{}
}

// `spec` is empty, `status` with value: copy status to spec
if len(*spec) == 0 {
*spec = ip.StringsToIPs(*status)
Expand Down
47 changes: 47 additions & 0 deletions pkg/controller/infrastructureconfig/sync_specstatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,53 @@ func Test_SpecStatusSynchronizer(t *testing.T) {
},
},
},
{
name: "should handle vSphere UPI: empty unset apiServerInternalIPs and ingressIPs",
givenInfra: configv1.Infrastructure{
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
Spec: configv1.InfrastructureSpec{
PlatformSpec: configv1.PlatformSpec{
VSphere: &configv1.VSpherePlatformSpec{
APIServerInternalIPs: []configv1.IP{},
IngressIPs: []configv1.IP{},
MachineNetworks: []configv1.CIDR{"224.0.0.1/24", "224.0.1.1/24"},
},
},
},
Status: configv1.InfrastructureStatus{
Platform: configv1.VSpherePlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: "VSphere",
VSphere: &configv1.VSpherePlatformStatus{
MachineNetworks: []configv1.CIDR{"224.0.0.1/24", "224.0.1.1/24"},
},
},
},
},
wantedInfra: configv1.Infrastructure{
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
Spec: configv1.InfrastructureSpec{
PlatformSpec: configv1.PlatformSpec{
VSphere: &configv1.VSpherePlatformSpec{
APIServerInternalIPs: []configv1.IP{},
IngressIPs: []configv1.IP{},
MachineNetworks: []configv1.CIDR{"224.0.0.1/24", "224.0.1.1/24"},
},
},
},
Status: configv1.InfrastructureStatus{
Platform: configv1.VSpherePlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: "VSphere",
VSphere: &configv1.VSpherePlatformStatus{
APIServerInternalIPs: []string{},
IngressIPs: []string{},
MachineNetworks: []configv1.CIDR{"224.0.0.1/24", "224.0.1.1/24"},
},
},
},
},
},
}

for _, tt := range tests {
Expand Down