Skip to content

Commit

Permalink
fix(): object type pod
Browse files Browse the repository at this point in the history
Signed-off-by: Mridul Gain <[email protected]>
  • Loading branch information
mridulgain committed May 23, 2024
1 parent e3b14cf commit 986d2af
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers/serviceexport/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ func (r *Reconciler) Setup(mgr ctrl.Manager, mf metrics.MetricsFactory) error {
func (r *Reconciler) mapPodsToServiceExport(ctx context.Context, obj client.Object) (recs []reconcile.Request) {
log := logger.FromContext(ctx)
debugLog := log.V(1)
_, ok := obj.(*corev1.Secret)
debugLog.Info("triggered watcher for svc export")
_, ok := obj.(*corev1.Pod)
if !ok {
debugLog.Info("Unexpected object type in ServiceExport reconciler watch predicate expected *corev1.Pod found ", reflect.TypeOf(obj))
return
Expand All @@ -252,13 +253,18 @@ func (r *Reconciler) mapPodsToServiceExport(ctx context.Context, obj client.Obje
log.Error(err, "Failed to list service export", "application namespace", obj.GetNamespace())
return
}
debugLog.Info("Service export found in app ns", "count", len(svcexpList.Items))
for _, svcexp := range svcexpList.Items {
selector, err := metav1.LabelSelectorAsSelector(svcexp.Spec.Selector)
if err != nil {
log.Error(err, "Failed to parse selector", "service export", svcexp.Name, "selector", svcexp.Spec.Selector)
continue
}
if selector.Matches(labels.Set(obj.GetLabels())) {
debugLog.Info("requeueing svc export", "obj", types.NamespacedName{
Name: svcexp.Name,
Namespace: svcexp.Namespace,
})
recs = append(recs, reconcile.Request{
NamespacedName: types.NamespacedName{
Name: svcexp.Name,
Expand Down

0 comments on commit 986d2af

Please sign in to comment.