mirror of https://github.com/k3s-io/k3s
Merge pull request #33346 from freehan/fix-lbsrcrange-update
Automatic merge from submit-queue disallow user to update loadbalancerSourceRanges buy myself some time to fix the root cause of #33033pull/6/head
commit
09e0e025e8
|
@ -2568,6 +2568,9 @@ func ValidateServiceUpdate(service, oldService *api.Service) field.ErrorList {
|
|||
allErrs = append(allErrs, ValidateImmutableField(service.Spec.ClusterIP, oldService.Spec.ClusterIP, field.NewPath("spec", "clusterIP"))...)
|
||||
}
|
||||
|
||||
// TODO(freehan): allow user to update loadbalancerSourceRanges
|
||||
allErrs = append(allErrs, ValidateImmutableField(service.Spec.LoadBalancerSourceRanges, oldService.Spec.LoadBalancerSourceRanges, field.NewPath("spec", "loadBalancerSourceRanges"))...)
|
||||
|
||||
allErrs = append(allErrs, ValidateService(service)...)
|
||||
return allErrs
|
||||
}
|
||||
|
|
|
@ -6388,6 +6388,25 @@ func TestValidateServiceUpdate(t *testing.T) {
|
|||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "add loadBalancerSourceRanges",
|
||||
tweakSvc: func(oldSvc, newSvc *api.Service) {
|
||||
oldSvc.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
newSvc.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
newSvc.Spec.LoadBalancerSourceRanges = []string{"10.0.0.0/8"}
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "update loadBalancerSourceRanges",
|
||||
tweakSvc: func(oldSvc, newSvc *api.Service) {
|
||||
oldSvc.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
oldSvc.Spec.LoadBalancerSourceRanges = []string{"10.0.0.0/8"}
|
||||
newSvc.Spec.Type = api.ServiceTypeLoadBalancer
|
||||
newSvc.Spec.LoadBalancerSourceRanges = []string{"10.180.0.0/16"}
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
|
Loading…
Reference in New Issue