@@ -24044,12 +24044,14 @@ func TestValidateLoadBalancerStatus(t *testing.T) {
24044
24044
testCases := []struct {
24045
24045
name string
24046
24046
ipModeEnabled bool
24047
+ nonLBAllowed bool
24047
24048
tweakLBStatus func(s *core.LoadBalancerStatus)
24048
24049
tweakSvcSpec func(s *core.ServiceSpec)
24049
24050
numErrs int
24050
24051
}{
24051
24052
{
24052
- name: "type is not LB",
24053
+ name: "type is not LB",
24054
+ nonLBAllowed: false,
24053
24055
tweakSvcSpec: func(s *core.ServiceSpec) {
24054
24056
s.Type = core.ServiceTypeClusterIP
24055
24057
},
@@ -24059,6 +24061,18 @@ func TestValidateLoadBalancerStatus(t *testing.T) {
24059
24061
}}
24060
24062
},
24061
24063
numErrs: 1,
24064
+ }, {
24065
+ name: "type is not LB. back-compat",
24066
+ nonLBAllowed: true,
24067
+ tweakSvcSpec: func(s *core.ServiceSpec) {
24068
+ s.Type = core.ServiceTypeClusterIP
24069
+ },
24070
+ tweakLBStatus: func(s *core.LoadBalancerStatus) {
24071
+ s.Ingress = []core.LoadBalancerIngress{{
24072
+ IP: "1.2.3.4",
24073
+ }}
24074
+ },
24075
+ numErrs: 0,
24062
24076
}, {
24063
24077
name: "valid vip ipMode",
24064
24078
ipModeEnabled: true,
@@ -24124,6 +24138,7 @@ func TestValidateLoadBalancerStatus(t *testing.T) {
24124
24138
featuregatetesting.SetFeatureGateEmulationVersionDuringTest(t, utilfeature.DefaultFeatureGate, version.MustParse("1.31"))
24125
24139
}
24126
24140
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.LoadBalancerIPMode, tc.ipModeEnabled)
24141
+ featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.AllowServiceLBStatusOnNonLB, tc.nonLBAllowed)
24127
24142
status := core.LoadBalancerStatus{}
24128
24143
tc.tweakLBStatus(&status)
24129
24144
spec := core.ServiceSpec{Type: core.ServiceTypeLoadBalancer}
0 commit comments