From b2782c047dc28d1c51d900a2259090d9bca17378 Mon Sep 17 00:00:00 2001 From: linzhecheng Date: Tue, 2 Jul 2024 10:38:19 +0800 Subject: [PATCH] chore: refine control knob constraints Signed-off-by: linzhecheng --- ...t.kubewharf.io_adminqosconfigurations.yaml | 36 ++++++------ pkg/apis/config/v1alpha1/adminqos.go | 22 ++++--- .../config/v1alpha1/zz_generated.deepcopy.go | 57 ++++++++++++------- 3 files changed, 66 insertions(+), 49 deletions(-) diff --git a/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml b/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml index 8ee3d7b..3759971 100644 --- a/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml +++ b/config/crd/bases/config.katalyst.kubewharf.io_adminqosconfigurations.yaml @@ -82,30 +82,26 @@ spec: constraints: items: properties: - name: - description: ControlKnobName defines available - control knob key for provision policy - type: string - restrictControlKnobMaxLowerGap: - description: RestrictControlKnobMaxUpperGap - is the maximum downward offset value from - the baseline + maxLowerGap: + description: MaxLowerGap is the maximum downward + offset value from the baseline type: number - restrictControlKnobMaxLowerGapRatio: - description: RestrictControlKnobMaxUpperGap - is the maximum downward offset ratio from - the baseline + maxLowerGapRatio: + description: MaxLowerGapRatio is the maximum + downward offset ratio from the baseline type: number - restrictControlKnobMaxUpperGap: - description: RestrictControlKnobMaxUpperGap - is the maximum upward offset value from the - baseline + maxUpperGap: + description: MaxUpperGap is the maximum upward + offset value from the baseline type: number - restrictControlKnobMaxUpperGapRatio: - description: RestrictControlKnobMaxUpperGap - is the maximum upward offset ratio from the - baseline + maxUpperGapRatio: + description: MaxUpperGapRatio is the maximum + upward offset ratio from the baseline type: number + name: + description: ControlKnobName defines available + control knob key for provision policy + type: string required: - name type: object diff --git a/pkg/apis/config/v1alpha1/adminqos.go b/pkg/apis/config/v1alpha1/adminqos.go index e14e689..27aa992 100644 --- a/pkg/apis/config/v1alpha1/adminqos.go +++ b/pkg/apis/config/v1alpha1/adminqos.go @@ -177,16 +177,20 @@ type IndicatorTargetConfiguration struct { Target float64 `json:"target"` } +type RestrictConstraints struct { + // MaxUpperGap is the maximum upward offset value from the baseline + MaxUpperGap *float64 `json:"maxUpperGap,omitempty"` + // MaxLowerGap is the maximum downward offset value from the baseline + MaxLowerGap *float64 `json:"maxLowerGap,omitempty"` + // MaxUpperGapRatio is the maximum upward offset ratio from the baseline + MaxUpperGapRatio *float64 `json:"maxUpperGapRatio,omitempty"` + // MaxLowerGapRatio is the maximum downward offset ratio from the baseline + MaxLowerGapRatio *float64 `json:"maxLowerGapRatio,omitempty"` +} + type ControlKnobConstraints struct { - Name ControlKnobName `json:"name"` - // RestrictControlKnobMaxUpperGap is the maximum upward offset value from the baseline - RestrictControlKnobMaxUpperGap *float64 `json:"restrictControlKnobMaxUpperGap,omitempty"` - // RestrictControlKnobMaxUpperGap is the maximum downward offset value from the baseline - RestrictControlKnobMaxLowerGap *float64 `json:"restrictControlKnobMaxLowerGap,omitempty"` - // RestrictControlKnobMaxUpperGap is the maximum upward offset ratio from the baseline - RestrictControlKnobMaxUpperGapRatio *float64 `json:"restrictControlKnobMaxUpperGapRatio,omitempty"` - // RestrictControlKnobMaxUpperGap is the maximum downward offset ratio from the baseline - RestrictControlKnobMaxLowerGapRatio *float64 `json:"restrictControlKnobMaxLowerGapRatio,omitempty"` + Name ControlKnobName `json:"name"` + RestrictConstraints RestrictConstraints `json:",inline"` } type CPUProvisionConfig struct { diff --git a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go index ec8dbce..1009768 100644 --- a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go @@ -639,26 +639,7 @@ func (in *CgroupConfig) DeepCopy() *CgroupConfig { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ControlKnobConstraints) DeepCopyInto(out *ControlKnobConstraints) { *out = *in - if in.RestrictControlKnobMaxUpperGap != nil { - in, out := &in.RestrictControlKnobMaxUpperGap, &out.RestrictControlKnobMaxUpperGap - *out = new(float64) - **out = **in - } - if in.RestrictControlKnobMaxLowerGap != nil { - in, out := &in.RestrictControlKnobMaxLowerGap, &out.RestrictControlKnobMaxLowerGap - *out = new(float64) - **out = **in - } - if in.RestrictControlKnobMaxUpperGapRatio != nil { - in, out := &in.RestrictControlKnobMaxUpperGapRatio, &out.RestrictControlKnobMaxUpperGapRatio - *out = new(float64) - **out = **in - } - if in.RestrictControlKnobMaxLowerGapRatio != nil { - in, out := &in.RestrictControlKnobMaxLowerGapRatio, &out.RestrictControlKnobMaxLowerGapRatio - *out = new(float64) - **out = **in - } + in.RestrictConstraints.DeepCopyInto(&out.RestrictConstraints) return } @@ -1617,6 +1598,42 @@ func (in *ResourcePortraitIndicators) DeepCopyObject() runtime.Object { return nil } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RestrictConstraints) DeepCopyInto(out *RestrictConstraints) { + *out = *in + if in.MaxUpperGap != nil { + in, out := &in.MaxUpperGap, &out.MaxUpperGap + *out = new(float64) + **out = **in + } + if in.MaxLowerGap != nil { + in, out := &in.MaxLowerGap, &out.MaxLowerGap + *out = new(float64) + **out = **in + } + if in.MaxUpperGapRatio != nil { + in, out := &in.MaxUpperGapRatio, &out.MaxUpperGapRatio + *out = new(float64) + **out = **in + } + if in.MaxLowerGapRatio != nil { + in, out := &in.MaxLowerGapRatio, &out.MaxLowerGapRatio + *out = new(float64) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RestrictConstraints. +func (in *RestrictConstraints) DeepCopy() *RestrictConstraints { + if in == nil { + return nil + } + out := new(RestrictConstraints) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RootfsPressureEvictionConfig) DeepCopyInto(out *RootfsPressureEvictionConfig) { *out = *in