Skip to content

Commit

Permalink
Merge pull request red-hat-storage#1664 from Madhu-1/use-gvk-scc
Browse files Browse the repository at this point in the history
use GVK to get Kind of consumer obj
  • Loading branch information
openshift-merge-robot committed May 11, 2022
2 parents 61bfc42 + 5aa617f commit 71530c1
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
Expand Down Expand Up @@ -397,10 +398,14 @@ func (r *StorageClassClaimReconciler) reconcileProviderPhases() (reconcile.Resul

r.storageClassClaim.Status.Phase = v1alpha1.StorageClassClaimInitializing

gvk, err := apiutil.GVKForObject(r.storageConsumer, r.Client.Scheme())
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to get gvk for consumer %w", err)
}
// reading storageConsumer Name from storageClassClaim ownerReferences
ownerRefs := r.storageClassClaim.GetOwnerReferences()
for i := range ownerRefs {
if ownerRefs[i].Kind == "StorageConsumer" {
if ownerRefs[i].Kind == gvk.Kind {
r.storageConsumer = &v1alpha1.StorageConsumer{}
r.storageConsumer.Name = ownerRefs[i].Name
r.storageConsumer.Namespace = r.storageCluster.Namespace
Expand Down

0 comments on commit 71530c1

Please sign in to comment.