Skip to content

Commit

Permalink
fix(resourcequotas): Update namespace-specific hard quota calculation…
Browse files Browse the repository at this point in the history
… logic (#1088)

Signed-off-by: Lukas Boettcher <[email protected]>
  • Loading branch information
lukasboettcher authored May 23, 2024
1 parent 915e493 commit b16bcda
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion controllers/tenant/resourcequotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,15 @@ func (r *Manager) syncResourceQuotas(ctx context.Context, tenant *capsulev1beta2
list.Items[item].Spec.Hard = map[corev1.ResourceName]resource.Quantity{}
}

list.Items[item].Spec.Hard[name] = resourceQuota.Hard[name]
// Effectively this subtracts the usage from all other namespaces in the tenant from the desired tenant hard quota.
// Thus we can determine, how much is left in this resourcequota (item) for the current resource (name).
// We use this remaining quota at the tenant level, to update the hard quota for the current namespace.

newHard := hardQuota // start off with desired tenant wide hard quota
newHard.Sub(quantity) // subtract tenant wide usage
newHard.Add(list.Items[item].Status.Used[name]) // add back usage in current ns

list.Items[item].Spec.Hard[name] = newHard

for k := range list.Items[item].Spec.Hard {
if !toKeep.Has(k) {
Expand Down

0 comments on commit b16bcda

Please sign in to comment.