Skip to content

Commit 6f9e69a

Browse files
authored
Merge pull request #7995 from sbueringer/pr-fix-apiversion-bump-in-mp
🌱 MachinePool: automatically bump apiVersions like in our other controllers
2 parents a613700 + e2f820f commit 6f9e69a

File tree

6 files changed

+135
-116
lines changed

6 files changed

+135
-116
lines changed

exp/controllers/alias.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import (
2828

2929
// MachinePoolReconciler reconciles a MachinePool object.
3030
type MachinePoolReconciler struct {
31-
Client client.Client
31+
Client client.Client
32+
APIReader client.Reader
3233

3334
// WatchFilterValue is the label value used to filter events prior to reconciliation.
3435
WatchFilterValue string
@@ -37,6 +38,7 @@ type MachinePoolReconciler struct {
3738
func (r *MachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
3839
return (&machinepool.MachinePoolReconciler{
3940
Client: r.Client,
41+
APIReader: r.APIReader,
4042
WatchFilterValue: r.WatchFilterValue,
4143
}).SetupWithManager(ctx, mgr, options)
4244
}

exp/internal/controllers/machinepool_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ const (
5959

6060
// MachinePoolReconciler reconciles a MachinePool object.
6161
type MachinePoolReconciler struct {
62-
Client client.Client
62+
Client client.Client
63+
APIReader client.Reader
6364

6465
// WatchFilterValue is the label value used to filter events prior to reconciliation.
6566
WatchFilterValue string

exp/internal/controllers/machinepool_controller_phases.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import (
3939
"sigs.k8s.io/cluster-api/util"
4040
"sigs.k8s.io/cluster-api/util/annotations"
4141
"sigs.k8s.io/cluster-api/util/conditions"
42+
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
4243
"sigs.k8s.io/cluster-api/util/patch"
4344
)
4445

@@ -104,6 +105,10 @@ func (r *MachinePoolReconciler) reconcilePhase(mp *expv1.MachinePool) {
104105
func (r *MachinePoolReconciler) reconcileExternal(ctx context.Context, cluster *clusterv1.Cluster, m *expv1.MachinePool, ref *corev1.ObjectReference) (external.ReconcileOutput, error) {
105106
log := ctrl.LoggerFrom(ctx)
106107

108+
if err := utilconversion.UpdateReferenceAPIContract(ctx, r.Client, r.APIReader, ref); err != nil {
109+
return external.ReconcileOutput{}, err
110+
}
111+
107112
obj, err := external.Get(ctx, r.Client, ref, m.Namespace)
108113
if err != nil {
109114
if apierrors.IsNotFound(errors.Cause(err)) {

0 commit comments

Comments
 (0)