From de156c111f52af84932937b071f79f2285702927 Mon Sep 17 00:00:00 2001 From: luomingmeng Date: Thu, 29 Jun 2023 19:50:24 +0800 Subject: [PATCH] refactor adminqos definition list member remove omitempty json flag --- ...talyst.kubewharf.io_adminqosconfigurations.yaml | 2 ++ pkg/apis/config/v1alpha1/adminqos.go | 6 ++++-- pkg/client/clientset/versioned/fake/register.go | 14 +++++++------- pkg/client/clientset/versioned/scheme/register.go | 14 +++++++------- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml b/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml index 6b658f9..a84eaa5 100644 --- a/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml +++ b/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml @@ -164,6 +164,7 @@ spec: - priority.pod - mem.total.numa.container type: string + minItems: 1 type: array numaFreeBelowWatermarkTimesThreshold: description: NumaFreeBelowWatermarkTimesThreshold is the @@ -185,6 +186,7 @@ spec: - priority.pod - mem.usage.container type: string + minItems: 1 type: array systemKswapdRateExceedTimesThreshold: description: SystemKswapdRateExceedTimesThreshold is the diff --git a/pkg/apis/config/v1alpha1/adminqos.go b/pkg/apis/config/v1alpha1/adminqos.go index ca13bba..2df03bd 100644 --- a/pkg/apis/config/v1alpha1/adminqos.go +++ b/pkg/apis/config/v1alpha1/adminqos.go @@ -177,7 +177,7 @@ type EvictionConfig struct { // 'foo' means "dry-run 'foo'" // first item for a particular name wins // +optional - DryRun []string `json:"dryRun,omitempty"` + DryRun []string `json:"dryRun"` // CPUPressureEvictionConfig is the config for cpu pressure eviction // +optional @@ -195,7 +195,7 @@ type EvictionConfig struct { type ReclaimedResourcesEvictionConfig struct { // EvictionThreshold eviction threshold rate for reclaimed resources // +optional - EvictionThreshold map[v1.ResourceName]float64 `json:"evictionThreshold,omitempty"` + EvictionThreshold map[v1.ResourceName]float64 `json:"evictionThreshold"` // GracePeriod is the grace period of reclaimed resources' eviction // +kubectl:validation:Minimum=0 @@ -289,11 +289,13 @@ type MemoryPressureEvictionConfig struct { // NumaEvictionRankingMetrics is the metrics used to rank pods for eviction // at the NUMA level + // +kubebuilder:validation:MinItems=1 // +optional NumaEvictionRankingMetrics []NumaEvictionRankingMetric `json:"numaEvictionRankingMetrics,omitempty"` // SystemEvictionRankingMetrics is the metrics used to rank pods for eviction // at the system level + // +kubebuilder:validation:MinItems=1 // +optional SystemEvictionRankingMetrics []SystemEvictionRankingMetric `json:"systemEvictionRankingMetrics,omitempty"` diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index dd28213..39e11b6 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -43,14 +43,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index 2f79e87..632af74 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -43,14 +43,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly.