Skip to content

Commit

Permalink
Merge pull request #268 from rchikatw/uiclustername
Browse files Browse the repository at this point in the history
api: adding role and set correct name to get CRQ
  • Loading branch information
openshift-merge-bot[bot] authored Nov 13, 2024
2 parents f027087 + b42557f commit 284e512
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,12 @@ spec:
verbs:
- get
- list
- apiGroups:
- quota.openshift.io
resources:
- clusterresourcequotas
verbs:
- get
serviceAccountName: ocs-client-operator-status-reporter
deployments:
- label:
Expand Down
6 changes: 6 additions & 0 deletions config/rbac/status-reporter-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ rules:
verbs:
- get
- list
- apiGroups:
- quota.openshift.io
resources:
- clusterresourcequotas
verbs:
- get
2 changes: 1 addition & 1 deletion internal/controller/storageclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func (r *StorageClientReconciler) reconcilePhases() (ctrl.Result, error) {

func (r *StorageClientReconciler) reconcileClusterResourceQuota(spec *quotav1.ClusterResourceQuotaSpec) error {
clusterResourceQuota := &quotav1.ClusterResourceQuota{}
clusterResourceQuota.Name = fmt.Sprintf("storage-client-%s-resourceqouta", utils.GetMD5Hash(r.storageClient.Name))
clusterResourceQuota.Name = utils.GetClusterResourceQuotaName(r.storageClient.Name)
_, err := controllerutil.CreateOrUpdate(r.ctx, r.Client, clusterResourceQuota, func() error {

if err := r.own(clusterResourceQuota); err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/utils/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,7 @@ func mutate(f controllerutil.MutateFn, key client.ObjectKey, obj client.Object)
}
return nil
}

func GetClusterResourceQuotaName(name string) string {
return fmt.Sprintf("storage-client-%s-resourceqouta", GetMD5Hash(name))
}
2 changes: 1 addition & 1 deletion service/status-report/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func setClusterInformation(ctx context.Context, cl client.Client, status interfa

func setStorageQuotaUtilizationRatio(ctx context.Context, cl client.Client, status interfaces.StorageClientStatus) {
clusterResourceQuota := &quotav1.ClusterResourceQuota{}
clusterResourceQuota.Name = status.GetClientName()
clusterResourceQuota.Name = utils.GetClusterResourceQuotaName(status.GetClientName())

// No need to check for NotFound because unlimited quota client will not have CRQ resource
if err := cl.Get(ctx, client.ObjectKeyFromObject(clusterResourceQuota), clusterResourceQuota); client.IgnoreNotFound(err) != nil {
Expand Down

0 comments on commit 284e512

Please sign in to comment.