mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-14 05:36:12 +00:00
Rename 'portal IP' to 'cluster IP' most everywhere
This covers obvious transforms, but not --portal_net, $PORTAL_NET and similar.
This commit is contained in:
@@ -1063,8 +1063,8 @@ func ValidateService(service *api.Service) errs.ValidationErrorList {
|
||||
}
|
||||
|
||||
if api.IsServiceIPSet(service) {
|
||||
if ip := net.ParseIP(service.Spec.PortalIP); ip == nil {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.portalIP", service.Spec.PortalIP, "portalIP should be empty, 'None', or a valid IP address"))
|
||||
if ip := net.ParseIP(service.Spec.ClusterIP); ip == nil {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.clusterIP", service.Spec.ClusterIP, "clusterIP should be empty, 'None', or a valid IP address"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1157,10 +1157,8 @@ func ValidateServiceUpdate(oldService, service *api.Service) errs.ValidationErro
|
||||
allErrs := errs.ValidationErrorList{}
|
||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldService.ObjectMeta, &service.ObjectMeta).Prefix("metadata")...)
|
||||
|
||||
// TODO: PortalIP should be a Status field, since the system can set a value != to the user's value
|
||||
// once PortalIP is set, it cannot be unset.
|
||||
if api.IsServiceIPSet(oldService) && service.Spec.PortalIP != oldService.Spec.PortalIP {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.portalIP", service.Spec.PortalIP, "field is immutable"))
|
||||
if api.IsServiceIPSet(oldService) && service.Spec.ClusterIP != oldService.Spec.ClusterIP {
|
||||
allErrs = append(allErrs, errs.NewFieldInvalid("spec.clusterIP", service.Spec.ClusterIP, "field is immutable"))
|
||||
}
|
||||
|
||||
allErrs = append(allErrs, ValidateService(service)...)
|
||||
|
@@ -1581,9 +1581,9 @@ func TestValidateService(t *testing.T) {
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "invalid portal ip",
|
||||
name: "invalid cluster ip",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.PortalIP = "invalid"
|
||||
s.Spec.ClusterIP = "invalid"
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
@@ -1676,16 +1676,16 @@ func TestValidateService(t *testing.T) {
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "valid portal ip - none ",
|
||||
name: "valid cluster ip - none ",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.PortalIP = "None"
|
||||
s.Spec.ClusterIP = "None"
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "valid portal ip - empty",
|
||||
name: "valid cluster ip - empty",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.PortalIP = ""
|
||||
s.Spec.ClusterIP = ""
|
||||
s.Spec.Ports[0].TargetPort = util.NewIntOrStringFromString("http")
|
||||
},
|
||||
numErrs: 0,
|
||||
@@ -2556,18 +2556,18 @@ func TestValidateServiceUpdate(t *testing.T) {
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "change portal IP",
|
||||
name: "change cluster IP",
|
||||
tweakSvc: func(oldSvc, newSvc *api.Service) {
|
||||
oldSvc.Spec.PortalIP = "1.2.3.4"
|
||||
newSvc.Spec.PortalIP = "8.6.7.5"
|
||||
oldSvc.Spec.ClusterIP = "1.2.3.4"
|
||||
newSvc.Spec.ClusterIP = "8.6.7.5"
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "remove portal IP",
|
||||
name: "remove cluster IP",
|
||||
tweakSvc: func(oldSvc, newSvc *api.Service) {
|
||||
oldSvc.Spec.PortalIP = "1.2.3.4"
|
||||
newSvc.Spec.PortalIP = ""
|
||||
oldSvc.Spec.ClusterIP = "1.2.3.4"
|
||||
newSvc.Spec.ClusterIP = ""
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
|
Reference in New Issue
Block a user