@@ -78,7 +78,7 @@ func (r *SlackClusterQueueMonitor) Reconcile(ctx context.Context, req ctrl.Reque
78
78
79
79
// enforce lending limits on 1st flavor of 1st resource group
80
80
resources := cq .Spec .ResourceGroups [0 ].Flavors [0 ].Resources
81
- limitsChanged := false
81
+ delta := map [v1. ResourceName ] * resource. Quantity {}
82
82
for i , quota := range resources {
83
83
var lendingLimit * resource.Quantity
84
84
if unschedulableQuantity := unschedulableQuantities [quota .Name ]; unschedulableQuantity != nil {
@@ -89,19 +89,28 @@ func (r *SlackClusterQueueMonitor) Reconcile(ctx context.Context, req ctrl.Reque
89
89
lendingLimit = resource .NewQuantity (0 , resource .DecimalSI )
90
90
}
91
91
}
92
- if quota .LendingLimit == nil && lendingLimit != nil ||
93
- quota .LendingLimit != nil && lendingLimit == nil ||
94
- quota .LendingLimit != nil && lendingLimit != nil && quota .LendingLimit .Cmp (* lendingLimit ) != 0 {
95
- limitsChanged = true
92
+ if quota .LendingLimit == nil && lendingLimit != nil {
93
+ delta [quota .Name ] = ptr .To (quota .NominalQuota )
94
+ delta [quota .Name ].Sub (* lendingLimit )
95
+ delta [quota .Name ].Neg ()
96
+ resources [i ].LendingLimit = lendingLimit
97
+ } else if quota .LendingLimit != nil && lendingLimit == nil {
98
+ delta [quota .Name ] = ptr .To (quota .NominalQuota )
99
+ delta [quota .Name ].Sub (* quota .LendingLimit )
100
+ resources [i ].LendingLimit = lendingLimit
101
+ } else if quota .LendingLimit != nil && lendingLimit != nil && quota .LendingLimit .Cmp (* lendingLimit ) != 0 {
102
+ delta [quota .Name ] = ptr .To (* quota .LendingLimit )
103
+ delta [quota .Name ].Sub (* lendingLimit )
104
+ delta [quota .Name ].Neg ()
96
105
resources [i ].LendingLimit = lendingLimit
97
106
}
98
107
}
99
108
100
109
// update lending limits
101
- if limitsChanged {
110
+ if len ( delta ) > 0 {
102
111
err := r .Update (ctx , cq )
103
112
if err == nil {
104
- log .FromContext (ctx ).Info ("Updated lending limits" , "Resources" , resources )
113
+ log .FromContext (ctx ).Info ("Updated lending limits" , "Changed by" , delta , "Updated Resources" , resources )
105
114
return ctrl.Result {}, nil
106
115
} else if errors .IsConflict (err ) {
107
116
return ctrl.Result {Requeue : true }, nil
0 commit comments