Skip to content

Commit

Permalink
Explicitly set GVK for IBMPowerVSCluster object
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik-K-N committed Mar 27, 2024
1 parent 0ccbfe8 commit a5c78ef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions controllers/ibmpowervscluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,17 @@ func (r *IBMPowerVSClusterReconciler) deleteIBMPowerVSImage(ctx context.Context,
return reconcile.Result{}, err
}

// since we are avoiding using cache for IBMPowerVSCluster the Type meta of the retrieved object will be empty
// explicitly setting here to filter children
if gvk := cluster.GetObjectKind().GroupVersionKind(); gvk.Empty() {
gvk, err := r.GroupVersionKindFor(cluster)
if err != nil {
log.Error(err, "Failed to get GVK of cluster")
return reconcile.Result{}, err
}
cluster.SetGroupVersionKind(gvk)
}

children, err := descendants.filterOwnedDescendants(cluster)
if err != nil {
log.Error(err, "Failed to extract direct descendants")
Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/webhook"

capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
Expand Down Expand Up @@ -130,6 +131,13 @@ func main() {
Port: webhookPort,
CertDir: webhookCertDir,
}),
Client: client.Options{
Cache: &client.CacheOptions{
DisableFor: []client.Object{
&infrav1beta2.IBMPowerVSCluster{},
},
},
},
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down

0 comments on commit a5c78ef

Please sign in to comment.