mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-28 06:29:29 +01:00
Merge pull request #33 from aveshagarwal/master-node-selector
Implement node selectors to retrieve node list based on provided query.
This commit is contained in:
@@ -53,4 +53,6 @@ func (rs *DeschedulerServer) AddFlags(fs *pflag.FlagSet) {
|
|||||||
fs.StringVar(&rs.KubeconfigFile, "kubeconfig-file", rs.KubeconfigFile, "File with kube configuration.")
|
fs.StringVar(&rs.KubeconfigFile, "kubeconfig-file", rs.KubeconfigFile, "File with kube configuration.")
|
||||||
fs.StringVar(&rs.PolicyConfigFile, "policy-config-file", rs.PolicyConfigFile, "File with descheduler policy configuration.")
|
fs.StringVar(&rs.PolicyConfigFile, "policy-config-file", rs.PolicyConfigFile, "File with descheduler policy configuration.")
|
||||||
fs.BoolVar(&rs.DryRun, "dry-run", rs.DryRun, "execute descheduler in dry run mode.")
|
fs.BoolVar(&rs.DryRun, "dry-run", rs.DryRun, "execute descheduler in dry run mode.")
|
||||||
|
// node-selector query causes descheduler to run only on nodes that matches the node labels in the query
|
||||||
|
fs.StringVar(&rs.NodeSelector, "node-selector", rs.NodeSelector, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,16 +81,16 @@ func (x *DeschedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||||||
} else {
|
} else {
|
||||||
yysep2 := !z.EncBinary()
|
yysep2 := !z.EncBinary()
|
||||||
yy2arr2 := z.EncBasicHandle().StructToArray
|
yy2arr2 := z.EncBasicHandle().StructToArray
|
||||||
var yyq2 [6]bool
|
var yyq2 [7]bool
|
||||||
_, _, _ = yysep2, yyq2, yy2arr2
|
_, _, _ = yysep2, yyq2, yy2arr2
|
||||||
const yyr2 bool = false
|
const yyr2 bool = false
|
||||||
yyq2[0] = x.Kind != ""
|
yyq2[0] = x.Kind != ""
|
||||||
yyq2[1] = x.APIVersion != ""
|
yyq2[1] = x.APIVersion != ""
|
||||||
var yynn2 int
|
var yynn2 int
|
||||||
if yyr2 || yy2arr2 {
|
if yyr2 || yy2arr2 {
|
||||||
r.EncodeArrayStart(6)
|
r.EncodeArrayStart(7)
|
||||||
} else {
|
} else {
|
||||||
yynn2 = 4
|
yynn2 = 5
|
||||||
for _, b := range yyq2 {
|
for _, b := range yyq2 {
|
||||||
if b {
|
if b {
|
||||||
yynn2++
|
yynn2++
|
||||||
@@ -227,6 +227,25 @@ func (x *DeschedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||||||
r.EncodeBool(bool(x.DryRun))
|
r.EncodeBool(bool(x.DryRun))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if yyr2 || yy2arr2 {
|
||||||
|
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
|
yym22 := z.EncBinary()
|
||||||
|
_ = yym22
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
r.EncodeString(codecSelferC_UTF81234, string(x.NodeSelector))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
z.EncSendContainerState(codecSelfer_containerMapKey1234)
|
||||||
|
r.EncodeString(codecSelferC_UTF81234, string("NodeSelector"))
|
||||||
|
z.EncSendContainerState(codecSelfer_containerMapValue1234)
|
||||||
|
yym23 := z.EncBinary()
|
||||||
|
_ = yym23
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
r.EncodeString(codecSelferC_UTF81234, string(x.NodeSelector))
|
||||||
|
}
|
||||||
|
}
|
||||||
if yyr2 || yy2arr2 {
|
if yyr2 || yy2arr2 {
|
||||||
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
} else {
|
} else {
|
||||||
@@ -361,6 +380,18 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.De
|
|||||||
*((*bool)(yyv14)) = r.DecodeBool()
|
*((*bool)(yyv14)) = r.DecodeBool()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "NodeSelector":
|
||||||
|
if r.TryDecodeAsNil() {
|
||||||
|
x.NodeSelector = ""
|
||||||
|
} else {
|
||||||
|
yyv16 := &x.NodeSelector
|
||||||
|
yym17 := z.DecBinary()
|
||||||
|
_ = yym17
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
*((*string)(yyv16)) = r.DecodeString()
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
z.DecStructFieldNotFound(-1, yys3)
|
z.DecStructFieldNotFound(-1, yys3)
|
||||||
} // end switch yys3
|
} // end switch yys3
|
||||||
@@ -372,16 +403,16 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
var yyj16 int
|
var yyj18 int
|
||||||
var yyb16 bool
|
var yyb18 bool
|
||||||
var yyhl16 bool = l >= 0
|
var yyhl18 bool = l >= 0
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -389,29 +420,7 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.Kind = ""
|
x.Kind = ""
|
||||||
} else {
|
} else {
|
||||||
yyv17 := &x.Kind
|
yyv19 := &x.Kind
|
||||||
yym18 := z.DecBinary()
|
|
||||||
_ = yym18
|
|
||||||
if false {
|
|
||||||
} else {
|
|
||||||
*((*string)(yyv17)) = r.DecodeString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yyj16++
|
|
||||||
if yyhl16 {
|
|
||||||
yyb16 = yyj16 > l
|
|
||||||
} else {
|
|
||||||
yyb16 = r.CheckBreak()
|
|
||||||
}
|
|
||||||
if yyb16 {
|
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
|
||||||
if r.TryDecodeAsNil() {
|
|
||||||
x.APIVersion = ""
|
|
||||||
} else {
|
|
||||||
yyv19 := &x.APIVersion
|
|
||||||
yym20 := z.DecBinary()
|
yym20 := z.DecBinary()
|
||||||
_ = yym20
|
_ = yym20
|
||||||
if false {
|
if false {
|
||||||
@@ -419,13 +428,35 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
*((*string)(yyv19)) = r.DecodeString()
|
*((*string)(yyv19)) = r.DecodeString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
|
if r.TryDecodeAsNil() {
|
||||||
|
x.APIVersion = ""
|
||||||
|
} else {
|
||||||
|
yyv21 := &x.APIVersion
|
||||||
|
yym22 := z.DecBinary()
|
||||||
|
_ = yym22
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
*((*string)(yyv21)) = r.DecodeString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yyj18++
|
||||||
|
if yyhl18 {
|
||||||
|
yyb18 = yyj18 > l
|
||||||
|
} else {
|
||||||
|
yyb18 = r.CheckBreak()
|
||||||
|
}
|
||||||
|
if yyb18 {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -433,22 +464,22 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.DeschedulingInterval = 0
|
x.DeschedulingInterval = 0
|
||||||
} else {
|
} else {
|
||||||
yyv21 := &x.DeschedulingInterval
|
yyv23 := &x.DeschedulingInterval
|
||||||
yym22 := z.DecBinary()
|
yym24 := z.DecBinary()
|
||||||
_ = yym22
|
_ = yym24
|
||||||
if false {
|
if false {
|
||||||
} else if z.HasExtensions() && z.DecExt(yyv21) {
|
} else if z.HasExtensions() && z.DecExt(yyv23) {
|
||||||
} else {
|
} else {
|
||||||
*((*int64)(yyv21)) = int64(r.DecodeInt(64))
|
*((*int64)(yyv23)) = int64(r.DecodeInt(64))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -456,29 +487,7 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.KubeconfigFile = ""
|
x.KubeconfigFile = ""
|
||||||
} else {
|
} else {
|
||||||
yyv23 := &x.KubeconfigFile
|
yyv25 := &x.KubeconfigFile
|
||||||
yym24 := z.DecBinary()
|
|
||||||
_ = yym24
|
|
||||||
if false {
|
|
||||||
} else {
|
|
||||||
*((*string)(yyv23)) = r.DecodeString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yyj16++
|
|
||||||
if yyhl16 {
|
|
||||||
yyb16 = yyj16 > l
|
|
||||||
} else {
|
|
||||||
yyb16 = r.CheckBreak()
|
|
||||||
}
|
|
||||||
if yyb16 {
|
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
|
||||||
if r.TryDecodeAsNil() {
|
|
||||||
x.PolicyConfigFile = ""
|
|
||||||
} else {
|
|
||||||
yyv25 := &x.PolicyConfigFile
|
|
||||||
yym26 := z.DecBinary()
|
yym26 := z.DecBinary()
|
||||||
_ = yym26
|
_ = yym26
|
||||||
if false {
|
if false {
|
||||||
@@ -486,13 +495,35 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
*((*string)(yyv25)) = r.DecodeString()
|
*((*string)(yyv25)) = r.DecodeString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
|
if r.TryDecodeAsNil() {
|
||||||
|
x.PolicyConfigFile = ""
|
||||||
|
} else {
|
||||||
|
yyv27 := &x.PolicyConfigFile
|
||||||
|
yym28 := z.DecBinary()
|
||||||
|
_ = yym28
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
*((*string)(yyv27)) = r.DecodeString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yyj18++
|
||||||
|
if yyhl18 {
|
||||||
|
yyb18 = yyj18 > l
|
||||||
|
} else {
|
||||||
|
yyb18 = r.CheckBreak()
|
||||||
|
}
|
||||||
|
if yyb18 {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -500,26 +531,48 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.DryRun = false
|
x.DryRun = false
|
||||||
} else {
|
} else {
|
||||||
yyv27 := &x.DryRun
|
yyv29 := &x.DryRun
|
||||||
yym28 := z.DecBinary()
|
yym30 := z.DecBinary()
|
||||||
_ = yym28
|
_ = yym30
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
*((*bool)(yyv27)) = r.DecodeBool()
|
*((*bool)(yyv29)) = r.DecodeBool()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yyj18++
|
||||||
|
if yyhl18 {
|
||||||
|
yyb18 = yyj18 > l
|
||||||
|
} else {
|
||||||
|
yyb18 = r.CheckBreak()
|
||||||
|
}
|
||||||
|
if yyb18 {
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
|
if r.TryDecodeAsNil() {
|
||||||
|
x.NodeSelector = ""
|
||||||
|
} else {
|
||||||
|
yyv31 := &x.NodeSelector
|
||||||
|
yym32 := z.DecBinary()
|
||||||
|
_ = yym32
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
*((*string)(yyv31)) = r.DecodeString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
z.DecStructFieldNotFound(yyj16-1, "")
|
z.DecStructFieldNotFound(yyj18-1, "")
|
||||||
}
|
}
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,7 @@ type DeschedulerConfiguration struct {
|
|||||||
|
|
||||||
// Dry run
|
// Dry run
|
||||||
DryRun bool
|
DryRun bool
|
||||||
|
|
||||||
|
// Node selectors
|
||||||
|
NodeSelector string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ func (x *DeschedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||||||
} else {
|
} else {
|
||||||
yysep2 := !z.EncBinary()
|
yysep2 := !z.EncBinary()
|
||||||
yy2arr2 := z.EncBasicHandle().StructToArray
|
yy2arr2 := z.EncBasicHandle().StructToArray
|
||||||
var yyq2 [6]bool
|
var yyq2 [7]bool
|
||||||
_, _, _ = yysep2, yyq2, yy2arr2
|
_, _, _ = yysep2, yyq2, yy2arr2
|
||||||
const yyr2 bool = false
|
const yyr2 bool = false
|
||||||
yyq2[0] = x.Kind != ""
|
yyq2[0] = x.Kind != ""
|
||||||
@@ -89,9 +89,10 @@ func (x *DeschedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||||||
yyq2[2] = x.DeschedulingInterval != 0
|
yyq2[2] = x.DeschedulingInterval != 0
|
||||||
yyq2[4] = x.PolicyConfigFile != ""
|
yyq2[4] = x.PolicyConfigFile != ""
|
||||||
yyq2[5] = x.DryRun != false
|
yyq2[5] = x.DryRun != false
|
||||||
|
yyq2[6] = x.NodeSelector != ""
|
||||||
var yynn2 int
|
var yynn2 int
|
||||||
if yyr2 || yy2arr2 {
|
if yyr2 || yy2arr2 {
|
||||||
r.EncodeArrayStart(6)
|
r.EncodeArrayStart(7)
|
||||||
} else {
|
} else {
|
||||||
yynn2 = 1
|
yynn2 = 1
|
||||||
for _, b := range yyq2 {
|
for _, b := range yyq2 {
|
||||||
@@ -248,6 +249,31 @@ func (x *DeschedulerConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if yyr2 || yy2arr2 {
|
||||||
|
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
|
if yyq2[6] {
|
||||||
|
yym22 := z.EncBinary()
|
||||||
|
_ = yym22
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
r.EncodeString(codecSelferC_UTF81234, string(x.NodeSelector))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
r.EncodeString(codecSelferC_UTF81234, "")
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if yyq2[6] {
|
||||||
|
z.EncSendContainerState(codecSelfer_containerMapKey1234)
|
||||||
|
r.EncodeString(codecSelferC_UTF81234, string("nodeSelector"))
|
||||||
|
z.EncSendContainerState(codecSelfer_containerMapValue1234)
|
||||||
|
yym23 := z.EncBinary()
|
||||||
|
_ = yym23
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
r.EncodeString(codecSelferC_UTF81234, string(x.NodeSelector))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if yyr2 || yy2arr2 {
|
if yyr2 || yy2arr2 {
|
||||||
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.EncSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
} else {
|
} else {
|
||||||
@@ -382,6 +408,18 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.De
|
|||||||
*((*bool)(yyv14)) = r.DecodeBool()
|
*((*bool)(yyv14)) = r.DecodeBool()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "nodeSelector":
|
||||||
|
if r.TryDecodeAsNil() {
|
||||||
|
x.NodeSelector = ""
|
||||||
|
} else {
|
||||||
|
yyv16 := &x.NodeSelector
|
||||||
|
yym17 := z.DecBinary()
|
||||||
|
_ = yym17
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
*((*string)(yyv16)) = r.DecodeString()
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
z.DecStructFieldNotFound(-1, yys3)
|
z.DecStructFieldNotFound(-1, yys3)
|
||||||
} // end switch yys3
|
} // end switch yys3
|
||||||
@@ -393,16 +431,16 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
var h codecSelfer1234
|
var h codecSelfer1234
|
||||||
z, r := codec1978.GenHelperDecoder(d)
|
z, r := codec1978.GenHelperDecoder(d)
|
||||||
_, _, _ = h, z, r
|
_, _, _ = h, z, r
|
||||||
var yyj16 int
|
var yyj18 int
|
||||||
var yyb16 bool
|
var yyb18 bool
|
||||||
var yyhl16 bool = l >= 0
|
var yyhl18 bool = l >= 0
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -410,29 +448,7 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.Kind = ""
|
x.Kind = ""
|
||||||
} else {
|
} else {
|
||||||
yyv17 := &x.Kind
|
yyv19 := &x.Kind
|
||||||
yym18 := z.DecBinary()
|
|
||||||
_ = yym18
|
|
||||||
if false {
|
|
||||||
} else {
|
|
||||||
*((*string)(yyv17)) = r.DecodeString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yyj16++
|
|
||||||
if yyhl16 {
|
|
||||||
yyb16 = yyj16 > l
|
|
||||||
} else {
|
|
||||||
yyb16 = r.CheckBreak()
|
|
||||||
}
|
|
||||||
if yyb16 {
|
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
|
||||||
if r.TryDecodeAsNil() {
|
|
||||||
x.APIVersion = ""
|
|
||||||
} else {
|
|
||||||
yyv19 := &x.APIVersion
|
|
||||||
yym20 := z.DecBinary()
|
yym20 := z.DecBinary()
|
||||||
_ = yym20
|
_ = yym20
|
||||||
if false {
|
if false {
|
||||||
@@ -440,13 +456,35 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
*((*string)(yyv19)) = r.DecodeString()
|
*((*string)(yyv19)) = r.DecodeString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
|
if r.TryDecodeAsNil() {
|
||||||
|
x.APIVersion = ""
|
||||||
|
} else {
|
||||||
|
yyv21 := &x.APIVersion
|
||||||
|
yym22 := z.DecBinary()
|
||||||
|
_ = yym22
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
*((*string)(yyv21)) = r.DecodeString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yyj18++
|
||||||
|
if yyhl18 {
|
||||||
|
yyb18 = yyj18 > l
|
||||||
|
} else {
|
||||||
|
yyb18 = r.CheckBreak()
|
||||||
|
}
|
||||||
|
if yyb18 {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -454,22 +492,22 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.DeschedulingInterval = 0
|
x.DeschedulingInterval = 0
|
||||||
} else {
|
} else {
|
||||||
yyv21 := &x.DeschedulingInterval
|
yyv23 := &x.DeschedulingInterval
|
||||||
yym22 := z.DecBinary()
|
yym24 := z.DecBinary()
|
||||||
_ = yym22
|
_ = yym24
|
||||||
if false {
|
if false {
|
||||||
} else if z.HasExtensions() && z.DecExt(yyv21) {
|
} else if z.HasExtensions() && z.DecExt(yyv23) {
|
||||||
} else {
|
} else {
|
||||||
*((*int64)(yyv21)) = int64(r.DecodeInt(64))
|
*((*int64)(yyv23)) = int64(r.DecodeInt(64))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -477,29 +515,7 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.KubeconfigFile = ""
|
x.KubeconfigFile = ""
|
||||||
} else {
|
} else {
|
||||||
yyv23 := &x.KubeconfigFile
|
yyv25 := &x.KubeconfigFile
|
||||||
yym24 := z.DecBinary()
|
|
||||||
_ = yym24
|
|
||||||
if false {
|
|
||||||
} else {
|
|
||||||
*((*string)(yyv23)) = r.DecodeString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
yyj16++
|
|
||||||
if yyhl16 {
|
|
||||||
yyb16 = yyj16 > l
|
|
||||||
} else {
|
|
||||||
yyb16 = r.CheckBreak()
|
|
||||||
}
|
|
||||||
if yyb16 {
|
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
|
||||||
if r.TryDecodeAsNil() {
|
|
||||||
x.PolicyConfigFile = ""
|
|
||||||
} else {
|
|
||||||
yyv25 := &x.PolicyConfigFile
|
|
||||||
yym26 := z.DecBinary()
|
yym26 := z.DecBinary()
|
||||||
_ = yym26
|
_ = yym26
|
||||||
if false {
|
if false {
|
||||||
@@ -507,13 +523,35 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
*((*string)(yyv25)) = r.DecodeString()
|
*((*string)(yyv25)) = r.DecodeString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
|
if r.TryDecodeAsNil() {
|
||||||
|
x.PolicyConfigFile = ""
|
||||||
|
} else {
|
||||||
|
yyv27 := &x.PolicyConfigFile
|
||||||
|
yym28 := z.DecBinary()
|
||||||
|
_ = yym28
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
*((*string)(yyv27)) = r.DecodeString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yyj18++
|
||||||
|
if yyhl18 {
|
||||||
|
yyb18 = yyj18 > l
|
||||||
|
} else {
|
||||||
|
yyb18 = r.CheckBreak()
|
||||||
|
}
|
||||||
|
if yyb18 {
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -521,26 +559,48 @@ func (x *DeschedulerConfiguration) codecDecodeSelfFromArray(l int, d *codec1978.
|
|||||||
if r.TryDecodeAsNil() {
|
if r.TryDecodeAsNil() {
|
||||||
x.DryRun = false
|
x.DryRun = false
|
||||||
} else {
|
} else {
|
||||||
yyv27 := &x.DryRun
|
yyv29 := &x.DryRun
|
||||||
yym28 := z.DecBinary()
|
yym30 := z.DecBinary()
|
||||||
_ = yym28
|
_ = yym30
|
||||||
if false {
|
if false {
|
||||||
} else {
|
} else {
|
||||||
*((*bool)(yyv27)) = r.DecodeBool()
|
*((*bool)(yyv29)) = r.DecodeBool()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yyj18++
|
||||||
|
if yyhl18 {
|
||||||
|
yyb18 = yyj18 > l
|
||||||
|
} else {
|
||||||
|
yyb18 = r.CheckBreak()
|
||||||
|
}
|
||||||
|
if yyb18 {
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
|
if r.TryDecodeAsNil() {
|
||||||
|
x.NodeSelector = ""
|
||||||
|
} else {
|
||||||
|
yyv31 := &x.NodeSelector
|
||||||
|
yym32 := z.DecBinary()
|
||||||
|
_ = yym32
|
||||||
|
if false {
|
||||||
|
} else {
|
||||||
|
*((*string)(yyv31)) = r.DecodeString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
yyj16++
|
yyj18++
|
||||||
if yyhl16 {
|
if yyhl18 {
|
||||||
yyb16 = yyj16 > l
|
yyb18 = yyj18 > l
|
||||||
} else {
|
} else {
|
||||||
yyb16 = r.CheckBreak()
|
yyb18 = r.CheckBreak()
|
||||||
}
|
}
|
||||||
if yyb16 {
|
if yyb18 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
|
||||||
z.DecStructFieldNotFound(yyj16-1, "")
|
z.DecStructFieldNotFound(yyj18-1, "")
|
||||||
}
|
}
|
||||||
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
z.DecSendContainerState(codecSelfer_containerArrayEnd1234)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,4 +37,7 @@ type DeschedulerConfiguration struct {
|
|||||||
|
|
||||||
// Dry run
|
// Dry run
|
||||||
DryRun bool `json:"dryRun,omitempty"`
|
DryRun bool `json:"dryRun,omitempty"`
|
||||||
|
|
||||||
|
// Node selectors
|
||||||
|
NodeSelector string `json:"nodeSelector,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ func autoConvert_v1alpha1_DeschedulerConfiguration_To_componentconfig_Deschedule
|
|||||||
out.KubeconfigFile = in.KubeconfigFile
|
out.KubeconfigFile = in.KubeconfigFile
|
||||||
out.PolicyConfigFile = in.PolicyConfigFile
|
out.PolicyConfigFile = in.PolicyConfigFile
|
||||||
out.DryRun = in.DryRun
|
out.DryRun = in.DryRun
|
||||||
|
out.NodeSelector = in.NodeSelector
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,6 +59,7 @@ func autoConvert_componentconfig_DeschedulerConfiguration_To_v1alpha1_Deschedule
|
|||||||
out.KubeconfigFile = in.KubeconfigFile
|
out.KubeconfigFile = in.KubeconfigFile
|
||||||
out.PolicyConfigFile = in.PolicyConfigFile
|
out.PolicyConfigFile = in.PolicyConfigFile
|
||||||
out.DryRun = in.DryRun
|
out.DryRun = in.DryRun
|
||||||
|
out.NodeSelector = in.NodeSelector
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ func Run(rs *options.DeschedulerServer) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopChannel := make(chan struct{})
|
stopChannel := make(chan struct{})
|
||||||
nodes, err := nodeutil.ReadyNodes(rs.Client, stopChannel)
|
nodes, err := nodeutil.ReadyNodes(rs.Client, rs.NodeSelector, stopChannel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,16 +31,23 @@ import (
|
|||||||
|
|
||||||
// ReadyNodes returns ready nodes irrespective of whether they are
|
// ReadyNodes returns ready nodes irrespective of whether they are
|
||||||
// schedulable or not.
|
// schedulable or not.
|
||||||
func ReadyNodes(client clientset.Interface, stopChannel <-chan struct{}) ([]*v1.Node, error) {
|
func ReadyNodes(client clientset.Interface, nodeSelector string, stopChannel <-chan struct{}) ([]*v1.Node, error) {
|
||||||
nl := GetNodeLister(client, stopChannel)
|
nl := GetNodeLister(client, stopChannel)
|
||||||
nodes, err := nl.List(labels.Everything())
|
|
||||||
|
ns, err := labels.Parse(nodeSelector)
|
||||||
|
if err != nil {
|
||||||
|
return []*v1.Node{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
nodes, err := nl.List(ns)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []*v1.Node{}, err
|
return []*v1.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
var err error
|
var err error
|
||||||
nItems, err := client.Core().Nodes().List(metav1.ListOptions{})
|
nItems, err := client.Core().Nodes().List(metav1.ListOptions{LabelSelector: nodeSelector})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []*v1.Node{}, err
|
return []*v1.Node{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,3 +80,20 @@ func TestReadyNodes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReadyNodesWithNodeSelector(t *testing.T) {
|
||||||
|
node1 := test.BuildTestNode("node1", 1000, 2000, 9)
|
||||||
|
node1.Labels = map[string]string{"type": "compute"}
|
||||||
|
node2 := test.BuildTestNode("node2", 1000, 2000, 9)
|
||||||
|
node2.Labels = map[string]string{"type": "infra"}
|
||||||
|
|
||||||
|
fakeClient := fake.NewSimpleClientset(node1, node2)
|
||||||
|
|
||||||
|
nodeSelector := "type=compute"
|
||||||
|
stopChannel := make(chan struct{})
|
||||||
|
nodes, _ := ReadyNodes(fakeClient, nodeSelector, stopChannel)
|
||||||
|
|
||||||
|
if nodes[0].Name != "node1" {
|
||||||
|
t.Errorf("Expected node1, got %s", nodes[0].Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user