Skip to content

Commit bfa66f8

Browse files
committed
для случая нет АГ или портов - это валидная история - ставим кондишен True
1 parent 901c2d2 commit bfa66f8

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

internal/controller/rules2s_controller.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,12 +260,11 @@ func (r *RuleS2SReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
260260
missingAddressGroupsMsg = fmt.Sprintf("TargetService '%s' has no address groups", targetService.Name)
261261
}
262262

263-
// Update status with error condition
264263
meta.SetStatusCondition(&ruleS2S.Status.Conditions, metav1.Condition{
265264
Type: netguardv1alpha1.ConditionReady,
266-
Status: metav1.ConditionFalse,
267-
Reason: "NoAddressGroups",
268-
Message: missingAddressGroupsMsg,
265+
Status: metav1.ConditionTrue,
266+
Reason: "ValidConfiguration",
267+
Message: fmt.Sprintf("Rule is valid but inactive: %s", missingAddressGroupsMsg),
269268
})
270269
if err := UpdateStatusWithRetry(ctx, r.Client, ruleS2S, DefaultMaxRetries); err != nil {
271270
logger.Error(err, "Failed to update RuleS2S status")
@@ -300,22 +299,21 @@ func (r *RuleS2SReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
300299
serviceName = fmt.Sprintf("target service '%s'", targetService.Name)
301300
}
302301

303-
errorMsg := fmt.Sprintf("No ports defined for the %s (traffic direction: %s)",
302+
infoMsg := fmt.Sprintf("No ports defined for the %s (traffic direction: %s)",
304303
serviceName, ruleS2S.Spec.Traffic)
305304

306-
// Update status with error condition
307305
meta.SetStatusCondition(&ruleS2S.Status.Conditions, metav1.Condition{
308306
Type: netguardv1alpha1.ConditionReady,
309-
Status: metav1.ConditionFalse,
310-
Reason: "NoPorts",
311-
Message: errorMsg,
307+
Status: metav1.ConditionTrue,
308+
Reason: "ValidConfiguration",
309+
Message: fmt.Sprintf("Rule is valid but inactive: %s", infoMsg),
312310
})
313311
if err := UpdateStatusWithRetry(ctx, r.Client, ruleS2S, DefaultMaxRetries); err != nil {
314312
logger.Error(err, "Failed to update RuleS2S status")
315313
}
316314

317315
// Логируем информацию
318-
logger.Info(errorMsg, "traffic", ruleS2S.Spec.Traffic)
316+
logger.Info(infoMsg, "traffic", ruleS2S.Spec.Traffic)
319317

320318
// Возвращаем пустой Result без RequeueAfter
321319
return ctrl.Result{}, nil

0 commit comments

Comments
 (0)