Promote the ServiceInternalTrafficPolicy field to Beta and on by default (#103462)
* pkg/features: promote the ServiceInternalTrafficPolicy field to Beta and on by default Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com> * pkg/api/service/testing: update Service test fixture functions to set internalTrafficPolicy=Cluster by default Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com> * pkg/apis/core/validation: add more Service validation tests for internalTrafficPolicy Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com> * pkg/registry/core/service/storage: fix failing Service REST storage tests to use internalTrafficPolicy: Cluster Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com> * pkg/registry/core/service/storage: add two test cases for Service REST TestServiceRegistryInternalTrafficPolicyClusterThenLocal and TestServiceRegistryInternalTrafficPolicyLocalThenCluster Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com> * pkg/registry/core/service: update strategy unit tests to expect default internalTrafficPolicy=Cluster Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com> * pkg/proxy/ipvs: fix unit test Test_EndpointSliceReadyAndTerminatingLocal to use internalTrafficPolicy=Cluster Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com> * pkg/apis/core: update fuzzers to set Service internalTrafficPolicy field Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com> * pkg/api/service/testing: refactor Service test fixtures to use Tweak funcs Signed-off-by: Andrew Sy Kim <kim.andrewsy@gmail.com>
This commit is contained in:
@@ -297,6 +297,10 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
|
||||
types := []core.ServiceExternalTrafficPolicyType{core.ServiceExternalTrafficPolicyTypeCluster, core.ServiceExternalTrafficPolicyTypeLocal}
|
||||
*p = types[c.Rand.Intn(len(types))]
|
||||
},
|
||||
func(p *core.ServiceInternalTrafficPolicyType, c fuzz.Continue) {
|
||||
types := []core.ServiceInternalTrafficPolicyType{core.ServiceInternalTrafficPolicyCluster, core.ServiceInternalTrafficPolicyLocal}
|
||||
*p = types[c.Rand.Intn(len(types))]
|
||||
},
|
||||
func(ct *core.Container, c fuzz.Continue) {
|
||||
c.FuzzNoCustom(ct) // fuzz self without calling this function again
|
||||
ct.TerminationMessagePath = "/" + ct.TerminationMessagePath // Must be non-empty
|
||||
|
@@ -10333,6 +10333,7 @@ func TestValidatePodStatusUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
func makeValidService() core.Service {
|
||||
clusterInternalTrafficPolicy := core.ServiceInternalTrafficPolicyCluster
|
||||
return core.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "valid",
|
||||
@@ -10342,10 +10343,11 @@ func makeValidService() core.Service {
|
||||
ResourceVersion: "1",
|
||||
},
|
||||
Spec: core.ServiceSpec{
|
||||
Selector: map[string]string{"key": "val"},
|
||||
SessionAffinity: "None",
|
||||
Type: core.ServiceTypeClusterIP,
|
||||
Ports: []core.ServicePort{{Name: "p", Protocol: "TCP", Port: 8675, TargetPort: intstr.FromInt(8675)}},
|
||||
Selector: map[string]string{"key": "val"},
|
||||
SessionAffinity: "None",
|
||||
Type: core.ServiceTypeClusterIP,
|
||||
Ports: []core.ServicePort{{Name: "p", Protocol: "TCP", Port: 8675, TargetPort: intstr.FromInt(8675)}},
|
||||
InternalTrafficPolicy: &clusterInternalTrafficPolicy,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -11286,6 +11288,22 @@ func TestValidateServiceCreate(t *testing.T) {
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
{
|
||||
name: "internalTrafficPolicy field set to Cluster",
|
||||
tweakSvc: func(s *core.Service) {
|
||||
cluster := core.ServiceInternalTrafficPolicyCluster
|
||||
s.Spec.InternalTrafficPolicy = &cluster
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "internalTrafficPolicy field set to Local",
|
||||
tweakSvc: func(s *core.Service) {
|
||||
local := core.ServiceInternalTrafficPolicyLocal
|
||||
s.Spec.InternalTrafficPolicy = &local
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "nagative healthCheckNodePort field",
|
||||
tweakSvc: func(s *core.Service) {
|
||||
@@ -14370,6 +14388,28 @@ func TestValidateServiceUpdate(t *testing.T) {
|
||||
},
|
||||
numErrs: 2,
|
||||
},
|
||||
{
|
||||
name: "update internalTrafficPolicy from Cluster to Local",
|
||||
tweakSvc: func(oldSvc, newSvc *core.Service) {
|
||||
cluster := core.ServiceInternalTrafficPolicyCluster
|
||||
oldSvc.Spec.InternalTrafficPolicy = &cluster
|
||||
|
||||
local := core.ServiceInternalTrafficPolicyLocal
|
||||
newSvc.Spec.InternalTrafficPolicy = &local
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
{
|
||||
name: "update internalTrafficPolicy from Local to Cluster",
|
||||
tweakSvc: func(oldSvc, newSvc *core.Service) {
|
||||
local := core.ServiceInternalTrafficPolicyLocal
|
||||
oldSvc.Spec.InternalTrafficPolicy = &local
|
||||
|
||||
cluster := core.ServiceInternalTrafficPolicyCluster
|
||||
newSvc.Spec.InternalTrafficPolicy = &cluster
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
Reference in New Issue
Block a user