Skip to content

Commit

Permalink
fix: do not trigger reconcile on DSC if no instance in the cluster
Browse files Browse the repository at this point in the history
-  remove check on CM(from operator NS) with uninstall label, it should be done by Owns(configmap)
- remove check on zeor DSC instance to not continue recontile with dummy name

Signed-off-by: Wen Zhou <wenzhou@redhat.com>

update: remove unnecessary predicate

Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Oct 31, 2024
1 parent 8ea9ea0 commit b4825c8
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions controllers/datasciencecluster/datasciencecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,6 @@ func (r *DataScienceClusterReconciler) SetupWithManager(ctx context.Context, mgr
return r.watchDataScienceClusterForDSCI(ctx, a)
},
)).
Watches(
&corev1.ConfigMap{},
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, a client.Object) []reconcile.Request {
return r.watchDataScienceClusterResources(ctx, a)
}),
builder.WithPredicates(configMapPredicates),
).
Watches(
&apiextensionsv1.CustomResourceDefinition{},
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, a client.Object) []reconcile.Request {
Expand Down Expand Up @@ -568,19 +561,6 @@ func (r *DataScienceClusterReconciler) watchDataScienceClusterResources(ctx cont
}}
}

// Trigger reconcile function when uninstall configmap is created
operatorNs, err := cluster.GetOperatorNamespace()
if err != nil {
return nil
}
if a.GetNamespace() == operatorNs {
cmLabels := a.GetLabels()
if val, ok := cmLabels[upgrade.DeleteConfigMapLabel]; ok && val == "true" {
return []reconcile.Request{{
NamespacedName: types.NamespacedName{Name: requestName},
}}
}
}
return nil
}

Expand All @@ -595,7 +575,7 @@ func (r *DataScienceClusterReconciler) getRequestName(ctx context.Context) (stri
case len(instanceList.Items) == 1:
return instanceList.Items[0].Name, nil
case len(instanceList.Items) == 0:
return "default-dsc", nil
return "", errors.New("none DataScienceCluster instance found")
default:
return "", errors.New("multiple DataScienceCluster instances found")
}
Expand Down

0 comments on commit b4825c8

Please sign in to comment.