Skip to content

Commit

Permalink
sync resourcequota objectstorage/size status used (#5102)
Browse files Browse the repository at this point in the history
  • Loading branch information
nowinkeyy authored Sep 26, 2024
1 parent 2fd2f07 commit b78691a
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"
"context"
"fmt"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -148,6 +149,7 @@ func (r *ObjectStorageUserReconciler) Reconcile(ctx context.Context, req ctrl.Re
}

quota := resourceQuota.Spec.Hard.Name(ResourceObjectStorageSize, resource.BinarySI)
used := resourceQuota.Status.Used.Name(ResourceObjectStorageSize, resource.BinarySI)

updated := r.initObjectStorageUser(user, username, quota.Value())

Expand Down Expand Up @@ -201,6 +203,14 @@ func (r *ObjectStorageUserReconciler) Reconcile(ctx context.Context, req ctrl.Re
updated = true
}

if used.Value() != size {
resourceQuota.Status.Used[ResourceObjectStorageSize] = resource.MustParse(strconv.FormatInt(size, 10))
if err := r.Status().Update(ctx, resourceQuota); err != nil {
r.Logger.Error(err, "failed to update status", "name", resourceQuota.Name, "namespace", userNamespace)
return ctrl.Result{}, err
}
}

if user.Status.ObjectsCount != objectsCount {
user.Status.ObjectsCount = objectsCount
updated = true
Expand Down

0 comments on commit b78691a

Please sign in to comment.