Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: adding role and set correct name to get CRQ #268

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo in qouta its quota

btw why did we need resoucequota in the name as its already ClusterResourceQuota.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot change the name of the resource right now because it has inherited from version 4.17. If I change it, I will need to conduct tests for the upgrade and some other scenarios. I will create a new task for this and work on it. Thank you for eyeing on that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
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
Loading