Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomitn committed Sep 3, 2024
1 parent 4dbe580 commit 6c0b8e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 31 deletions.
31 changes: 8 additions & 23 deletions controllers/flashsystemcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

var flashSystemClusterFinalizer = "flashsystemcluster.odf.ibm.com"
Expand Down Expand Up @@ -137,7 +136,7 @@ func (s *ReconcileMapper) CSIToClusterMapFunc(_ client.Object) []reconcile.Reque
return requests
}

func (s *ReconcileMapper) SecretToClusterMapFunc(object client.Object) []reconcile.Request {
func (s *ReconcileMapper) SecretToClusterMapFunc(object client.Object, _ reconcile.Request) []reconcile.Request {
clusters := &odfv1.FlashSystemClusterList{}

err := s.reconciler.Client.List(context.TODO(), clusters)
Expand Down Expand Up @@ -465,27 +464,13 @@ func (r *FlashSystemClusterReconciler) SetupWithManager(mgr ctrl.Manager) error
//TODO: it seems operator-sdk 1.5 + golang 1.5 fails to watch resources through Owns
return ctrl.NewControllerManagedBy(mgr).
For(&odfv1.FlashSystemCluster{}).
Watches(&source.Kind{
Type: &appsv1.Deployment{},
}, &handler.EnqueueRequestForOwner{OwnerType: &odfv1.FlashSystemCluster{}}).
Watches(&source.Kind{
Type: &corev1.Service{},
}, &handler.EnqueueRequestForOwner{OwnerType: &odfv1.FlashSystemCluster{}}).
Watches(&source.Kind{
Type: &monitoringv1.ServiceMonitor{},
}, &handler.EnqueueRequestForOwner{OwnerType: &odfv1.FlashSystemCluster{}}).
Watches(&source.Kind{
Type: &corev1.Secret{},
}, handler.EnqueueRequestsFromMapFunc(reconcileMapper.SecretToClusterMapFunc)).
Watches(&source.Kind{
Type: &storagev1.StorageClass{},
}, handler.EnqueueRequestsFromMapFunc(reconcileMapper.DefaultStorageClassToClusterMapperFunc), builder.WithPredicates(util.RunDeletePredicate)).
Watches(&source.Kind{
Type: &corev1.ConfigMap{},
}, handler.EnqueueRequestsFromMapFunc(reconcileMapper.ConfigMapToClusterMapFunc), builder.WithPredicates(util.RunDeletePredicate)).
Watches(&source.Kind{
Type: csiBlock},
handler.EnqueueRequestsFromMapFunc(reconcileMapper.CSIToClusterMapFunc), builder.WithPredicates(util.RunDeletePredicate)).
Watches(&appsv1.Deployment{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &odfv1.FlashSystemCluster{})).
Watches(&corev1.Service{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &odfv1.FlashSystemCluster{})).
Watches(&monitoringv1.ServiceMonitor{}, handler.EnqueueRequestForOwner(mgr.GetScheme(), mgr.GetRESTMapper(), &odfv1.FlashSystemCluster{})).
Watches(&corev1.Secret{}, handler.EnqueueRequestsFromMapFunc(reconcileMapper.SecretToClusterMapFunc)).

Check failure on line 470 in controllers/flashsystemcluster_controller.go

View workflow job for this annotation

GitHub Actions / precheck-and-build (1.22)

cannot use reconcileMapper.SecretToClusterMapFunc (value of type func(object client.Object, _ reconcile.Request) []reconcile.Request) as handler.TypedMapFunc[client.Object, reconcile.Request] value in argument to handler.EnqueueRequestsFromMapFunc
Watches(&storagev1.StorageClass{}, handler.EnqueueRequestsFromMapFunc(reconcileMapper.DefaultStorageClassToClusterMapperFunc), builder.WithPredicates(util.RunDeletePredicate)).

Check failure on line 471 in controllers/flashsystemcluster_controller.go

View workflow job for this annotation

GitHub Actions / precheck-and-build (1.22)

cannot use reconcileMapper.DefaultStorageClassToClusterMapperFunc (value of type func(object client.Object) []reconcile.Request) as handler.TypedMapFunc[client.Object, reconcile.Request] value in argument to handler.EnqueueRequestsFromMapFunc
Watches(&corev1.ConfigMap{}, handler.EnqueueRequestsFromMapFunc(reconcileMapper.ConfigMapToClusterMapFunc), builder.WithPredicates(util.RunDeletePredicate)).

Check failure on line 472 in controllers/flashsystemcluster_controller.go

View workflow job for this annotation

GitHub Actions / precheck-and-build (1.22)

cannot use reconcileMapper.ConfigMapToClusterMapFunc (value of type func(object client.Object) []reconcile.Request) as handler.TypedMapFunc[client.Object, reconcile.Request] value in argument to handler.EnqueueRequestsFromMapFunc
Watches(csiBlock, handler.EnqueueRequestsFromMapFunc(reconcileMapper.CSIToClusterMapFunc), builder.WithPredicates(util.RunDeletePredicate)).

Check failure on line 473 in controllers/flashsystemcluster_controller.go

View workflow job for this annotation

GitHub Actions / precheck-and-build (1.22)

cannot use reconcileMapper.CSIToClusterMapFunc (value of type func(_ client.Object) []reconcile.Request) as handler.TypedMapFunc[client.Object, reconcile.Request] value in argument to handler.EnqueueRequestsFromMapFunc
WithOptions(controller.Options{MaxConcurrentReconciles: 1}).
Complete(r)

Expand Down
11 changes: 3 additions & 8 deletions controllers/persistentvolume/persistentvolume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
"strings"

"github.com/IBM/ibm-storage-odf-operator/controllers/util"
Expand All @@ -45,7 +44,7 @@ type persistentVolumeMapper struct {
reconciler *PersistentVolumeWatcher
}

func (f *persistentVolumeMapper) pvMap(_ client.Object) []reconcile.Request {
func (f *persistentVolumeMapper) pvMap(_ context.Context, _ client.Object) []reconcile.Request {
pvs := &corev1.PersistentVolumeList{}
err := f.reconciler.Client.List(context.TODO(), pvs)
if err != nil {
Expand Down Expand Up @@ -111,12 +110,8 @@ func (r *PersistentVolumeWatcher) SetupWithManager(mgr ctrl.Manager) error {

return ctrl.NewControllerManagedBy(mgr).
For(&corev1.PersistentVolume{}, builder.WithPredicates(pvPredicate)).
Watches(&source.Kind{
Type: &apiv1.FlashSystemCluster{},
}, handler.EnqueueRequestsFromMapFunc(pvMapper.pvMap), builder.WithPredicates(util.IgnoreUpdateAndGenericPredicate)).
Watches(&source.Kind{
Type: &corev1.Secret{},
}, handler.EnqueueRequestsFromMapFunc(pvMapper.pvMap), builder.WithPredicates(util.SecretMgmtAddrPredicate)).
Watches(&apiv1.FlashSystemCluster{}, handler.EnqueueRequestsFromMapFunc(pvMapper.pvMap), builder.WithPredicates(util.IgnoreUpdateAndGenericPredicate)).
Watches(&corev1.Secret{}, handler.EnqueueRequestsFromMapFunc(pvMapper.pvMap), builder.WithPredicates(util.SecretMgmtAddrPredicate)).
WithOptions(controller.Options{MaxConcurrentReconciles: 1}).
Complete(r)
}
Expand Down

0 comments on commit 6c0b8e2

Please sign in to comment.