Skip to content

Commit

Permalink
manager: add GetNodeAllocatable in quota-controller (#1710)
Browse files Browse the repository at this point in the history
Signed-off-by: chuanyun.lcy <[email protected]>
Co-authored-by: chuanyun.lcy <[email protected]>
  • Loading branch information
shaloulcy and chuanyun.lcy authored Oct 13, 2023
1 parent 5675273 commit 8c19de1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/quota-controller/profile/profile_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 25 additions & 0 deletions pkg/quota-controller/profile/util.go
Original file line number Diff line number Diff line change
@@ -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()
}

0 comments on commit 8c19de1

Please sign in to comment.