diff --git a/pkg/api/deep_copy_generated.go b/pkg/api/deep_copy_generated.go index bb6a4ce6fb6..5ab20e154c4 100644 --- a/pkg/api/deep_copy_generated.go +++ b/pkg/api/deep_copy_generated.go @@ -1306,15 +1306,6 @@ func DeepCopy_api_NodeAddress(in NodeAddress, out *NodeAddress, c *conversion.Cl } func DeepCopy_api_NodeAffinity(in NodeAffinity, out *NodeAffinity, c *conversion.Cloner) error { - if in.RequiredDuringSchedulingRequiredDuringExecution != nil { - in, out := in.RequiredDuringSchedulingRequiredDuringExecution, &out.RequiredDuringSchedulingRequiredDuringExecution - *out = new(NodeSelector) - if err := DeepCopy_api_NodeSelector(*in, *out, c); err != nil { - return err - } - } else { - out.RequiredDuringSchedulingRequiredDuringExecution = nil - } if in.RequiredDuringSchedulingIgnoredDuringExecution != nil { in, out := in.RequiredDuringSchedulingIgnoredDuringExecution, &out.RequiredDuringSchedulingIgnoredDuringExecution *out = new(NodeSelector) diff --git a/pkg/api/types.generated.go b/pkg/api/types.generated.go index 3d632b1a03f..c20c79fa621 100644 --- a/pkg/api/types.generated.go +++ b/pkg/api/types.generated.go @@ -22211,15 +22211,14 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [3]bool + var yyq2 [2]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false - yyq2[0] = x.RequiredDuringSchedulingRequiredDuringExecution != nil - yyq2[1] = x.RequiredDuringSchedulingIgnoredDuringExecution != nil - yyq2[2] = len(x.PreferredDuringSchedulingIgnoredDuringExecution) != 0 + yyq2[0] = x.RequiredDuringSchedulingIgnoredDuringExecution != nil + yyq2[1] = len(x.PreferredDuringSchedulingIgnoredDuringExecution) != 0 var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(3) + r.EncodeArrayStart(2) } else { yynn2 = 0 for _, b := range yyq2 { @@ -22233,29 +22232,6 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) if yyq2[0] { - if x.RequiredDuringSchedulingRequiredDuringExecution == nil { - r.EncodeNil() - } else { - x.RequiredDuringSchedulingRequiredDuringExecution.CodecEncodeSelf(e) - } - } else { - r.EncodeNil() - } - } else { - if yyq2[0] { - z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("requiredDuringSchedulingRequiredDuringExecution")) - z.EncSendContainerState(codecSelfer_containerMapValue1234) - if x.RequiredDuringSchedulingRequiredDuringExecution == nil { - r.EncodeNil() - } else { - x.RequiredDuringSchedulingRequiredDuringExecution.CodecEncodeSelf(e) - } - } - } - if yyr2 || yy2arr2 { - z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq2[1] { if x.RequiredDuringSchedulingIgnoredDuringExecution == nil { r.EncodeNil() } else { @@ -22265,7 +22241,7 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } } else { - if yyq2[1] { + if yyq2[0] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("requiredDuringSchedulingIgnoredDuringExecution")) z.EncSendContainerState(codecSelfer_containerMapValue1234) @@ -22278,12 +22254,12 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq2[2] { + if yyq2[1] { if x.PreferredDuringSchedulingIgnoredDuringExecution == nil { r.EncodeNil() } else { - yym10 := z.EncBinary() - _ = yym10 + yym7 := z.EncBinary() + _ = yym7 if false { } else { h.encSlicePreferredSchedulingTerm(([]PreferredSchedulingTerm)(x.PreferredDuringSchedulingIgnoredDuringExecution), e) @@ -22293,15 +22269,15 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } } else { - if yyq2[2] { + if yyq2[1] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("preferredDuringSchedulingIgnoredDuringExecution")) z.EncSendContainerState(codecSelfer_containerMapValue1234) if x.PreferredDuringSchedulingIgnoredDuringExecution == nil { r.EncodeNil() } else { - yym11 := z.EncBinary() - _ = yym11 + yym8 := z.EncBinary() + _ = yym8 if false { } else { h.encSlicePreferredSchedulingTerm(([]PreferredSchedulingTerm)(x.PreferredDuringSchedulingIgnoredDuringExecution), e) @@ -22370,17 +22346,6 @@ func (x *NodeAffinity) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { yys3 := string(yys3Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) switch yys3 { - case "requiredDuringSchedulingRequiredDuringExecution": - if r.TryDecodeAsNil() { - if x.RequiredDuringSchedulingRequiredDuringExecution != nil { - x.RequiredDuringSchedulingRequiredDuringExecution = nil - } - } else { - if x.RequiredDuringSchedulingRequiredDuringExecution == nil { - x.RequiredDuringSchedulingRequiredDuringExecution = new(NodeSelector) - } - x.RequiredDuringSchedulingRequiredDuringExecution.CodecDecodeSelf(d) - } case "requiredDuringSchedulingIgnoredDuringExecution": if r.TryDecodeAsNil() { if x.RequiredDuringSchedulingIgnoredDuringExecution != nil { @@ -22396,12 +22361,12 @@ func (x *NodeAffinity) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.PreferredDuringSchedulingIgnoredDuringExecution = nil } else { - yyv6 := &x.PreferredDuringSchedulingIgnoredDuringExecution - yym7 := z.DecBinary() - _ = yym7 + yyv5 := &x.PreferredDuringSchedulingIgnoredDuringExecution + yym6 := z.DecBinary() + _ = yym6 if false { } else { - h.decSlicePreferredSchedulingTerm((*[]PreferredSchedulingTerm)(yyv6), d) + h.decSlicePreferredSchedulingTerm((*[]PreferredSchedulingTerm)(yyv5), d) } } default: @@ -22415,37 +22380,16 @@ func (x *NodeAffinity) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj8 int - var yyb8 bool - var yyhl8 bool = l >= 0 - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + var yyj7 int + var yyb7 bool + var yyhl7 bool = l >= 0 + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb8 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb8 { - z.DecSendContainerState(codecSelfer_containerArrayEnd1234) - return - } - z.DecSendContainerState(codecSelfer_containerArrayElem1234) - if r.TryDecodeAsNil() { - if x.RequiredDuringSchedulingRequiredDuringExecution != nil { - x.RequiredDuringSchedulingRequiredDuringExecution = nil - } - } else { - if x.RequiredDuringSchedulingRequiredDuringExecution == nil { - x.RequiredDuringSchedulingRequiredDuringExecution = new(NodeSelector) - } - x.RequiredDuringSchedulingRequiredDuringExecution.CodecDecodeSelf(d) - } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = r.CheckBreak() - } - if yyb8 { + if yyb7 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -22460,13 +22404,13 @@ func (x *NodeAffinity) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.RequiredDuringSchedulingIgnoredDuringExecution.CodecDecodeSelf(d) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb8 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb8 { + if yyb7 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -22474,26 +22418,26 @@ func (x *NodeAffinity) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.PreferredDuringSchedulingIgnoredDuringExecution = nil } else { - yyv11 := &x.PreferredDuringSchedulingIgnoredDuringExecution - yym12 := z.DecBinary() - _ = yym12 + yyv9 := &x.PreferredDuringSchedulingIgnoredDuringExecution + yym10 := z.DecBinary() + _ = yym10 if false { } else { - h.decSlicePreferredSchedulingTerm((*[]PreferredSchedulingTerm)(yyv11), d) + h.decSlicePreferredSchedulingTerm((*[]PreferredSchedulingTerm)(yyv9), d) } } for { - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb8 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb8 { + if yyb7 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj8-1, "") + z.DecStructFieldNotFound(yyj7-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } diff --git a/pkg/api/types.go b/pkg/api/types.go index ab854971590..2de6d2418af 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -1113,23 +1113,23 @@ const ( NodeSelectorOpLt NodeSelectorOperator = "Lt" ) -// Affinity is a group of affinity scheduling requirements. +// Affinity is a group of affinity scheduling rules, currently +// only node affinity, but in the future also inter-pod affinity. type Affinity struct { - // Describes node affinity scheduling requirements for the pod. + // Describes node affinity scheduling rules for the pod. NodeAffinity *NodeAffinity `json:"nodeAffinity,omitempty"` } -// Node affinity is a group of node affinity scheduling requirements. -// If RequiredDuringSchedulingRequiredDuringExecution and -// RequiredDuringSchedulingIgnoredDuringExecution are both set, -// then both node selectors must be satisfied. +// Node affinity is a group of node affinity scheduling rules. type NodeAffinity struct { + // NOT YET IMPLEMENTED. TODO: Uncomment field once it is implemented. // If the affinity requirements specified by this field are not met at // scheduling time, the pod will not be scheduled onto the node. // If the affinity requirements specified by this field cease to be met // at some point during pod execution (e.g. due to an update), the system // will try to eventually evict the pod from its node. - RequiredDuringSchedulingRequiredDuringExecution *NodeSelector `json:"requiredDuringSchedulingRequiredDuringExecution,omitempty"` + // RequiredDuringSchedulingRequiredDuringExecution *NodeSelector `json:"requiredDuringSchedulingRequiredDuringExecution,omitempty"` + // If the affinity requirements specified by this field are not met at // scheduling time, the pod will not be scheduled onto the node. // If the affinity requirements specified by this field cease to be met diff --git a/pkg/api/v1/types.generated.go b/pkg/api/v1/types.generated.go index b1214958ef9..65ce7f20200 100644 --- a/pkg/api/v1/types.generated.go +++ b/pkg/api/v1/types.generated.go @@ -21484,15 +21484,14 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { } else { yysep2 := !z.EncBinary() yy2arr2 := z.EncBasicHandle().StructToArray - var yyq2 [3]bool + var yyq2 [2]bool _, _, _ = yysep2, yyq2, yy2arr2 const yyr2 bool = false - yyq2[0] = x.RequiredDuringSchedulingRequiredDuringExecution != nil - yyq2[1] = x.RequiredDuringSchedulingIgnoredDuringExecution != nil - yyq2[2] = len(x.PreferredDuringSchedulingIgnoredDuringExecution) != 0 + yyq2[0] = x.RequiredDuringSchedulingIgnoredDuringExecution != nil + yyq2[1] = len(x.PreferredDuringSchedulingIgnoredDuringExecution) != 0 var yynn2 int if yyr2 || yy2arr2 { - r.EncodeArrayStart(3) + r.EncodeArrayStart(2) } else { yynn2 = 0 for _, b := range yyq2 { @@ -21506,29 +21505,6 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) if yyq2[0] { - if x.RequiredDuringSchedulingRequiredDuringExecution == nil { - r.EncodeNil() - } else { - x.RequiredDuringSchedulingRequiredDuringExecution.CodecEncodeSelf(e) - } - } else { - r.EncodeNil() - } - } else { - if yyq2[0] { - z.EncSendContainerState(codecSelfer_containerMapKey1234) - r.EncodeString(codecSelferC_UTF81234, string("requiredDuringSchedulingRequiredDuringExecution")) - z.EncSendContainerState(codecSelfer_containerMapValue1234) - if x.RequiredDuringSchedulingRequiredDuringExecution == nil { - r.EncodeNil() - } else { - x.RequiredDuringSchedulingRequiredDuringExecution.CodecEncodeSelf(e) - } - } - } - if yyr2 || yy2arr2 { - z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq2[1] { if x.RequiredDuringSchedulingIgnoredDuringExecution == nil { r.EncodeNil() } else { @@ -21538,7 +21514,7 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } } else { - if yyq2[1] { + if yyq2[0] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("requiredDuringSchedulingIgnoredDuringExecution")) z.EncSendContainerState(codecSelfer_containerMapValue1234) @@ -21551,12 +21527,12 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { } if yyr2 || yy2arr2 { z.EncSendContainerState(codecSelfer_containerArrayElem1234) - if yyq2[2] { + if yyq2[1] { if x.PreferredDuringSchedulingIgnoredDuringExecution == nil { r.EncodeNil() } else { - yym10 := z.EncBinary() - _ = yym10 + yym7 := z.EncBinary() + _ = yym7 if false { } else { h.encSlicePreferredSchedulingTerm(([]PreferredSchedulingTerm)(x.PreferredDuringSchedulingIgnoredDuringExecution), e) @@ -21566,15 +21542,15 @@ func (x *NodeAffinity) CodecEncodeSelf(e *codec1978.Encoder) { r.EncodeNil() } } else { - if yyq2[2] { + if yyq2[1] { z.EncSendContainerState(codecSelfer_containerMapKey1234) r.EncodeString(codecSelferC_UTF81234, string("preferredDuringSchedulingIgnoredDuringExecution")) z.EncSendContainerState(codecSelfer_containerMapValue1234) if x.PreferredDuringSchedulingIgnoredDuringExecution == nil { r.EncodeNil() } else { - yym11 := z.EncBinary() - _ = yym11 + yym8 := z.EncBinary() + _ = yym8 if false { } else { h.encSlicePreferredSchedulingTerm(([]PreferredSchedulingTerm)(x.PreferredDuringSchedulingIgnoredDuringExecution), e) @@ -21643,17 +21619,6 @@ func (x *NodeAffinity) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { yys3 := string(yys3Slc) z.DecSendContainerState(codecSelfer_containerMapValue1234) switch yys3 { - case "requiredDuringSchedulingRequiredDuringExecution": - if r.TryDecodeAsNil() { - if x.RequiredDuringSchedulingRequiredDuringExecution != nil { - x.RequiredDuringSchedulingRequiredDuringExecution = nil - } - } else { - if x.RequiredDuringSchedulingRequiredDuringExecution == nil { - x.RequiredDuringSchedulingRequiredDuringExecution = new(NodeSelector) - } - x.RequiredDuringSchedulingRequiredDuringExecution.CodecDecodeSelf(d) - } case "requiredDuringSchedulingIgnoredDuringExecution": if r.TryDecodeAsNil() { if x.RequiredDuringSchedulingIgnoredDuringExecution != nil { @@ -21669,12 +21634,12 @@ func (x *NodeAffinity) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.PreferredDuringSchedulingIgnoredDuringExecution = nil } else { - yyv6 := &x.PreferredDuringSchedulingIgnoredDuringExecution - yym7 := z.DecBinary() - _ = yym7 + yyv5 := &x.PreferredDuringSchedulingIgnoredDuringExecution + yym6 := z.DecBinary() + _ = yym6 if false { } else { - h.decSlicePreferredSchedulingTerm((*[]PreferredSchedulingTerm)(yyv6), d) + h.decSlicePreferredSchedulingTerm((*[]PreferredSchedulingTerm)(yyv5), d) } } default: @@ -21688,37 +21653,16 @@ func (x *NodeAffinity) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { var h codecSelfer1234 z, r := codec1978.GenHelperDecoder(d) _, _, _ = h, z, r - var yyj8 int - var yyb8 bool - var yyhl8 bool = l >= 0 - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + var yyj7 int + var yyb7 bool + var yyhl7 bool = l >= 0 + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb8 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb8 { - z.DecSendContainerState(codecSelfer_containerArrayEnd1234) - return - } - z.DecSendContainerState(codecSelfer_containerArrayElem1234) - if r.TryDecodeAsNil() { - if x.RequiredDuringSchedulingRequiredDuringExecution != nil { - x.RequiredDuringSchedulingRequiredDuringExecution = nil - } - } else { - if x.RequiredDuringSchedulingRequiredDuringExecution == nil { - x.RequiredDuringSchedulingRequiredDuringExecution = new(NodeSelector) - } - x.RequiredDuringSchedulingRequiredDuringExecution.CodecDecodeSelf(d) - } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l - } else { - yyb8 = r.CheckBreak() - } - if yyb8 { + if yyb7 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -21733,13 +21677,13 @@ func (x *NodeAffinity) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { } x.RequiredDuringSchedulingIgnoredDuringExecution.CodecDecodeSelf(d) } - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb8 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb8 { + if yyb7 { z.DecSendContainerState(codecSelfer_containerArrayEnd1234) return } @@ -21747,26 +21691,26 @@ func (x *NodeAffinity) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) { if r.TryDecodeAsNil() { x.PreferredDuringSchedulingIgnoredDuringExecution = nil } else { - yyv11 := &x.PreferredDuringSchedulingIgnoredDuringExecution - yym12 := z.DecBinary() - _ = yym12 + yyv9 := &x.PreferredDuringSchedulingIgnoredDuringExecution + yym10 := z.DecBinary() + _ = yym10 if false { } else { - h.decSlicePreferredSchedulingTerm((*[]PreferredSchedulingTerm)(yyv11), d) + h.decSlicePreferredSchedulingTerm((*[]PreferredSchedulingTerm)(yyv9), d) } } for { - yyj8++ - if yyhl8 { - yyb8 = yyj8 > l + yyj7++ + if yyhl7 { + yyb7 = yyj7 > l } else { - yyb8 = r.CheckBreak() + yyb7 = r.CheckBreak() } - if yyb8 { + if yyb7 { break } z.DecSendContainerState(codecSelfer_containerArrayElem1234) - z.DecStructFieldNotFound(yyj8-1, "") + z.DecStructFieldNotFound(yyj7-1, "") } z.DecSendContainerState(codecSelfer_containerArrayEnd1234) } diff --git a/pkg/api/v1/types.go b/pkg/api/v1/types.go index c06eafcb670..63ad403c1f4 100644 --- a/pkg/api/v1/types.go +++ b/pkg/api/v1/types.go @@ -1349,24 +1349,23 @@ const ( NodeSelectorOpLt NodeSelectorOperator = "Lt" ) -// Affinity is a group of affinity scheduling requirements, -// including node affinity and inter pod affinity. +// Affinity is a group of affinity scheduling rules, currently +// only node affinity, but in the future also inter-pod affinity. type Affinity struct { - // Describes node affinity scheduling requirements for the pod. + // Describes node affinity scheduling rules for the pod. NodeAffinity *NodeAffinity `json:"nodeAffinity,omitempty"` } -// Node affinity is a group of node affinity scheduling requirements. -// If RequiredDuringSchedulingRequiredDuringExecution and -// RequiredDuringSchedulingIgnoredDuringExecution are both set, -// then both node selectors must be satisfied. +// Node affinity is a group of node affinity scheduling rules. type NodeAffinity struct { + // NOT YET IMPLEMENTED. TODO: Uncomment field once it is implemented. // If the affinity requirements specified by this field are not met at // scheduling time, the pod will not be scheduled onto the node. // If the affinity requirements specified by this field cease to be met // at some point during pod execution (e.g. due to an update), the system // will try to eventually evict the pod from its node. - RequiredDuringSchedulingRequiredDuringExecution *NodeSelector `json:"requiredDuringSchedulingRequiredDuringExecution,omitempty"` + // RequiredDuringSchedulingRequiredDuringExecution *NodeSelector `json:"requiredDuringSchedulingRequiredDuringExecution,omitempty"` + // If the affinity requirements specified by this field are not met at // scheduling time, the pod will not be scheduled onto the node. // If the affinity requirements specified by this field cease to be met diff --git a/pkg/api/v1/types_swagger_doc_generated.go b/pkg/api/v1/types_swagger_doc_generated.go index 192931f1254..25542397ee3 100644 --- a/pkg/api/v1/types_swagger_doc_generated.go +++ b/pkg/api/v1/types_swagger_doc_generated.go @@ -40,8 +40,8 @@ func (AWSElasticBlockStoreVolumeSource) SwaggerDoc() map[string]string { } var map_Affinity = map[string]string{ - "": "Affinity is a group of affinity scheduling requirements, including node affinity and inter pod affinity.", - "nodeAffinity": "Describes node affinity scheduling requirements for the pod.", + "": "Affinity is a group of affinity scheduling rules, currently only node affinity, but in the future also inter-pod affinity.", + "nodeAffinity": "Describes node affinity scheduling rules for the pod.", } func (Affinity) SwaggerDoc() map[string]string { @@ -752,8 +752,7 @@ func (NodeAddress) SwaggerDoc() map[string]string { } var map_NodeAffinity = map[string]string{ - "": "Node affinity is a group of node affinity scheduling requirements. If RequiredDuringSchedulingRequiredDuringExecution and RequiredDuringSchedulingIgnoredDuringExecution are both set, then both node selectors must be satisfied.", - "requiredDuringSchedulingRequiredDuringExecution": "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to an update), the system will try to eventually evict the pod from its node.", + "": "Node affinity is a group of node affinity scheduling rules.", "requiredDuringSchedulingIgnoredDuringExecution": "If the affinity requirements specified by this field are not met at scheduling time, the pod will not be scheduled onto the node. If the affinity requirements specified by this field cease to be met at some point during pod execution (e.g. due to an update), the system may or may not try to eventually evict the pod from its node.", "preferredDuringSchedulingIgnoredDuringExecution": "The scheduler will prefer to schedule pods to nodes that satisfy the affinity expressions specified by this field, but it may choose a node that violates one or more of the expressions. The node that is most preferred is the one with the greatest sum of weights, i.e. for each node that meets all of the scheduling requirements (resource request, requiredDuringScheduling affinity expressions, etc.), compute a sum by iterating through the elements of this field and adding \"weight\" to the sum if the node matches the corresponding matchExpressions; the node(s) with the highest sum are the most preferred.", } diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index ff38e7fa09c..937544b737f 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -1431,9 +1431,11 @@ func ValidateAffinityInPodAnnotations(annotations map[string]string, fldPath *fi if affinity.NodeAffinity != nil { na := affinity.NodeAffinity - if na.RequiredDuringSchedulingRequiredDuringExecution != nil { - allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingRequiredDuringExecution, fldPath.Child("requiredDuringSchedulingRequiredDuringExecution"))...) - } + + // TODO: Uncomment the next three lines once RequiredDuringSchedulingRequiredDuringExecution is implemented. + // if na.RequiredDuringSchedulingRequiredDuringExecution != nil { + // allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingRequiredDuringExecution, fldPath.Child("requiredDuringSchedulingRequiredDuringExecution"))...) + // } if na.RequiredDuringSchedulingIgnoredDuringExecution != nil { allErrs = append(allErrs, ValidateNodeSelector(na.RequiredDuringSchedulingIgnoredDuringExecution, fldPath.Child("requiredDuringSchedulingIgnoredDuringExecution"))...) diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 7094cbb7359..19a1b702838 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -1739,17 +1739,19 @@ func TestValidatePod(t *testing.T) { ObjectMeta: api.ObjectMeta{ Name: "123", Namespace: "ns", + // TODO: Uncomment and move this block into Annotations map once + // RequiredDuringSchedulingRequiredDuringExecution is implemented + // "requiredDuringSchedulingRequiredDuringExecution": { + // "nodeSelectorTerms": [{ + // "matchExpressions": [{ + // "key": "key1", + // "operator": "Exists" + // }] + // }] + // }, Annotations: map[string]string{ api.AffinityAnnotationKey: ` {"nodeAffinity": { - "requiredDuringSchedulingRequiredDuringExecution": { - "nodeSelectorTerms": [{ - "matchExpressions": [{ - "key": "key1", - "operator": "Exists" - }] - }] - }, "requiredDuringSchedulingIgnoredDuringExecution": { "nodeSelectorTerms": [{ "matchExpressions": [{ @@ -1830,7 +1832,7 @@ func TestValidatePod(t *testing.T) { Annotations: map[string]string{ api.AffinityAnnotationKey: ` {"nodeAffinity": { - "requiredDuringSchedulingRequiredDuringExecution": { + "requiredDuringSchedulingIgnoredDuringExecution": { "nodeSelectorTerms": [{ `, }, @@ -1847,7 +1849,7 @@ func TestValidatePod(t *testing.T) { Namespace: "ns", Annotations: map[string]string{ api.AffinityAnnotationKey: ` - {"nodeAffinity": {"requiredDuringSchedulingRequiredDuringExecution": { + {"nodeAffinity": {"requiredDuringSchedulingIgnoredDuringExecution": { "nodeSelectorTerms": [{ "matchExpressions": [{ "key": "key1", @@ -1888,14 +1890,14 @@ func TestValidatePod(t *testing.T) { DNSPolicy: api.DNSClusterFirst, }, }, - "invalid requiredDuringSchedulingRequiredDuringExecution node selector, nodeSelectorTerms must have at least one term": { + "invalid requiredDuringSchedulingIgnoredDuringExecution node selector, nodeSelectorTerms must have at least one term": { ObjectMeta: api.ObjectMeta{ Name: "123", Namespace: "ns", Annotations: map[string]string{ api.AffinityAnnotationKey: ` {"nodeAffinity": { - "requiredDuringSchedulingRequiredDuringExecution": { + "requiredDuringSchedulingIgnoredDuringExecution": { "nodeSelectorTerms": [] }, }}`, @@ -1907,14 +1909,14 @@ func TestValidatePod(t *testing.T) { DNSPolicy: api.DNSClusterFirst, }, }, - "invalid requiredDuringSchedulingRequiredDuringExecution node selector term, matchExpressions must have at least one node selector requirement": { + "invalid requiredDuringSchedulingIgnoredDuringExecution node selector term, matchExpressions must have at least one node selector requirement": { ObjectMeta: api.ObjectMeta{ Name: "123", Namespace: "ns", Annotations: map[string]string{ api.AffinityAnnotationKey: ` {"nodeAffinity": { - "requiredDuringSchedulingRequiredDuringExecution": { + "requiredDuringSchedulingIgnoredDuringExecution": { "nodeSelectorTerms": [{ "matchExpressions": [] }] diff --git a/plugin/pkg/scheduler/algorithm/predicates/predicates.go b/plugin/pkg/scheduler/algorithm/predicates/predicates.go index c0d52815208..cbf99341837 100644 --- a/plugin/pkg/scheduler/algorithm/predicates/predicates.go +++ b/plugin/pkg/scheduler/algorithm/predicates/predicates.go @@ -513,18 +513,21 @@ func PodMatchesNodeLabels(pod *api.Pod, node *api.Node) bool { if affinity.NodeAffinity != nil { nodeAffinity := affinity.NodeAffinity // if no required NodeAffinity requirements, will do no-op, means select all nodes. - if nodeAffinity.RequiredDuringSchedulingRequiredDuringExecution == nil && nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution == nil { + // TODO: Replace next line with subsequent commented-out line when implement RequiredDuringSchedulingRequiredDuringExecution. + if nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution == nil { + // if nodeAffinity.RequiredDuringSchedulingRequiredDuringExecution == nil && nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution == nil { return true } // Match node selector for requiredDuringSchedulingRequiredDuringExecution. - if nodeAffinity.RequiredDuringSchedulingRequiredDuringExecution != nil { - nodeSelectorTerms := nodeAffinity.RequiredDuringSchedulingRequiredDuringExecution.NodeSelectorTerms - glog.V(10).Infof("Match for RequiredDuringSchedulingRequiredDuringExecution node selector terms %+v", nodeSelectorTerms) - nodeAffinityMatches = NodeMatchesNodeSelectorTerms(node, nodeSelectorTerms) - } + // TODO: Uncomment this block when implement RequiredDuringSchedulingRequiredDuringExecution. + // if nodeAffinity.RequiredDuringSchedulingRequiredDuringExecution != nil { + // nodeSelectorTerms := nodeAffinity.RequiredDuringSchedulingRequiredDuringExecution.NodeSelectorTerms + // glog.V(10).Infof("Match for RequiredDuringSchedulingRequiredDuringExecution node selector terms %+v", nodeSelectorTerms) + // nodeAffinityMatches = NodeMatchesNodeSelectorTerms(node, nodeSelectorTerms) + // } - // Match node selector for requiredDuringSchedulingRequiredDuringExecution. + // Match node selector for requiredDuringSchedulingIgnoredDuringExecution. if nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution != nil { nodeSelectorTerms := nodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms glog.V(10).Infof("Match for RequiredDuringSchedulingIgnoredDuringExecution node selector terms %+v", nodeSelectorTerms) diff --git a/plugin/pkg/scheduler/algorithm/predicates/predicates_test.go b/plugin/pkg/scheduler/algorithm/predicates/predicates_test.go index 4ac7191f873..4126eafe998 100644 --- a/plugin/pkg/scheduler/algorithm/predicates/predicates_test.go +++ b/plugin/pkg/scheduler/algorithm/predicates/predicates_test.go @@ -881,41 +881,42 @@ func TestPodFitsSelector(t *testing.T) { fits: true, test: "Pod with multiple NodeSelectorTerms ORed in affinity, matches the node's labels and will schedule onto the node", }, - { - pod: &api.Pod{ - ObjectMeta: api.ObjectMeta{ - Annotations: map[string]string{ - api.AffinityAnnotationKey: ` - {"nodeAffinity": { - "requiredDuringSchedulingRequiredDuringExecution": { - "nodeSelectorTerms": [{ - "matchExpressions": [{ - "key": "foo", - "operator": "In", - "values": ["bar", "value2"] - }] - }] - }, - "requiredDuringSchedulingIgnoredDuringExecution": { - "nodeSelectorTerms": [{ - "matchExpressions": [{ - "key": "foo", - "operator": "NotIn", - "values": ["bar", "value2"] - }] - }] - } - }}`, - }, - }, - }, - labels: map[string]string{ - "foo": "bar", - }, - fits: false, - test: "Pod with an Affinity both requiredDuringSchedulingRequiredDuringExecution and " + - "requiredDuringSchedulingIgnoredDuringExecution indicated that don't match node's labels and won't schedule onto the node", - }, + // TODO: Uncomment this test when implement RequiredDuringSchedulingRequiredDuringExecution + // { + // pod: &api.Pod{ + // ObjectMeta: api.ObjectMeta{ + // Annotations: map[string]string{ + // api.AffinityAnnotationKey: ` + // {"nodeAffinity": { + // "requiredDuringSchedulingRequiredDuringExecution": { + // "nodeSelectorTerms": [{ + // "matchExpressions": [{ + // "key": "foo", + // "operator": "In", + // "values": ["bar", "value2"] + // }] + // }] + // }, + // "requiredDuringSchedulingIgnoredDuringExecution": { + // "nodeSelectorTerms": [{ + // "matchExpressions": [{ + // "key": "foo", + // "operator": "NotIn", + // "values": ["bar", "value2"] + // }] + // }] + // } + // }}`, + // }, + // }, + // }, + // labels: map[string]string{ + // "foo": "bar", + // }, + // fits: false, + // test: "Pod with an Affinity both requiredDuringSchedulingRequiredDuringExecution and " + + // "requiredDuringSchedulingIgnoredDuringExecution indicated that don't match node's labels and won't schedule onto the node", + // }, { pod: &api.Pod{ ObjectMeta: api.ObjectMeta{ diff --git a/test/e2e/scheduler_predicates.go b/test/e2e/scheduler_predicates.go index 607b5125b69..cf824655f0c 100644 --- a/test/e2e/scheduler_predicates.go +++ b/test/e2e/scheduler_predicates.go @@ -419,7 +419,7 @@ var _ = Describe("SchedulerPredicates [Serial]", func() { Annotations: map[string]string{ api.AffinityAnnotationKey: ` {"nodeAffinity": { - "requiredDuringSchedulingRequiredDuringExecution": { + "requiredDuringSchedulingIgnoredDuringExecution": { "nodeSelectorTerms": [{ "matchExpressions": [] }]