From b6c27b77637e2d6a170de05bc619f6d37e5338d8 Mon Sep 17 00:00:00 2001 From: linzhecheng Date: Fri, 29 May 2026 14:46:36 +0800 Subject: [PATCH] refactor: use ResourceList for node resource usage - replace fixed cpu and memory fields with ResourceList - update NUMA and generic usage schemas in node metrics - regenerate deepcopy methods for updated API types Signed-off-by: linzhecheng --- ...sparentmemoryoffloadingconfigurations.yaml | 15 +++ ...lyst.kubewharf.io_customnoderesources.yaml | 76 +++++-------- .../config/v1alpha1/zz_generated.deepcopy.go | 5 + pkg/apis/node/v1alpha1/types.go | 9 +- .../node/v1alpha1/zz_generated.deepcopy.go | 100 ++++++++++++------ 5 files changed, 116 insertions(+), 89 deletions(-) diff --git a/config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml b/config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml index 6c82897a..8b90fb66 100644 --- a/config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml +++ b/config/crd/bases/config.katalyst.kubewharf.io_transparentmemoryoffloadingconfigurations.yaml @@ -147,6 +147,11 @@ spec: identifying memory pages that can be offloaded. type: number type: object + reservedInactiveFile: + description: ReservedInactiveFile is the reserved value + of inactive file memory + format: int64 + type: integer type: object required: - cgroupPath @@ -280,6 +285,11 @@ spec: identifying memory pages that can be offloaded. type: number type: object + reservedInactiveFile: + description: ReservedInactiveFile is the reserved value + of inactive file memory + format: int64 + type: integer type: object poolName: description: PoolName is a resource pool name, e.g. system, @@ -350,6 +360,11 @@ spec: identifying memory pages that can be offloaded. type: number type: object + reservedInactiveFile: + description: ReservedInactiveFile is the reserved value + of inactive file memory + format: int64 + type: integer type: object qosLevel: description: QoSLevel is either of reclaimed_cores, shared_cores, diff --git a/config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml b/config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml index 3de89fa0..df281249 100644 --- a/config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml +++ b/config/crd/bases/node.katalyst.kubewharf.io_customnoderesources.yaml @@ -154,21 +154,14 @@ spec: - system_cores type: string genericUsage: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true description: GenericUsage contains the real-time resource usage - properties: - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true type: object numaUsage: description: NUMAUsage contains the real-time resource usage @@ -178,21 +171,14 @@ spec: numaId: type: integer usage: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true description: Usage contains the real-time resource usage for this NUMA node - properties: - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true type: object required: - numaId @@ -214,21 +200,14 @@ spec: description: NodeMetric contains the metrics for this node. properties: genericUsage: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true description: GenericUsage contains the real-time resource usage - properties: - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true type: object numaUsage: description: NUMAUsage contains the real-time resource usage @@ -238,21 +217,14 @@ spec: numaId: type: integer usage: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true description: Usage contains the real-time resource usage for this NUMA node - properties: - cpu: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - memory: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true type: object required: - numaId diff --git a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go index dd187ad9..674f742e 100644 --- a/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/config/v1alpha1/zz_generated.deepcopy.go @@ -3082,6 +3082,11 @@ func (in *TMOConfigDetail) DeepCopyInto(out *TMOConfigDetail) { *out = new(bool) **out = **in } + if in.ReservedInactiveFile != nil { + in, out := &in.ReservedInactiveFile, &out.ReservedInactiveFile + *out = new(uint64) + **out = **in + } if in.Interval != nil { in, out := &in.Interval, &out.Interval *out = new(v1.Duration) diff --git a/pkg/apis/node/v1alpha1/types.go b/pkg/apis/node/v1alpha1/types.go index b506301c..69012a5b 100644 --- a/pkg/apis/node/v1alpha1/types.go +++ b/pkg/apis/node/v1alpha1/types.go @@ -338,17 +338,12 @@ type NodeMetricStatus struct { GroupMetric []GroupMetricInfo `json:"groupMetric,omitempty"` } -type ResourceMetric struct { - CPU *resource.Quantity `json:"cpu,omitempty"` - Memory *resource.Quantity `json:"memory,omitempty"` -} - type ResourceUsage struct { // NUMAUsage contains the real-time resource usage for each NUMA NUMAUsage []NUMAMetricInfo `json:"numaUsage,omitempty"` // GenericUsage contains the real-time resource usage - GenericUsage *ResourceMetric `json:"genericUsage,omitempty"` + GenericUsage v1.ResourceList `json:"genericUsage,omitempty"` } type GroupMetricInfo struct { @@ -367,7 +362,7 @@ type NodeMetricInfo struct { type NUMAMetricInfo struct { NUMAId int `json:"numaId"` // Usage contains the real-time resource usage for this NUMA node - Usage *ResourceMetric `json:"usage"` + Usage v1.ResourceList `json:"usage"` } // ResourcePackage represents a single compute package definition. diff --git a/pkg/apis/node/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/node/v1alpha1/zz_generated.deepcopy.go index 11a68294..2eb597f9 100644 --- a/pkg/apis/node/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/node/v1alpha1/zz_generated.deepcopy.go @@ -285,8 +285,10 @@ func (in *NUMAMetricInfo) DeepCopyInto(out *NUMAMetricInfo) { *out = *in if in.Usage != nil { in, out := &in.Usage, &out.Usage - *out = new(ResourceMetric) - (*in).DeepCopyInto(*out) + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } } return } @@ -503,32 +505,6 @@ func (in *Property) DeepCopy() *Property { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ResourceMetric) DeepCopyInto(out *ResourceMetric) { - *out = *in - if in.CPU != nil { - in, out := &in.CPU, &out.CPU - x := (*in).DeepCopy() - *out = &x - } - if in.Memory != nil { - in, out := &in.Memory, &out.Memory - x := (*in).DeepCopy() - *out = &x - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceMetric. -func (in *ResourceMetric) DeepCopy() *ResourceMetric { - if in == nil { - return nil - } - out := new(ResourceMetric) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ResourcePackage) DeepCopyInto(out *ResourcePackage) { *out = *in @@ -616,8 +592,10 @@ func (in *ResourceUsage) DeepCopyInto(out *ResourceUsage) { } if in.GenericUsage != nil { in, out := &in.GenericUsage, &out.GenericUsage - *out = new(ResourceMetric) - (*in).DeepCopyInto(*out) + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } } return } @@ -768,6 +746,38 @@ func (in *Taint) DeepCopy() *Taint { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in TopologyAllocation) DeepCopyInto(out *TopologyAllocation) { + { + in := &in + *out = make(TopologyAllocation, len(*in)) + for key, val := range *in { + var outVal map[string]ZoneAllocation + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make(map[string]ZoneAllocation, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + (*out)[key] = outVal + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TopologyAllocation. +func (in TopologyAllocation) DeepCopy() TopologyAllocation { + if in == nil { + return nil + } + out := new(TopologyAllocation) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TopologyZone) DeepCopyInto(out *TopologyZone) { *out = *in @@ -818,3 +828,33 @@ func (in *TopologyZone) DeepCopy() *TopologyZone { in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ZoneAllocation) DeepCopyInto(out *ZoneAllocation) { + *out = *in + if in.Allocated != nil { + in, out := &in.Allocated, &out.Allocated + *out = make(v1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.Attributes != nil { + in, out := &in.Attributes, &out.Attributes + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZoneAllocation. +func (in *ZoneAllocation) DeepCopy() *ZoneAllocation { + if in == nil { + return nil + } + out := new(ZoneAllocation) + in.DeepCopyInto(out) + return out +}