Skip to content

Commit

Permalink
Merge pull request #7987 from killianmuldoon/pr-exvars-cc-observedGen
Browse files Browse the repository at this point in the history
🌱  Add observedGeneration to ClusterClass status
  • Loading branch information
k8s-ci-robot authored Jan 27, 2023
2 parents 5c6fb4b + 5978270 commit 358a064
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions api/v1beta1/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,10 @@ type ClusterClassStatus struct {
// Conditions defines current observed state of the ClusterClass.
// +optional
Conditions Conditions `json:"conditions,omitempty"`

// ObservedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

// GetConditions returns the set of conditions for this object.
Expand Down
7 changes: 7 additions & 0 deletions api/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions internal/controllers/clusterclass/clusterclass_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,16 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
}

defer func() {
if err := patchHelper.Patch(ctx, clusterClass); err != nil {
// Patch ObservedGeneration only if the reconciliation completed successfully
patchOpts := []patch.Option{}
if reterr == nil {
patchOpts = append(patchOpts, patch.WithStatusObservedGeneration{})
}
if err := patchHelper.Patch(ctx, clusterClass, patchOpts...); err != nil {
reterr = kerrors.NewAggregate([]error{reterr, errors.Wrapf(err, "failed to patch %s", tlog.KObj{Obj: clusterClass})})
return
}
}()

return r.reconcile(ctx, clusterClass)
}

Expand Down

0 comments on commit 358a064

Please sign in to comment.