Created
November 27, 2025 15:24
-
-
Save fabriziopandini/2f53866aed6a17a5dc33ed844203aad9 to your computer and use it in GitHub Desktop.
patch capi 13059
This file contains hidden or 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
| Index: internal/controllers/machineset/machineset_controller_test.go | |
| IDEA additional info: | |
| Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
| <+>UTF-8 | |
| =================================================================== | |
| diff --git a/internal/controllers/machineset/machineset_controller_test.go b/internal/controllers/machineset/machineset_controller_test.go | |
| --- a/internal/controllers/machineset/machineset_controller_test.go (revision b81b8888e8cdbec44f5cc00ad8c5ced40b585fb2) | |
| +++ b/internal/controllers/machineset/machineset_controller_test.go (date 1764256166630) | |
| @@ -47,10 +47,12 @@ | |
| "sigs.k8s.io/controller-runtime/pkg/reconcile" | |
| clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2" | |
| + runtimehooksv1 "sigs.k8s.io/cluster-api/api/runtime/hooks/v1alpha1" | |
| runtimev1 "sigs.k8s.io/cluster-api/api/runtime/v1beta2" | |
| "sigs.k8s.io/cluster-api/controllers/external" | |
| "sigs.k8s.io/cluster-api/feature" | |
| "sigs.k8s.io/cluster-api/internal/contract" | |
| + "sigs.k8s.io/cluster-api/internal/hooks" | |
| "sigs.k8s.io/cluster-api/internal/util/ssa" | |
| "sigs.k8s.io/cluster-api/util" | |
| "sigs.k8s.io/cluster-api/util/conditions" | |
| @@ -3478,10 +3480,19 @@ | |
| wantErr: false, | |
| }, | |
| } | |
| + | |
| + // We want to test that trigger in place handles version and failure domain, which are not reconciled by syncMachines | |
| + versionBeforeInplaceUpdate := "v1.33.0" | |
| + versionAfterInplaceUpdate := "v1.34.0" | |
| + failureDomainBeforeInplaceUpdate := "fd-1" | |
| + failureDomainAfterInplaceUpdate := "fd-2" | |
| + | |
| for _, tt := range tests { | |
| t.Run(tt.name, func(t *testing.T) { | |
| g := NewWithT(t) | |
| + tt.ms.Spec.Template.Spec.Version = versionAfterInplaceUpdate | |
| + tt.ms.Spec.Template.Spec.FailureDomain = failureDomainAfterInplaceUpdate | |
| tt.ms.Spec.Template.Spec.InfrastructureRef = clusterv1.ContractVersionedObjectReference{ | |
| APIGroup: infraTmpl.GroupVersionKind().Group, | |
| Kind: infraTmpl.GetKind(), | |
| @@ -3507,6 +3518,14 @@ | |
| for _, m := range tt.machines { | |
| m.SetNamespace(tt.ms.Namespace) | |
| + if hooks.IsPending(runtimehooksv1.UpdateMachine, m) { | |
| + m.Spec.Version = versionAfterInplaceUpdate | |
| + m.Spec.FailureDomain = failureDomainAfterInplaceUpdate | |
| + } else { | |
| + // NOTE: following values must be changed when in place upgrade is triggered for a machine | |
| + m.Spec.Version = versionBeforeInplaceUpdate | |
| + m.Spec.FailureDomain = failureDomainBeforeInplaceUpdate | |
| + } | |
| mInfraObj := infraObj.DeepCopy() | |
| mInfraObj.SetName(m.Name) | |
| @@ -3552,6 +3571,16 @@ | |
| updatingMachines := machinesInPlaceUpdating(machines) | |
| g.Expect(updatingMachines).To(ConsistOf(tt.wantMachinesInPlaceUpdating)) | |
| + | |
| + for _, m := range machines.Items { | |
| + if hooks.IsPending(runtimehooksv1.UpdateMachine, &m) { | |
| + g.Expect(m.Spec.Version).To(Equal(versionAfterInplaceUpdate)) | |
| + g.Expect(m.Spec.FailureDomain).To(Equal(failureDomainAfterInplaceUpdate)) | |
| + } else { | |
| + g.Expect(m.Spec.Version).To(Equal(versionBeforeInplaceUpdate)) | |
| + g.Expect(m.Spec.FailureDomain).To(Equal(failureDomainBeforeInplaceUpdate)) | |
| + } | |
| + } | |
| }) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment