From 8c19de1b2a10e461dea3e4a799e60cf58d38719e Mon Sep 17 00:00:00 2001 From: shaloulcy Date: Thu, 12 Oct 2023 20:36:11 -0500 Subject: [PATCH] manager: add GetNodeAllocatable in quota-controller (#1710) Signed-off-by: chuanyun.lcy Co-authored-by: chuanyun.lcy --- .../profile/profile_controller.go | 2 +- pkg/quota-controller/profile/util.go | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 pkg/quota-controller/profile/util.go diff --git a/pkg/quota-controller/profile/profile_controller.go b/pkg/quota-controller/profile/profile_controller.go index e6176b506..3aea4f394 100644 --- a/pkg/quota-controller/profile/profile_controller.go +++ b/pkg/quota-controller/profile/profile_controller.go @@ -139,7 +139,7 @@ func (r *QuotaProfileReconciler) Reconcile(ctx context.Context, req ctrl.Request // TODO: consider node status. totalResource := corev1.ResourceList{} for _, node := range nodeList.Items { - totalResource = quotav1.Add(totalResource, node.Status.Allocatable) + totalResource = quotav1.Add(totalResource, GetNodeAllocatable(node)) } decorateTotalResource(profile, totalResource) diff --git a/pkg/quota-controller/profile/util.go b/pkg/quota-controller/profile/util.go new file mode 100644 index 000000000..34fae64c2 --- /dev/null +++ b/pkg/quota-controller/profile/util.go @@ -0,0 +1,25 @@ +/* +Copyright 2022 The Koordinator Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package profile + +import ( + corev1 "k8s.io/api/core/v1" +) + +func GetNodeAllocatable(node corev1.Node) corev1.ResourceList { + return node.Status.Allocatable.DeepCopy() +}