diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index c5e0cd27e2b..cf1c2464554 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -39818,16 +39818,13 @@ }, "io.k8s.kubernetes.pkg.api.v1.PodAffinityTerm": { "description": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key \u003ctopologyKey\u003e tches that of any node on which a pod of the set of pods is running", - "required": [ - "namespaces" - ], "properties": { "labelSelector": { "description": "A label query over a set of resources, in this case pods.", "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" }, "namespaces": { - "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.", + "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"", "type": "array", "items": { "type": "string" diff --git a/api/swagger-spec/apps_v1beta1.json b/api/swagger-spec/apps_v1beta1.json index 79cd0234061..a3c5447002c 100644 --- a/api/swagger-spec/apps_v1beta1.json +++ b/api/swagger-spec/apps_v1beta1.json @@ -4259,9 +4259,6 @@ "v1.PodAffinityTerm": { "id": "v1.PodAffinityTerm", "description": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key \u003ctopologyKey\u003e tches that of any node on which a pod of the set of pods is running", - "required": [ - "namespaces" - ], "properties": { "labelSelector": { "$ref": "v1.LabelSelector", @@ -4272,7 +4269,7 @@ "items": { "type": "string" }, - "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details." + "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"" }, "topologyKey": { "type": "string", diff --git a/api/swagger-spec/batch_v1.json b/api/swagger-spec/batch_v1.json index 1f1d5b21b7e..73c4b10aa5f 100644 --- a/api/swagger-spec/batch_v1.json +++ b/api/swagger-spec/batch_v1.json @@ -3042,9 +3042,6 @@ "v1.PodAffinityTerm": { "id": "v1.PodAffinityTerm", "description": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key \u003ctopologyKey\u003e tches that of any node on which a pod of the set of pods is running", - "required": [ - "namespaces" - ], "properties": { "labelSelector": { "$ref": "v1.LabelSelector", @@ -3055,7 +3052,7 @@ "items": { "type": "string" }, - "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details." + "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"" }, "topologyKey": { "type": "string", diff --git a/api/swagger-spec/extensions_v1beta1.json b/api/swagger-spec/extensions_v1beta1.json index 81a42959215..f9be475bc23 100644 --- a/api/swagger-spec/extensions_v1beta1.json +++ b/api/swagger-spec/extensions_v1beta1.json @@ -8506,9 +8506,6 @@ "v1.PodAffinityTerm": { "id": "v1.PodAffinityTerm", "description": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key \u003ctopologyKey\u003e tches that of any node on which a pod of the set of pods is running", - "required": [ - "namespaces" - ], "properties": { "labelSelector": { "$ref": "v1.LabelSelector", @@ -8519,7 +8516,7 @@ "items": { "type": "string" }, - "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details." + "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"" }, "topologyKey": { "type": "string", diff --git a/api/swagger-spec/v1.json b/api/swagger-spec/v1.json index 7ee08c4d090..0a95ec4c538 100644 --- a/api/swagger-spec/v1.json +++ b/api/swagger-spec/v1.json @@ -19857,9 +19857,6 @@ "v1.PodAffinityTerm": { "id": "v1.PodAffinityTerm", "description": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key \u003ctopologyKey\u003e tches that of any node on which a pod of the set of pods is running", - "required": [ - "namespaces" - ], "properties": { "labelSelector": { "$ref": "v1.LabelSelector", @@ -19870,7 +19867,7 @@ "items": { "type": "string" }, - "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details." + "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"" }, "topologyKey": { "type": "string", diff --git a/docs/api-reference/apps/v1beta1/definitions.html b/docs/api-reference/apps/v1beta1/definitions.html index 31a4c6db5c8..cb818fa258a 100755 --- a/docs/api-reference/apps/v1beta1/definitions.html +++ b/docs/api-reference/apps/v1beta1/definitions.html @@ -1984,8 +1984,8 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

namespaces

-

namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means "this pod’s namespace," empty list means "all namespaces" The json tag here is not "omitempty" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.

-

true

+

namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means "this pod’s namespace"

+

false

string array

diff --git a/docs/api-reference/batch/v1/definitions.html b/docs/api-reference/batch/v1/definitions.html index 9a712a95e02..d79d711ea37 100755 --- a/docs/api-reference/batch/v1/definitions.html +++ b/docs/api-reference/batch/v1/definitions.html @@ -2818,8 +2818,8 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

namespaces

-

namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means "this pod’s namespace," empty list means "all namespaces" The json tag here is not "omitempty" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.

-

true

+

namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means "this pod’s namespace"

+

false

string array

diff --git a/docs/api-reference/extensions/v1beta1/definitions.html b/docs/api-reference/extensions/v1beta1/definitions.html index 8d4a89f8293..5da07c048d5 100755 --- a/docs/api-reference/extensions/v1beta1/definitions.html +++ b/docs/api-reference/extensions/v1beta1/definitions.html @@ -2604,8 +2604,8 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

namespaces

-

namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means "this pod’s namespace," empty list means "all namespaces" The json tag here is not "omitempty" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.

-

true

+

namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means "this pod’s namespace"

+

false

string array

diff --git a/docs/api-reference/v1/definitions.html b/docs/api-reference/v1/definitions.html index 64d952d52de..4e64f0d6fa6 100755 --- a/docs/api-reference/v1/definitions.html +++ b/docs/api-reference/v1/definitions.html @@ -2737,8 +2737,8 @@ Populated by the system when a graceful deletion is requested. Read-only. More i

namespaces

-

namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means "this pod’s namespace," empty list means "all namespaces" The json tag here is not "omitempty" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.

-

true

+

namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means "this pod’s namespace"

+

false

string array

diff --git a/federation/apis/openapi-spec/swagger.json b/federation/apis/openapi-spec/swagger.json index 3ebecee87e1..68ed5b05827 100644 --- a/federation/apis/openapi-spec/swagger.json +++ b/federation/apis/openapi-spec/swagger.json @@ -10586,16 +10586,13 @@ }, "io.k8s.kubernetes.pkg.api.v1.PodAffinityTerm": { "description": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key \u003ctopologyKey\u003e tches that of any node on which a pod of the set of pods is running", - "required": [ - "namespaces" - ], "properties": { "labelSelector": { "description": "A label query over a set of resources, in this case pods.", "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelector" }, "namespaces": { - "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.", + "description": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"", "type": "array", "items": { "type": "string" diff --git a/pkg/api/types.go b/pkg/api/types.go index 6b3dbfc4bea..4f423695087 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -1886,9 +1886,7 @@ type PodAffinityTerm struct { // +optional LabelSelector *metav1.LabelSelector // namespaces specifies which namespaces the labelSelector applies to (matches against); - // nil list means "this pod's namespace," empty list means "all namespaces" - // The json tag here is not "omitempty" since we need to distinguish nil and empty. - // See https://golang.org/pkg/encoding/json/#Marshal for more details. + // null or empty list means "this pod's namespace" Namespaces []string // This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching // the labelSelector in the specified namespaces, where co-located is defined as running on a node diff --git a/pkg/api/v1/generated.proto b/pkg/api/v1/generated.proto index c5e86044ab2..9c48148aafd 100644 --- a/pkg/api/v1/generated.proto +++ b/pkg/api/v1/generated.proto @@ -2279,9 +2279,7 @@ message PodAffinityTerm { optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector labelSelector = 1; // namespaces specifies which namespaces the labelSelector applies to (matches against); - // nil list means "this pod's namespace," empty list means "all namespaces" - // The json tag here is not "omitempty" since we need to distinguish nil and empty. - // See https://golang.org/pkg/encoding/json/#Marshal for more details. + // null or empty list means "this pod's namespace" repeated string namespaces = 2; // This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching diff --git a/pkg/api/v1/types.generated.go b/pkg/api/v1/types.generated.go index 8eefc7c906c..c6fd805aa5a 100644 --- a/pkg/api/v1/types.generated.go +++ b/pkg/api/v1/types.generated.go @@ -32190,12 +32190,13 @@ func (x *PodAffinityTerm) CodecEncodeSelf(e *codec1978.Encoder) { _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false yyq2[0] = x.LabelSelector != nil + yyq2[1] = len(x.Namespaces) != 0 yyq2[2] = x.TopologyKey != "" var yynn2 int if yyr2 || yy2arr2 { r.EncodeArrayStart(3) } else { - yynn2 = 1 + yynn2 = 0 for _, b := range yyq2 { if b { yynn2++ @@ -32241,28 +32242,34 @@ func (x *PodAffinityTerm) CodecEncodeSelf(e *codec1978.Encoder) { } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if x.Namespaces == nil { - r.EncodeNil() - } else { - yym7 := z.EncBinary() - _ = yym7 - if false { + if yyq2[1] { + if x.Namespaces == nil { + r.EncodeNil() } else { - z.F.EncSliceStringV(x.Namespaces, false, e) + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + z.F.EncSliceStringV(x.Namespaces, false, e) + } } + } else { + r.EncodeNil() } } else { - z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("namespaces")) - z.EncSendContainerState(codecSelfer_containerMapValue1234) - if x.Namespaces == nil { - r.EncodeNil() - } else { - yym8 := z.EncBinary() - _ = yym8 - if false { + if yyq2[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("namespaces")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.Namespaces == nil { + r.EncodeNil() } else { - z.F.EncSliceStringV(x.Namespaces, false, e) + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + z.F.EncSliceStringV(x.Namespaces, false, e) + } } } } diff --git a/pkg/api/v1/types.go b/pkg/api/v1/types.go index e7f59f648bd..a75a1d0f069 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -2102,10 +2102,8 @@ type PodAffinityTerm struct { // +optional LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty" protobuf:"bytes,1,opt,name=labelSelector"` // namespaces specifies which namespaces the labelSelector applies to (matches against); - // nil list means "this pod's namespace," empty list means "all namespaces" - // The json tag here is not "omitempty" since we need to distinguish nil and empty. - // See https://golang.org/pkg/encoding/json/#Marshal for more details. - Namespaces []string `json:"namespaces" protobuf:"bytes,2,rep,name=namespaces"` + // null or empty list means "this pod's namespace" + Namespaces []string `json:"namespaces,omitempty" protobuf:"bytes,2,rep,name=namespaces"` // This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching // the labelSelector in the specified namespaces, where co-located is defined as running on a node // whose value of the label with key topologyKey matches that of any node on which any of the diff --git a/pkg/api/v1/types_swagger_doc_generated.go b/pkg/api/v1/types_swagger_doc_generated.go index cbc16be2eb2..75416d59a23 100644 --- a/pkg/api/v1/types_swagger_doc_generated.go +++ b/pkg/api/v1/types_swagger_doc_generated.go @@ -1189,7 +1189,7 @@ func (PodAffinity) SwaggerDoc() map[string]string { var map_PodAffinityTerm = map[string]string{ "": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key tches that of any node on which a pod of the set of pods is running", "labelSelector": "A label query over a set of resources, in this case pods.", - "namespaces": "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.", + "namespaces": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"", "topologyKey": "This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. For PreferredDuringScheduling pod anti-affinity, empty topologyKey is interpreted as \"all topologies\" (\"all topologies\" here means all the topologyKeys indicated by scheduler command-line argument --failure-domains); for affinity and for RequiredDuringScheduling pod anti-affinity, empty topologyKey is not allowed.", } diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index c485dfce1bb..a27394a9ee4 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -5925,7 +5925,7 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope }, "namespaces": { SchemaProps: spec.SchemaProps{ - Description: "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.", + Description: "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"", Type: []string{"array"}, Items: &spec.SchemaOrArray{ Schema: &spec.Schema{ @@ -5945,7 +5945,6 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope }, }, }, - Required: []string{"namespaces"}, }, }, Dependencies: []string{ diff --git a/plugin/pkg/scheduler/algorithm/priorities/util/topologies.go b/plugin/pkg/scheduler/algorithm/priorities/util/topologies.go index 568e9253886..3615a7bc2f5 100644 --- a/plugin/pkg/scheduler/algorithm/priorities/util/topologies.go +++ b/plugin/pkg/scheduler/algorithm/priorities/util/topologies.go @@ -26,13 +26,12 @@ import ( // GetNamespacesFromPodAffinityTerm returns a set of names // according to the namespaces indicated in podAffinityTerm. -// 1. If the namespaces is nil considers the given pod's namespace -// 2. If the namespaces is empty list then considers all the namespaces +// If namespaces is empty it considers the given pod's namespace. func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffinityTerm) sets.String { names := sets.String{} - if podAffinityTerm.Namespaces == nil { + if len(podAffinityTerm.Namespaces) == 0 { names.Insert(pod.Namespace) - } else if len(podAffinityTerm.Namespaces) != 0 { + } else { names.Insert(podAffinityTerm.Namespaces...) } return names @@ -41,7 +40,7 @@ func GetNamespacesFromPodAffinityTerm(pod *v1.Pod, podAffinityTerm *v1.PodAffini // PodMatchesTermsNamespaceAndSelector returns true if the given // matches the namespace and selector defined by `s . func PodMatchesTermsNamespaceAndSelector(pod *v1.Pod, namespaces sets.String, selector labels.Selector) bool { - if len(namespaces) != 0 && !namespaces.Has(pod.Namespace) { + if !namespaces.Has(pod.Namespace) { return false } diff --git a/staging/src/k8s.io/client-go/pkg/api/types.go b/staging/src/k8s.io/client-go/pkg/api/types.go index 6b3dbfc4bea..4f423695087 100644 --- a/staging/src/k8s.io/client-go/pkg/api/types.go +++ b/staging/src/k8s.io/client-go/pkg/api/types.go @@ -1886,9 +1886,7 @@ type PodAffinityTerm struct { // +optional LabelSelector *metav1.LabelSelector // namespaces specifies which namespaces the labelSelector applies to (matches against); - // nil list means "this pod's namespace," empty list means "all namespaces" - // The json tag here is not "omitempty" since we need to distinguish nil and empty. - // See https://golang.org/pkg/encoding/json/#Marshal for more details. + // null or empty list means "this pod's namespace" Namespaces []string // This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching // the labelSelector in the specified namespaces, where co-located is defined as running on a node diff --git a/staging/src/k8s.io/client-go/pkg/api/v1/generated.proto b/staging/src/k8s.io/client-go/pkg/api/v1/generated.proto index c5e86044ab2..9c48148aafd 100644 --- a/staging/src/k8s.io/client-go/pkg/api/v1/generated.proto +++ b/staging/src/k8s.io/client-go/pkg/api/v1/generated.proto @@ -2279,9 +2279,7 @@ message PodAffinityTerm { optional k8s.io.apimachinery.pkg.apis.meta.v1.LabelSelector labelSelector = 1; // namespaces specifies which namespaces the labelSelector applies to (matches against); - // nil list means "this pod's namespace," empty list means "all namespaces" - // The json tag here is not "omitempty" since we need to distinguish nil and empty. - // See https://golang.org/pkg/encoding/json/#Marshal for more details. + // null or empty list means "this pod's namespace" repeated string namespaces = 2; // This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching diff --git a/staging/src/k8s.io/client-go/pkg/api/v1/types.generated.go b/staging/src/k8s.io/client-go/pkg/api/v1/types.generated.go index 8eefc7c906c..c6fd805aa5a 100644 --- a/staging/src/k8s.io/client-go/pkg/api/v1/types.generated.go +++ b/staging/src/k8s.io/client-go/pkg/api/v1/types.generated.go @@ -32190,12 +32190,13 @@ func (x *PodAffinityTerm) CodecEncodeSelf(e *codec1978.Encoder) { _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false yyq2[0] = x.LabelSelector != nil + yyq2[1] = len(x.Namespaces) != 0 yyq2[2] = x.TopologyKey != "" var yynn2 int if yyr2 || yy2arr2 { r.EncodeArrayStart(3) } else { - yynn2 = 1 + yynn2 = 0 for _, b := range yyq2 { if b { yynn2++ @@ -32241,28 +32242,34 @@ func (x *PodAffinityTerm) CodecEncodeSelf(e *codec1978.Encoder) { } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if x.Namespaces == nil { - r.EncodeNil() - } else { - yym7 := z.EncBinary() - _ = yym7 - if false { + if yyq2[1] { + if x.Namespaces == nil { + r.EncodeNil() } else { - z.F.EncSliceStringV(x.Namespaces, false, e) + yym7 := z.EncBinary() + _ = yym7 + if false { + } else { + z.F.EncSliceStringV(x.Namespaces, false, e) + } } + } else { + r.EncodeNil() } } else { - z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("namespaces")) - z.EncSendContainerState(codecSelfer_containerMapValue1234) - if x.Namespaces == nil { - r.EncodeNil() - } else { - yym8 := z.EncBinary() - _ = yym8 - if false { + if yyq2[1] { + z.EncSendContainerState(codecSelfer_containerMapKey1234) + r.EncodeString(codecSelferC_UTF81234, string("namespaces")) + z.EncSendContainerState(codecSelfer_containerMapValue1234) + if x.Namespaces == nil { + r.EncodeNil() } else { - z.F.EncSliceStringV(x.Namespaces, false, e) + yym8 := z.EncBinary() + _ = yym8 + if false { + } else { + z.F.EncSliceStringV(x.Namespaces, false, e) + } } } } diff --git a/staging/src/k8s.io/client-go/pkg/api/v1/types.go b/staging/src/k8s.io/client-go/pkg/api/v1/types.go index e7f59f648bd..a75a1d0f069 100644 --- a/staging/src/k8s.io/client-go/pkg/api/v1/types.go +++ b/staging/src/k8s.io/client-go/pkg/api/v1/types.go @@ -2102,10 +2102,8 @@ type PodAffinityTerm struct { // +optional LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty" protobuf:"bytes,1,opt,name=labelSelector"` // namespaces specifies which namespaces the labelSelector applies to (matches against); - // nil list means "this pod's namespace," empty list means "all namespaces" - // The json tag here is not "omitempty" since we need to distinguish nil and empty. - // See https://golang.org/pkg/encoding/json/#Marshal for more details. - Namespaces []string `json:"namespaces" protobuf:"bytes,2,rep,name=namespaces"` + // null or empty list means "this pod's namespace" + Namespaces []string `json:"namespaces,omitempty" protobuf:"bytes,2,rep,name=namespaces"` // This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching // the labelSelector in the specified namespaces, where co-located is defined as running on a node // whose value of the label with key topologyKey matches that of any node on which any of the diff --git a/staging/src/k8s.io/client-go/pkg/api/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/client-go/pkg/api/v1/types_swagger_doc_generated.go index cbc16be2eb2..75416d59a23 100644 --- a/staging/src/k8s.io/client-go/pkg/api/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/client-go/pkg/api/v1/types_swagger_doc_generated.go @@ -1189,7 +1189,7 @@ func (PodAffinity) SwaggerDoc() map[string]string { var map_PodAffinityTerm = map[string]string{ "": "Defines a set of pods (namely those matching the labelSelector relative to the given namespace(s)) that this pod should be co-located (affinity) or not co-located (anti-affinity) with, where co-located is defined as running on a node whose value of the label with key tches that of any node on which a pod of the set of pods is running", "labelSelector": "A label query over a set of resources, in this case pods.", - "namespaces": "namespaces specifies which namespaces the labelSelector applies to (matches against); nil list means \"this pod's namespace,\" empty list means \"all namespaces\" The json tag here is not \"omitempty\" since we need to distinguish nil and empty. See https://golang.org/pkg/encoding/json/#Marshal for more details.", + "namespaces": "namespaces specifies which namespaces the labelSelector applies to (matches against); null or empty list means \"this pod's namespace\"", "topologyKey": "This pod should be co-located (affinity) or not co-located (anti-affinity) with the pods matching the labelSelector in the specified namespaces, where co-located is defined as running on a node whose value of the label with key topologyKey matches that of any node on which any of the selected pods is running. For PreferredDuringScheduling pod anti-affinity, empty topologyKey is interpreted as \"all topologies\" (\"all topologies\" here means all the topologyKeys indicated by scheduler command-line argument --failure-domains); for affinity and for RequiredDuringScheduling pod anti-affinity, empty topologyKey is not allowed.", }