Skip to content

Commit

Permalink
fix: create reconciler if new sub resources are added (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
raffis authored Dec 6, 2024
1 parent ac17b6c commit f0c9742
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/v1beta1/keycloakrealm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ type KeycloakRealmStatus struct {
// ObservedGeneration is the last generation reconciled by the controller
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// ObservedSHA256 is the last realm checksum reconciled by the controller
ObservedSHA256 string `json:"observedSHA256,omitempty"`

// Reconciler is the reconciler pod while a reconciliation is in progress
Reconciler string `json:"reconciler,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9571,6 +9571,10 @@ spec:
by the controller
format: int64
type: integer
observedSHA256:
description: ObservedSHA256 is the last realm checksum reconciled
by the controller
type: string
reconciler:
description: Reconciler is the reconciler pod while a reconciliation
is in progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9571,6 +9571,10 @@ spec:
by the controller
format: int64
type: integer
observedSHA256:
description: ObservedSHA256 is the last realm checksum reconciled
by the controller
type: string
reconciler:
description: Reconciler is the reconciler pod while a reconciliation
is in progress
Expand Down
4 changes: 3 additions & 1 deletion internal/controllers/keycloakrealm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ func (r *KeycloakRealmReconciler) reconcile(ctx context.Context, realm infrav1be
}

// rate limiter
if readyCondition != nil && readyCondition.Status == metav1.ConditionTrue && (realm.Spec.Interval == nil || time.Since(readyCondition.LastTransitionTime.Time) < realm.Spec.Interval.Duration) && realm.Generation == readyCondition.ObservedGeneration {
if readyCondition != nil && readyCondition.Status == metav1.ConditionTrue && (realm.Spec.Interval == nil || time.Since(readyCondition.LastTransitionTime.Time) < realm.Spec.Interval.Duration) && checksum == realm.Status.ObservedSHA256 {
logger.V(1).Info("skip reconciliation, last transition time too recent")

if realm.Spec.Interval != nil {
Expand All @@ -346,6 +346,8 @@ func (r *KeycloakRealmReconciler) reconcile(ctx context.Context, realm infrav1be
}
}

realm.Status.ObservedSHA256 = checksum

// handle reconciler pod state
if podErr == nil && pod.Name != "" {
return r.handlerReconcilerState(realm, pod, logger)
Expand Down

0 comments on commit f0c9742

Please sign in to comment.