Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/styra/v1beta1/system_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ const (
// for the SLP used by the System.
EventErrorGetStatefulSet EventType = "ErrorGetStatefulSet"

// EventErrorStatefulSetNotFound is an EventType used when a system with 'localPlane' enabled but which
// does not have a StatefulSet created for the SLP.
EventErrorStatefulSetNotFound EventType = "ErrorStatefulSetNotFound"

// EventErrorPatchStatefulSet is an EventType used when the controller fails to patch the StatefulSet
// for the SLP used by the System.
EventErrorPatchStatefulSet EventType = "ErrorPatchStatefulSet"
Expand Down
11 changes: 10 additions & 1 deletion internal/controller/styra/system_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@ func (r *SystemReconciler) restartSLPs(
nsName := types.NamespacedName{Name: system.Spec.LocalPlane.Name, Namespace: system.Namespace}
var sts appsv1.StatefulSet
if err := r.Get(ctx, nsName, &sts); err != nil {
if k8serrors.IsNotFound(err) {
log.Info("System has SLP but no SLP found with that name")
return ctrl.Result{}, ctrlerr.Wrap(err, "SLP statefulset not found for system with SLP enabled").
WithEvent(v1beta1.EventErrorStatefulSetNotFound).
WithSystemCondition(v1beta1.ConditionTypeSLPUpToDate)
}
return ctrl.Result{}, ctrlerr.Wrap(err, "Could not get StatefulSet").
WithEvent(v1beta1.EventErrorGetStatefulSet).
WithSystemCondition(v1beta1.ConditionTypeSLPUpToDate)
Expand Down Expand Up @@ -1573,7 +1579,10 @@ func (r *SystemReconciler) SetupWithManager(mgr ctrl.Manager, name string) error
if err != nil {
return errors.Wrap(err, "Could not build predicate")
}
p = ctrlpred.And(p, ctrlpred.GenerationChangedPredicate{})

updatedPred := ctrlpred.Or(ctrlpred.GenerationChangedPredicate{}, ctrlpred.LabelChangedPredicate{})

p = ctrlpred.And(p, updatedPred)

return ctrl.NewControllerManagedBy(mgr).Named(name).
For(&v1beta1.System{}, builder.WithPredicates(p)).
Expand Down
Loading