Skip to content

Commit

Permalink
fix: add clusterScope condition statement to service_controller suppo…
Browse files Browse the repository at this point in the history
…rting namespace-scoped mode properly

Signed-off-by: jooho <[email protected]>
  • Loading branch information
Jooho committed Sep 27, 2023
1 parent 856b16e commit 0a32d28
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions controllers/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,23 @@ func (r *ServiceReconciler) reconcileService(ctx context.Context, mms *mmesh.MMS
// - when the namespace does not have the annotation modelmesh-enabled
// - when the namespace is under a Terminating state.
n := &corev1.Namespace{}
if err := r.Client.Get(ctx, types.NamespacedName{Name: namespace}, n); err != nil {
return nil, err, false
if r.ClusterScope {
if err := r.Client.Get(ctx, types.NamespacedName{Name: namespace}, n); err != nil {
return nil, err, false
}
} else {
n = &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: namespace,
},
}
}

if !modelMeshEnabled(n, r.ControllerDeployment.Namespace) {
r.ModelEventStream.RemoveWatchedService(serviceName, namespace)
r.Log.Info("Deleted Watched Service", "name", serviceName, "namespace", namespace)
return nil, nil, false
}

var s *corev1.Service
for i := range sl.Items {
ss := &sl.Items[i]
Expand Down

0 comments on commit 0a32d28

Please sign in to comment.