-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
856fe91
commit 6d71009
Showing
5 changed files
with
26 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -184,7 +184,7 @@ func (r *ElementalMachineReconciler) ClusterToElementalMachines(ctx context.Cont | |
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
// For more details about the reconciliation loop, check the official CAPI documentation: | ||
// - https://cluster-api.sigs.k8s.io/developer/providers/machine-infrastructure | ||
func (r *ElementalMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
func (r *ElementalMachineReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, rerr error) { | ||
logger := log.FromContext(ctx). | ||
WithValues(ilog.KeyNamespace, req.Namespace). | ||
WithValues(ilog.KeyElementalMachine, req.Name) | ||
|
@@ -229,6 +229,12 @@ func (r *ElementalMachineReconciler) Reconcile(ctx context.Context, req ctrl.Req | |
if err != nil { | ||
return ctrl.Result{}, fmt.Errorf("initializing patch helper: %w", err) | ||
} | ||
defer func() { | ||
// Reconciliation step #12: Patch the resource to persist changes | ||
if err := patchHelper.Patch(ctx, elementalMachine); err != nil { | ||
rerr = fmt.Errorf("patching ElementalMachine: %w", err) | ||
} | ||
}() | ||
|
||
if elementalMachine.GetDeletionTimestamp() == nil || elementalMachine.GetDeletionTimestamp().IsZero() { | ||
// The object is not being deleted, so register the finalizer | ||
|
@@ -254,7 +260,6 @@ func (r *ElementalMachineReconciler) Reconcile(ctx context.Context, req ctrl.Req | |
return ctrl.Result{}, fmt.Errorf("reconciling ElementalMachine: %w", err) | ||
} | ||
return result, nil | ||
|
||
} | ||
|
||
// The object is up for deletion | ||
|
@@ -264,11 +269,6 @@ func (r *ElementalMachineReconciler) Reconcile(ctx context.Context, req ctrl.Req | |
} | ||
} | ||
|
||
// Reconciliation step #12: Patch the resource to persist changes | ||
if err := patchHelper.Patch(ctx, elementalMachine); err != nil { | ||
return ctrl.Result{}, fmt.Errorf("patching ElementalMachine: %w", err) | ||
} | ||
|
||
return ctrl.Result{}, nil | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,7 +47,7 @@ type ElementalMachineRegistrationReconciler struct { | |
// | ||
// For more details, check Reconcile and its Result here: | ||
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/reconcile | ||
func (r *ElementalMachineRegistrationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { | ||
func (r *ElementalMachineRegistrationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Result, rerr error) { | ||
logger := log.FromContext(ctx). | ||
WithValues(ilog.KeyNamespace, req.Namespace). | ||
WithValues(ilog.KeyElementalMachineRegistration, req.Name) | ||
|
@@ -67,10 +67,11 @@ func (r *ElementalMachineRegistrationReconciler) Reconcile(ctx context.Context, | |
if err != nil { | ||
return ctrl.Result{}, fmt.Errorf("initializing patch helper: %w", err) | ||
} | ||
|
||
if err := patchHelper.Patch(ctx, elementalMachineRegistration); err != nil { | ||
return ctrl.Result{}, fmt.Errorf("patching ElementalMachineRegistration: %w", err) | ||
} | ||
defer func() { | ||
if err := patchHelper.Patch(ctx, elementalMachineRegistration); err != nil { | ||
rerr = fmt.Errorf("patching ElementalMachineRegistration: %w", err) | ||
} | ||
}() | ||
|
||
return ctrl.Result{}, nil | ||
} | ||
|