Skip to content

Commit eb15b1e

Browse files
authored
enhancement: Add condition to global settings if using the wrong name/namespace (#2063)
1 parent d14ba26 commit eb15b1e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

go/controller/internal/controller/deploymentsettings_controller.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ func (r *DeploymentSettingsReconciler) Reconcile(ctx context.Context, req ctrl.R
7272
if err := r.Get(ctx, req.NamespacedName, settings); err != nil {
7373
return ctrl.Result{}, client.IgnoreNotFound(err)
7474
}
75+
7576
utils.MarkCondition(settings.SetCondition, v1alpha1.ReadyConditionType, v1.ConditionFalse, v1alpha1.ReadyConditionReason, "")
76-
// make sure there is only one CRD object with the `global` name and the agent namespace
77-
if settings.Name != deploymentSettingsName || settings.Namespace != deploymentSettingsNamespace {
78-
return ctrl.Result{}, nil
79-
}
77+
8078
scope, err := NewDefaultScope(ctx, r.Client, settings)
8179
if err != nil {
8280
logger.Error(err, "failed to create deployment settings scope")
@@ -90,6 +88,12 @@ func (r *DeploymentSettingsReconciler) Reconcile(ctx context.Context, req ctrl.R
9088
}
9189
}()
9290

91+
// make sure there is only one CRD object with the `global` name and the agent namespace
92+
if settings.Name != deploymentSettingsName || settings.Namespace != deploymentSettingsNamespace {
93+
utils.MarkCondition(settings.SetCondition, v1alpha1.SynchronizedConditionType, v1.ConditionFalse, v1alpha1.SynchronizedConditionReasonError, fmt.Sprintf("ignoring because of invalid name/namespace, only the %s/%s DeploymentSettings will be reconciled", deploymentSettingsName, deploymentSettingsNamespace))
94+
return ctrl.Result{}, nil
95+
}
96+
9397
// Switch to namespace credentials if configured. This has to be done before sending any request to the console.
9498
nc, err := r.ConsoleClient.UseCredentials(req.Namespace, r.CredentialsCache)
9599
credentials.SyncCredentialsInfo(settings, settings.SetCondition, nc, err)

0 commit comments

Comments
 (0)