From d37953536258c46c547f181e902a774538793e23 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Fri, 26 Apr 2024 17:15:35 +0000 Subject: [PATCH 1/2] tag TrafficDistribution tests to avoid running on clusters without the feature enabled --- test/e2e/feature/feature.go | 7 ++++++- test/e2e/network/traffic_distribution.go | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/e2e/feature/feature.go b/test/e2e/feature/feature.go index db0200bbe42..65aca91ea69 100644 --- a/test/e2e/feature/feature.go +++ b/test/e2e/feature/feature.go @@ -321,9 +321,14 @@ var ( // TODO: document the feature (owning SIG, when to use this feature for a test) StorageVersionAPI = framework.WithFeature(framework.ValidFeatures.Add("StorageVersionAPI")) - // TODO: document the feature (owning SIG, when to use this feature for a test) + // Owner: sig-network + // Marks tests that require a cluster with Topology Hints enabled. TopologyHints = framework.WithFeature(framework.ValidFeatures.Add("Topology Hints")) + // Owner: sig-network + // Marks tests that require a cluster with Traffic Distribution enabled. + TrafficDistribution = framework.WithFeature(framework.ValidFeatures.Add("Traffic Distribution")) + // TODO: document the feature (owning SIG, when to use this feature for a test) TopologyManager = framework.WithFeature(framework.ValidFeatures.Add("TopologyManager")) diff --git a/test/e2e/network/traffic_distribution.go b/test/e2e/network/traffic_distribution.go index 59ed3bbffcd..d56dfbd7141 100644 --- a/test/e2e/network/traffic_distribution.go +++ b/test/e2e/network/traffic_distribution.go @@ -28,6 +28,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" clientset "k8s.io/client-go/kubernetes" + "k8s.io/kubernetes/test/e2e/feature" "k8s.io/kubernetes/test/e2e/framework" e2enode "k8s.io/kubernetes/test/e2e/framework/node" e2epod "k8s.io/kubernetes/test/e2e/framework/pod" @@ -41,7 +42,7 @@ import ( "github.com/onsi/gomega" ) -var _ = common.SIGDescribe("TrafficDistribution", func() { +var _ = common.SIGDescribe(feature.TrafficDistribution, func() { f := framework.NewDefaultFramework("traffic-distribution") f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged From d17cd6ef75c4b6f9a8a0ed0aa20ea9aa99b96e44 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Fri, 26 Apr 2024 17:19:25 +0000 Subject: [PATCH 2/2] tag service.spec.TrafficDistribution field as alpha --- api/openapi-spec/swagger.json | 2 +- api/openapi-spec/v3/api__v1_openapi.json | 2 +- pkg/generated/openapi/zz_generated.openapi.go | 2 +- staging/src/k8s.io/api/core/v1/generated.proto | 2 ++ staging/src/k8s.io/api/core/v1/types.go | 2 ++ staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go | 2 +- 6 files changed, 8 insertions(+), 4 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index c5d57305c66..74acfcdeb80 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -11248,7 +11248,7 @@ "description": "sessionAffinityConfig contains the configurations of session affinity." }, "trafficDistribution": { - "description": "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone).", + "description": "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone). This is an alpha field and requires enabling ServiceTrafficDistribution feature.", "type": "string" }, "type": { diff --git a/api/openapi-spec/v3/api__v1_openapi.json b/api/openapi-spec/v3/api__v1_openapi.json index 7d42bbcac86..e7ab449310a 100644 --- a/api/openapi-spec/v3/api__v1_openapi.json +++ b/api/openapi-spec/v3/api__v1_openapi.json @@ -7550,7 +7550,7 @@ "description": "sessionAffinityConfig contains the configurations of session affinity." }, "trafficDistribution": { - "description": "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone).", + "description": "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone). This is an alpha field and requires enabling ServiceTrafficDistribution feature.", "type": "string" }, "type": { diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 1fc94fee217..a910c505854 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -30662,7 +30662,7 @@ func schema_k8sio_api_core_v1_ServiceSpec(ref common.ReferenceCallback) common.O }, "trafficDistribution": { SchemaProps: spec.SchemaProps{ - Description: "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone).", + Description: "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone). This is an alpha field and requires enabling ServiceTrafficDistribution feature.", Type: []string{"string"}, Format: "", }, diff --git a/staging/src/k8s.io/api/core/v1/generated.proto b/staging/src/k8s.io/api/core/v1/generated.proto index 021e45e890a..b304ead5135 100644 --- a/staging/src/k8s.io/api/core/v1/generated.proto +++ b/staging/src/k8s.io/api/core/v1/generated.proto @@ -5838,6 +5838,8 @@ message ServiceSpec { // not set, the implementation will apply its default routing strategy. If set // to "PreferClose", implementations should prioritize endpoints that are // topologically close (e.g., same zone). + // This is an alpha field and requires enabling ServiceTrafficDistribution feature. + // +featureGate=ServiceTrafficDistribution // +optional optional string trafficDistribution = 23; } diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index 803679c48ba..3c0c4d0c469 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -5366,6 +5366,8 @@ type ServiceSpec struct { // not set, the implementation will apply its default routing strategy. If set // to "PreferClose", implementations should prioritize endpoints that are // topologically close (e.g., same zone). + // This is an alpha field and requires enabling ServiceTrafficDistribution feature. + // +featureGate=ServiceTrafficDistribution // +optional TrafficDistribution *string `json:"trafficDistribution,omitempty" protobuf:"bytes,23,opt,name=trafficDistribution"` } diff --git a/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go index 5470aebc559..7e58651adad 100644 --- a/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go @@ -2420,7 +2420,7 @@ var map_ServiceSpec = map[string]string{ "allocateLoadBalancerNodePorts": "allocateLoadBalancerNodePorts defines if NodePorts will be automatically allocated for services with type LoadBalancer. Default is \"true\". It may be set to \"false\" if the cluster load-balancer does not rely on NodePorts. If the caller requests specific NodePorts (by specifying a value), those requests will be respected, regardless of this field. This field may only be set for services with type LoadBalancer and will be cleared if the type is changed to any other type.", "loadBalancerClass": "loadBalancerClass is the class of the load balancer implementation this Service belongs to. If specified, the value of this field must be a label-style identifier, with an optional prefix, e.g. \"internal-vip\" or \"example.com/internal-vip\". Unprefixed names are reserved for end-users. This field can only be set when the Service type is 'LoadBalancer'. If not set, the default load balancer implementation is used, today this is typically done through the cloud provider integration, but should apply for any default implementation. If set, it is assumed that a load balancer implementation is watching for Services with a matching class. Any default load balancer implementation (e.g. cloud providers) should ignore Services that set this field. This field can only be set when creating or updating a Service to type 'LoadBalancer'. Once set, it can not be changed. This field will be wiped when a service is updated to a non 'LoadBalancer' type.", "internalTrafficPolicy": "InternalTrafficPolicy describes how nodes distribute service traffic they receive on the ClusterIP. If set to \"Local\", the proxy will assume that pods only want to talk to endpoints of the service on the same node as the pod, dropping the traffic if there are no local endpoints. The default value, \"Cluster\", uses the standard behavior of routing to all endpoints evenly (possibly modified by topology and other features).", - "trafficDistribution": "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone).", + "trafficDistribution": "TrafficDistribution offers a way to express preferences for how traffic is distributed to Service endpoints. Implementations can use this field as a hint, but are not required to guarantee strict adherence. If the field is not set, the implementation will apply its default routing strategy. If set to \"PreferClose\", implementations should prioritize endpoints that are topologically close (e.g., same zone). This is an alpha field and requires enabling ServiceTrafficDistribution feature.", } func (ServiceSpec) SwaggerDoc() map[string]string {