From bc78491cace70e3300bf1e364e96370f756b5777 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Wed, 10 Jan 2024 14:17:50 +0200 Subject: [PATCH 1/3] pkg/apis/config: fix balloons config tags. Fix `omitempty` JSON tags for balloons config `PreferCloseToDevices` and `IdleCpuClass`, so they properly imply optionality in the corresponding CRD fields. Tag `PreferFarFromDevices` is considered unstable/untested and should not be used. Hence, tag it as `"-"` to prevent unmarshalling it from a CRD to the actual configuration. Signed-off-by: Krisztian Litkey --- pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go b/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go index 3b1c4f7e7..42af407ca 100644 --- a/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go +++ b/pkg/apis/config/v1alpha1/resmgr/policy/balloons/config.go @@ -46,7 +46,7 @@ type Config struct { PinMemory *bool `json:"pinMemory,omitempty"` // IdleCpuClass controls how unusded CPUs outside any a // balloons are (re)configured. - IdleCpuClass string `json:"idleCPUClass",omitempty"` + IdleCpuClass string `json:"idleCPUClass,omitempty"` // ReservedPoolNamespaces is a list of namespace globs that // will be allocated to reserved CPUs. ReservedPoolNamespaces []string `json:"reservedPoolNamespaces,omitempty"` @@ -185,10 +185,12 @@ type BalloonDef struct { ShareIdleCpusInSame CPUTopologyLevel `json:"shareIdleCPUsInSame,omitempty"` // PreferCloseToDevices: prefer creating new balloons of this // type close to listed devices. - PreferCloseToDevices []string `json:"preferCloseToDevices",omitempty` + PreferCloseToDevices []string `json:"preferCloseToDevices,omitempty"` // PreferFarFromDevices: prefer creating new balloons of this // type far from listed devices. - PreferFarFromDevices []string `json:"preferFarFromDevices",omitempty` + // TODO: PreferFarFromDevices is considered too untested for usage. Hence, + // for the time being we prevent its usage through CRDs. + PreferFarFromDevices []string `json:"-"` } // String stringifies a BalloonDef From 4bc81425d8fc81b4d29d4d122ec927d5619d0e89 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Tue, 9 Jan 2024 19:42:37 +0200 Subject: [PATCH 2/3] pkg/apis, helm: update balloons config/CRD. It looks like the latest balloons configuration additions have been committed then merged without updating the configuration, CRDs and clientsets. Let's fix it. Signed-off-by: Krisztian Litkey --- config/crd/bases/config.nri_balloonspolicies.yaml | 7 ++++++- .../balloons/crds/config.nri_balloonspolicies.yaml | 4 ++-- .../resmgr/policy/balloons/zz_generated.deepcopy.go | 10 ++++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/config/crd/bases/config.nri_balloonspolicies.yaml b/config/crd/bases/config.nri_balloonspolicies.yaml index 178c7d280..61cb9f473 100644 --- a/config/crd/bases/config.nri_balloonspolicies.yaml +++ b/config/crd/bases/config.nri_balloonspolicies.yaml @@ -106,6 +106,12 @@ spec: items: type: string type: array + preferCloseToDevices: + description: 'PreferCloseToDevices: prefer creating new balloons + of this type close to listed devices.' + items: + type: string + type: array preferNewBalloons: description: 'PreferNewBalloons: prefer creating new balloons over adding containers to existing balloons. The default is @@ -297,7 +303,6 @@ spec: description: Reserved (CPU) resources for kube-system namespace. type: object required: - - idleCPUClass - reservedResources type: object status: diff --git a/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml b/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml index 07121dd55..61cb9f473 100644 --- a/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml +++ b/deployment/helm/balloons/crds/config.nri_balloonspolicies.yaml @@ -107,7 +107,8 @@ spec: type: string type: array preferCloseToDevices: - description: prefer creating new balloons of this type close to listed devices. + description: 'PreferCloseToDevices: prefer creating new balloons + of this type close to listed devices.' items: type: string type: array @@ -302,7 +303,6 @@ spec: description: Reserved (CPU) resources for kube-system namespace. type: object required: - - idleCPUClass - reservedResources type: object status: diff --git a/pkg/apis/config/v1alpha1/resmgr/policy/balloons/zz_generated.deepcopy.go b/pkg/apis/config/v1alpha1/resmgr/policy/balloons/zz_generated.deepcopy.go index c443ed6e3..be332eaae 100644 --- a/pkg/apis/config/v1alpha1/resmgr/policy/balloons/zz_generated.deepcopy.go +++ b/pkg/apis/config/v1alpha1/resmgr/policy/balloons/zz_generated.deepcopy.go @@ -41,6 +41,16 @@ func (in *BalloonDef) DeepCopyInto(out *BalloonDef) { *out = new(bool) **out = **in } + if in.PreferCloseToDevices != nil { + in, out := &in.PreferCloseToDevices, &out.PreferCloseToDevices + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.PreferFarFromDevices != nil { + in, out := &in.PreferFarFromDevices, &out.PreferFarFromDevices + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BalloonDef. From c0fb898a2a6653dcfd5616a0a6f33ddbacd3f563 Mon Sep 17 00:00:00 2001 From: Krisztian Litkey Date: Wed, 10 Jan 2024 14:37:50 +0200 Subject: [PATCH 3/3] Makefile: add 'verify-generate' target. Add target for verifying that all generated artifacts are up to date in the repo. Hook it in to the top-level verify target, so it will be run as part of our github CI workflows. Signed-off-by: Krisztian Litkey --- Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e73bc165a..1b06432be 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ allclean: clean clean-cache test: test-gopkgs -verify: verify-godeps verify-fmt +verify: verify-godeps verify-fmt verify-generate # # build targets @@ -372,6 +372,17 @@ verify-fmt: exit 1; \ fi +verify-generate: generate + $(Q) git diff --quiet; ec="$$?"; \ + if [ "$$ec" != "0" ]; then \ + echo "ERROR: generated artifacts are not up-to-date."; \ + echo "ERROR:"; \ + git --no-pager diff | sed 's/^/ERROR: /g'; \ + echo "ERROR:"; \ + echo "ERROR: please run 'make generate' and commit these changes."; \ + exit "$$ec"; \ + fi + # # targets for installing dependencies #