Skip to content

Commit c563eb4

Browse files
Merge pull request #2795 from vr4manta/SPLAT-2503
SPLAT-2503: Fixed "null" value for vSphere api and ingress VIP in UPI scenario
2 parents a587975 + f8a4b09 commit c563eb4

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

pkg/controller/infrastructureconfig/sync_specstatus.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@ func syncVips(spec *[]configv1.IP, status *[]string) error {
182182
if spec == nil || status == nil {
183183
return fmt.Errorf("passed nil value as spec or status vip")
184184
}
185+
186+
// If status is not initialized, it will cause issues when committing "null" value to update
187+
if *status == nil {
188+
*status = []string{}
189+
}
190+
185191
// `spec` is empty, `status` with value: copy status to spec
186192
if len(*spec) == 0 {
187193
*spec = ip.StringsToIPs(*status)

pkg/controller/infrastructureconfig/sync_specstatus_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,53 @@ func Test_SpecStatusSynchronizer(t *testing.T) {
911911
},
912912
},
913913
},
914+
{
915+
name: "should handle vSphere UPI: empty unset apiServerInternalIPs and ingressIPs",
916+
givenInfra: configv1.Infrastructure{
917+
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
918+
Spec: configv1.InfrastructureSpec{
919+
PlatformSpec: configv1.PlatformSpec{
920+
VSphere: &configv1.VSpherePlatformSpec{
921+
APIServerInternalIPs: []configv1.IP{},
922+
IngressIPs: []configv1.IP{},
923+
MachineNetworks: []configv1.CIDR{"224.0.0.1/24", "224.0.1.1/24"},
924+
},
925+
},
926+
},
927+
Status: configv1.InfrastructureStatus{
928+
Platform: configv1.VSpherePlatformType,
929+
PlatformStatus: &configv1.PlatformStatus{
930+
Type: "VSphere",
931+
VSphere: &configv1.VSpherePlatformStatus{
932+
MachineNetworks: []configv1.CIDR{"224.0.0.1/24", "224.0.1.1/24"},
933+
},
934+
},
935+
},
936+
},
937+
wantedInfra: configv1.Infrastructure{
938+
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
939+
Spec: configv1.InfrastructureSpec{
940+
PlatformSpec: configv1.PlatformSpec{
941+
VSphere: &configv1.VSpherePlatformSpec{
942+
APIServerInternalIPs: []configv1.IP{},
943+
IngressIPs: []configv1.IP{},
944+
MachineNetworks: []configv1.CIDR{"224.0.0.1/24", "224.0.1.1/24"},
945+
},
946+
},
947+
},
948+
Status: configv1.InfrastructureStatus{
949+
Platform: configv1.VSpherePlatformType,
950+
PlatformStatus: &configv1.PlatformStatus{
951+
Type: "VSphere",
952+
VSphere: &configv1.VSpherePlatformStatus{
953+
APIServerInternalIPs: []string{},
954+
IngressIPs: []string{},
955+
MachineNetworks: []configv1.CIDR{"224.0.0.1/24", "224.0.1.1/24"},
956+
},
957+
},
958+
},
959+
},
960+
},
914961
}
915962

916963
for _, tt := range tests {

0 commit comments

Comments
 (0)