Skip to content

Commit

Permalink
Merge pull request #225 from ffromani/sched-config-render-unstruct
Browse files Browse the repository at this point in the history
scheduler: update: use unstructured in RenderConfig
  • Loading branch information
ffromani authored Oct 23, 2023
2 parents 647ac54 + bb37528 commit 0199c84
Show file tree
Hide file tree
Showing 113 changed files with 916 additions and 17,853 deletions.
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@ require (
k8s.io/apimachinery v0.27.3
k8s.io/client-go v0.27.3
k8s.io/klog/v2 v2.100.1
k8s.io/kube-scheduler v0.26.4
k8s.io/kubelet v0.27.3
k8s.io/kubernetes v1.26.4
k8s.io/utils v0.0.0-20230505201702-9f6742963106
sigs.k8s.io/controller-runtime v0.13.1
sigs.k8s.io/scheduler-plugins v0.25.7
sigs.k8s.io/yaml v1.3.0
)

Expand Down Expand Up @@ -79,7 +76,6 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.27.3 // indirect
k8s.io/component-base v0.27.3 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
19 changes: 0 additions & 19 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/diktyo-io/appgroup-api v1.0.1-alpha h1:XIl7FrBtkGO9QVLQ61xMu7gbtP1DYMdMdS51ntQiN1k=
github.com/diktyo-io/networktopology-api v1.0.1-alpha h1:yAgUu+h2sSC25Gbv52hsZD453pyDiRhbLUQRIWsmFNI=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful/v3 v3.8.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Expand All @@ -93,7 +91,6 @@ github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH
github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJCLunww=
github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4=
github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
Expand Down Expand Up @@ -140,7 +137,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
Expand Down Expand Up @@ -221,7 +217,6 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
Expand Down Expand Up @@ -270,7 +265,6 @@ github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8m
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
Expand Down Expand Up @@ -302,8 +296,6 @@ github.com/openshift/client-go v0.0.0-20230607134213-3cd0021bbee3 h1:uVCq/Sx2y4U
github.com/openshift/client-go v0.0.0-20230607134213-3cd0021bbee3/go.mod h1:M+VUIcqx5IvgzejcbgmQnxETPrXRYlcufHpw2bAgz9Y=
github.com/openshift/machine-config-operator v0.0.1-0.20231018130918-594da89d0bb9 h1:oRKh/IBO1yI9HvQyYb3Ee25grcg/T6oFmidOWZ+SxfI=
github.com/openshift/machine-config-operator v0.0.1-0.20231018130918-594da89d0bb9/go.mod h1:ftCpVtU6Q31exB0DTBn9s2eu90RJESOSisNAruWkvcE=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
github.com/paypal/load-watcher v0.2.2 h1:tKCy3Ts8LnihFSLKmyrOODrdt9ulbRXe0MFbxe9U2Bk=
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -344,7 +336,6 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
Expand Down Expand Up @@ -639,14 +630,11 @@ k8s.io/apiextensions-apiserver v0.26.4 h1:9D2RTxYGxrG5uYg6D7QZRcykXvavBvcA59j5kT
k8s.io/apiextensions-apiserver v0.26.4/go.mod h1:cd4uGFGIgzEqUghWpRsr9KE8j2KNTjY8Ji8pnMMazyw=
k8s.io/apimachinery v0.26.4 h1:rZccKdBLg9vP6J09JD+z8Yr99Ce8gk3Lbi9TCx05Jzs=
k8s.io/apimachinery v0.26.4/go.mod h1:ats7nN1LExKHvJ9TmwootT00Yz05MuYqPXEXaVeOy5I=
k8s.io/apiserver v0.26.4 h1:3Oq4mnJv0mzVX7BR/Nod+8KjlELf/3Ljvu9ZWDyLUoA=
k8s.io/apiserver v0.26.4/go.mod h1:yAY3O1vBM4/0OIGAGeWcdfzQvgdwJ188VirLcuSAVnw=
k8s.io/client-go v0.26.4 h1:/7P/IbGBuT73A+G97trf44NTPSNqvuBREpOfdLbHvD4=
k8s.io/client-go v0.26.4/go.mod h1:6qOItWm3EwxJdl/8p5t7FWtWUOwyMdA8N9ekbW4idpI=
k8s.io/code-generator v0.26.4/go.mod h1:ryaiIKwfxEJEaywEzx3dhWOydpVctKYbqLajJf0O8dI=
k8s.io/component-base v0.26.4 h1:Bg2xzyXNKL3eAuiTEu3XE198d6z22ENgFgGQv2GGOUk=
k8s.io/component-base v0.26.4/go.mod h1:lTuWL1Xz/a4e80gmIC3YZG2JCO4xNwtKWHJWeJmsq20=
k8s.io/component-helpers v0.26.4 h1:qbZrh8QmfL+Yn7lWEI/BPrvITGgkBy33djP5Tzsu2hA=
k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
k8s.io/gengo v0.0.0-20220902162205-c0856e24416d/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E=
k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE=
Expand All @@ -657,13 +645,8 @@ k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4=
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg=
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg=
k8s.io/kube-scheduler v0.26.4 h1:J+ZCWQV64atAfHEomA5XrmNlbYI5XtN950zIQZioTnI=
k8s.io/kube-scheduler v0.26.4/go.mod h1:Mzh7sJavoa6+74a0vwv4+OpQXZYAwJA1jEWUkCfuixo=
k8s.io/kubelet v0.26.4 h1:SEQPfjN4lu4uL9O8NdeN7Aum3liQ4kOnp/yC3jMRMUo=
k8s.io/kubelet v0.26.4/go.mod h1:ZMPGTCnrQ5UOlC7igXhbW9cgna1LtTRWLaHub4dA2FU=
k8s.io/kubernetes v1.26.4 h1:/c00/JjOltBwhNOBs+hO433Q3fRyeWWtyYF6z2xtmag=
k8s.io/kubernetes v1.26.4/go.mod h1:NxzR7U7mS+OGa3J/qweI86Pek//mlfHqDgt6NNGdz8g=
k8s.io/metrics v0.26.4 h1:ijyerycmjVp9EVPfDqha8eb+s9jw5c+A9MkTvuRBdms=
k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
k8s.io/utils v0.0.0-20230505201702-9f6742963106 h1:EObNQ3TW2D+WptiYXlApGNLVy0zm/JIBVY9i+M4wpAU=
Expand All @@ -676,8 +659,6 @@ sigs.k8s.io/controller-runtime v0.13.1/go.mod h1:Zbz+el8Yg31jubvAEyglRZGdLAjplZl
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/scheduler-plugins v0.25.7 h1:2qSTXfHmzfFZJF9M9UHLiDXGdDXX+sUs/cn0dHbc4qk=
sigs.k8s.io/scheduler-plugins v0.25.7/go.mod h1:CKgZ1xu9WZdB3CMSzOjro/rtrBY/bQWMf6un2M9VNS4=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
Expand Down
1 change: 1 addition & 0 deletions pkg/commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func NewDeploySchedulerPluginCommand(env *deployer.Environment, commonOpts *depl
Replicas: int32(commonOpts.Replicas),
RTEConfigData: commonOpts.RTEConfigData,
PullIfNotPresent: commonOpts.PullIfNotPresent,
ProfileName: commonOpts.SchedProfileName,
CacheResyncPeriod: commonOpts.SchedResyncPeriod,
CtrlPlaneAffinity: commonOpts.SchedCtrlPlaneAffinity,
Verbose: commonOpts.SchedVerbose,
Expand Down
2 changes: 2 additions & 0 deletions pkg/commands/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func NewRemoveCommand(env *deployer.Environment, commonOpts *deploy.Options) *co
Replicas: int32(commonOpts.Replicas),
RTEConfigData: commonOpts.RTEConfigData,
PullIfNotPresent: commonOpts.PullIfNotPresent,
ProfileName: commonOpts.SchedProfileName,
CacheResyncPeriod: commonOpts.SchedResyncPeriod,
CtrlPlaneAffinity: commonOpts.SchedCtrlPlaneAffinity,
})
Expand Down Expand Up @@ -158,6 +159,7 @@ func NewRemoveSchedulerPluginCommand(env *deployer.Environment, commonOpts *depl
Replicas: int32(commonOpts.Replicas),
RTEConfigData: commonOpts.RTEConfigData,
PullIfNotPresent: commonOpts.PullIfNotPresent,
ProfileName: commonOpts.SchedProfileName,
CacheResyncPeriod: commonOpts.SchedResyncPeriod,
CtrlPlaneAffinity: commonOpts.SchedCtrlPlaneAffinity,
Verbose: commonOpts.SchedVerbose,
Expand Down
1 change: 1 addition & 0 deletions pkg/deploy/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func OnCluster(env *deployer.Environment, commonOpts *Options) error {
Replicas: int32(commonOpts.Replicas),
RTEConfigData: commonOpts.RTEConfigData,
PullIfNotPresent: commonOpts.PullIfNotPresent,
ProfileName: commonOpts.SchedProfileName,
CacheResyncPeriod: commonOpts.SchedResyncPeriod,
CtrlPlaneAffinity: commonOpts.SchedCtrlPlaneAffinity,
Verbose: commonOpts.SchedVerbose,
Expand Down
3 changes: 3 additions & 0 deletions pkg/deployer/sched/sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Options struct {
Platform platform.Platform
WaitCompletion bool
Replicas int32
ProfileName string
RTEConfigData string
PullIfNotPresent bool
CacheResyncPeriod time.Duration
Expand All @@ -54,6 +55,7 @@ func Deploy(env *deployer.Environment, opts Options) error {
}

mf, err = mf.Render(env.Log, schedmanifests.RenderOptions{
ProfileName: opts.ProfileName,
Replicas: opts.Replicas,
PullIfNotPresent: opts.PullIfNotPresent,
CacheResyncPeriod: opts.CacheResyncPeriod,
Expand Down Expand Up @@ -95,6 +97,7 @@ func Remove(env *deployer.Environment, opts Options) error {
}

mf, err = mf.Render(env.Log, schedmanifests.RenderOptions{
ProfileName: opts.ProfileName,
Replicas: opts.Replicas,
PullIfNotPresent: opts.PullIfNotPresent,
CacheResyncPeriod: opts.CacheResyncPeriod,
Expand Down
35 changes: 0 additions & 35 deletions pkg/manifests/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ import (
"k8s.io/apimachinery/pkg/runtime"
k8sjson "k8s.io/apimachinery/pkg/runtime/serializer/json"
k8sscheme "k8s.io/client-go/kubernetes/scheme"
schedconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"

"sigs.k8s.io/controller-runtime/pkg/client"
schedscheme "sigs.k8s.io/scheduler-plugins/apis/config/scheme"
"sigs.k8s.io/scheduler-plugins/apis/config/v1beta2"
)

func SerializeObject(obj runtime.Object, out io.Writer) error {
Expand Down Expand Up @@ -77,38 +74,6 @@ func loadObject(path string) (runtime.Object, error) {
return DeserializeObjectFromData(data)
}

func DecodeSchedulerConfigFromData(data []byte) (*schedconfig.KubeSchedulerConfiguration, error) {
decoder := schedscheme.Codecs.UniversalDecoder()
obj, gvk, err := decoder.Decode(data, nil, nil)

if err != nil {
return nil, err
}

schedCfg, ok := obj.(*schedconfig.KubeSchedulerConfiguration)
if !ok {
return nil, fmt.Errorf("decoded unsupported type: %T gvk=%s", obj, gvk)
}
return schedCfg, nil
}

func EncodeSchedulerConfigToData(schedCfg *schedconfig.KubeSchedulerConfiguration) ([]byte, error) {
yamlInfo, ok := runtime.SerializerInfoForMediaType(schedscheme.Codecs.SupportedMediaTypes(), runtime.ContentTypeYAML)
if !ok {
return nil, fmt.Errorf("unable to locate encoder -- %q is not a supported media type", runtime.ContentTypeYAML)
}

encoder := schedscheme.Codecs.EncoderForVersion(yamlInfo.Serializer, v1beta2.SchemeGroupVersion)

var buf bytes.Buffer
err := encoder.Encode(schedCfg, &buf)
if err != nil {
return nil, err
}

return buf.Bytes(), nil
}

func RenderObjects(objs []client.Object, w io.Writer) error {
for _, obj := range objs {
fmt.Fprintf(w, "---\n")
Expand Down
28 changes: 0 additions & 28 deletions pkg/manifests/manifests.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ import (
apiextensionv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes/scheme"
kubeschedulerconfigv1beta2 "k8s.io/kube-scheduler/config/v1beta2"
"k8s.io/utils/pointer"
apiconfigv1beta2 "sigs.k8s.io/scheduler-plugins/apis/config/v1beta2"

k8sschedpluginsconf "sigs.k8s.io/scheduler-plugins/apis/config"
k8sschedpluginsconfv1beta2 "sigs.k8s.io/scheduler-plugins/apis/config/v1beta2"
k8sschedpluginsconfv1beta3 "sigs.k8s.io/scheduler-plugins/apis/config/v1beta3"

rteassets "github.com/k8stopologyawareschedwg/deployer/pkg/assets/rte"
selinuxassets "github.com/k8stopologyawareschedwg/deployer/pkg/assets/selinux"
Expand Down Expand Up @@ -80,11 +74,6 @@ var src embed.FS

func init() {
apiextensionv1.AddToScheme(scheme.Scheme)
apiconfigv1beta2.AddToScheme(scheme.Scheme)
kubeschedulerconfigv1beta2.AddToScheme(scheme.Scheme)
k8sschedpluginsconf.AddToScheme(scheme.Scheme)
k8sschedpluginsconfv1beta2.AddToScheme(scheme.Scheme)
k8sschedpluginsconfv1beta3.AddToScheme(scheme.Scheme)
machineconfigv1.Install(scheme.Scheme)
securityv1.Install(scheme.Scheme)
}
Expand Down Expand Up @@ -455,23 +444,6 @@ func SecurityContextConstraint(component string) (*securityv1.SecurityContextCon
return scc, nil
}

func KubeSchedulerConfigurationFromData(data []byte) (*kubeschedulerconfigv1beta2.KubeSchedulerConfiguration, error) {
obj, err := DeserializeObjectFromData(data)
if err != nil {
return nil, err
}

sc, ok := obj.(*kubeschedulerconfigv1beta2.KubeSchedulerConfiguration)
if !ok {
return nil, fmt.Errorf("unexpected type, got %T %v", obj, obj.GetObjectKind())
}
return sc, nil
}

func KubeSchedulerConfigurationToData(sc *kubeschedulerconfigv1beta2.KubeSchedulerConfiguration) ([]byte, error) {
return SerializeObjectToData(sc)
}

func validateComponent(component string) error {
if component == ComponentAPI || component == ComponentResourceTopologyExporter || component == ComponentNodeFeatureDiscovery || component == ComponentSchedulerPlugin {
return nil
Expand Down
12 changes: 11 additions & 1 deletion pkg/manifests/sched/sched.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ func (mf Manifests) Render(logger logr.Logger, options RenderOptions) (Manifests
ret.DPScheduler.Spec.Replicas = newInt32(replicas)
ret.DPController.Spec.Replicas = newInt32(replicas)

err := schedupdate.SchedulerConfig(ret.ConfigMap, options.ProfileName, options.CacheResyncPeriod)
params := manifests.ConfigParams{
Cache: &manifests.ConfigCacheParams{
ResyncPeriodSeconds: newInt64(int64(options.CacheResyncPeriod.Seconds())),
},
}

err := schedupdate.SchedulerConfig(ret.ConfigMap, options.ProfileName, &params)
if err != nil {
return ret, err
}
Expand Down Expand Up @@ -211,3 +217,7 @@ func GetManifests(plat platform.Platform, namespace string) (Manifests, error) {
func newInt32(value int32) *int32 {
return &value
}

func newInt64(value int64) *int64 {
return &value
}
Loading

0 comments on commit 0199c84

Please sign in to comment.