Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions cmd/machine-api-migration/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,6 @@ func getControllers(opts commoncmdoptions.OperatorConfig, platform configv1.Plat
CAPINamespace: *opts.CAPINamespace,
},
"machineset migration": &machinesetmigration.MachineSetMigrationReconciler{
Platform: platform,
Infra: infra,
InfraTypes: infraTypes,

MAPINamespace: *opts.MAPINamespace,
CAPINamespace: *opts.CAPINamespace,
},
Expand Down
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/openshift/cluster-api-actuator-pkg v0.0.0-20260310144400-bec013a007a8
github.com/openshift/cluster-api-provider-baremetal v0.0.0-20250619124612-fb678fec5f7e
github.com/openshift/cluster-capi-operator v0.0.0-20260425200736-89a8af46df2a
github.com/openshift/library-go v0.0.0-20260413093329-d2db42c961e1
k8s.io/api v0.35.3
k8s.io/apimachinery v0.35.3
k8s.io/client-go v0.35.3
Expand Down Expand Up @@ -103,7 +104,6 @@ require (
github.com/openshift/client-go v0.0.0-20260416131737-a19e91702ab5 // indirect
github.com/openshift/cluster-api-actuator-pkg/testutils v0.0.0 // indirect
github.com/openshift/cluster-autoscaler-operator v0.0.1-0.20250702183526-4eb64d553940 // indirect
github.com/openshift/library-go v0.0.0-20260413093329-d2db42c961e1 // indirect
github.com/openshift/machine-api-operator v0.2.1-0.20260226113419-88465550a74b // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
Expand Down
3 changes: 3 additions & 0 deletions e2e/machine_migration_capi_authoritative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachineAuthoritative(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMAPIMachineSynchronizedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSynchronizedGeneration(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSynchronizedAPI(newMapiMachine, mapiv1beta1.ClusterAPISynchronized)
verifyMachinePausedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachinePausedCondition(newCapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)

Expand All @@ -235,6 +236,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachineAuthoritative(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMAPIMachineSynchronizedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachineSynchronizedGeneration(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachineSynchronizedAPI(newMapiMachine, mapiv1beta1.MachineAPISynchronized)
verifyMachinePausedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachinePausedCondition(newCapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)

Expand All @@ -244,6 +246,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachineAuthoritative(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMAPIMachineSynchronizedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSynchronizedGeneration(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSynchronizedAPI(newMapiMachine, mapiv1beta1.ClusterAPISynchronized)
verifyMachinePausedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachinePausedCondition(newCapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)

Expand Down
11 changes: 11 additions & 0 deletions e2e/machine_migration_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,3 +478,14 @@ func verifyMachineSynchronizedGeneration(mapiMachine *mapiv1beta1.Machine, autho
Fail(fmt.Sprintf("unknown authoritativeAPI type: %v", authority))
}
}

// verifyMachineSynchronizedAPI verifies that the MAPI Machine's status.synchronizedAPI matches the expected value.
func verifyMachineSynchronizedAPI(mapiMachine *mapiv1beta1.Machine, expectedSynchronizedAPI mapiv1beta1.SynchronizedAPI) {
GinkgoHelper()

By(fmt.Sprintf("Verifying MAPI Machine SynchronizedAPI is %s", expectedSynchronizedAPI))
Comment thread
RadekManak marked this conversation as resolved.
Eventually(komega.Object(mapiMachine), capiframework.WaitMedium, capiframework.RetryMedium).Should(
HaveField("Status.SynchronizedAPI", Equal(expectedSynchronizedAPI)),
fmt.Sprintf("MAPI Machine SynchronizedAPI should be %s", expectedSynchronizedAPI),
)
}
3 changes: 3 additions & 0 deletions e2e/machine_migration_mapi_authoritative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachineAuthoritative(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMAPIMachineSynchronizedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachineSynchronizedGeneration(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachineSynchronizedAPI(newMapiMachine, mapiv1beta1.MachineAPISynchronized)
verifyMachinePausedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachinePausedCondition(newCapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)

Expand All @@ -195,6 +196,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachineAuthoritative(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMAPIMachineSynchronizedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSynchronizedGeneration(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSynchronizedAPI(newMapiMachine, mapiv1beta1.ClusterAPISynchronized)
verifyMachinePausedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachinePausedCondition(newCapiMachine, mapiv1beta1.MachineAuthorityClusterAPI)

Expand All @@ -204,6 +206,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachineAuthoritative(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMAPIMachineSynchronizedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachineSynchronizedGeneration(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachineSynchronizedAPI(newMapiMachine, mapiv1beta1.MachineAPISynchronized)
verifyMachinePausedCondition(newMapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachinePausedCondition(newCapiMachine, mapiv1beta1.MachineAuthorityMachineAPI)

Expand Down
2 changes: 2 additions & 0 deletions e2e/machineset_migration_capi_authoritative_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachineSetPausedCondition(mapiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachineSetPausedCondition(capiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMAPIMachineSetSynchronizedCondition(mapiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMachineSetSynchronizedAPI(mapiMachineSet, mapiv1beta1.MachineAPISynchronized)

By("Scaling up MAPI MachineSet to 3 replicas")
Expect(mapiframework.ScaleMachineSet(mapiMSAuthCAPIName, 3)).To(Succeed(), "should be able to scale up MAPI MachineSet")
Expand Down Expand Up @@ -216,6 +217,7 @@ var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration] Ma
verifyMachineSetPausedCondition(mapiMachineSet, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSetPausedCondition(capiMachineSet, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMAPIMachineSetSynchronizedCondition(mapiMachineSet, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSetSynchronizedAPI(mapiMachineSet, mapiv1beta1.ClusterAPISynchronized)

By("Deleting CAPI MachineSet and verifying mirrors are removed")
capiframework.DeleteMachineSets(ctx, cl, capiMachineSet)
Expand Down
245 changes: 245 additions & 0 deletions e2e/machineset_migration_disruptive_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// Copyright 2026 Red Hat, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package e2e

import (
"fmt"
"time"

. "github.com/onsi/ginkgo/v2"

configv1 "github.com/openshift/api/config/v1"
"github.com/openshift/api/features"
mapiv1beta1 "github.com/openshift/api/machine/v1beta1"
capiframework "github.com/openshift/cluster-capi-operator/e2e/framework"
awsv1 "sigs.k8s.io/cluster-api-provider-aws/v2/api/v1beta2"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
)

type machineSetMigrationDisruptiveFixture struct {
awsMachineTemplate *awsv1.AWSMachineTemplate
capiMachineSet *clusterv1.MachineSet
mapiMachineSet *mapiv1beta1.MachineSet
}

func createZeroReplicaMachineSetMigrationDisruptiveFixture(machineSetNamePrefix string) machineSetMigrationDisruptiveFixture {
GinkgoHelper()

machineSetName := generateName(machineSetNamePrefix)
mapiMachineSet := createMAPIMachineSetWithAuthoritativeAPI(
ctx,
cl,
0,
machineSetName,
mapiv1beta1.MachineAuthorityMachineAPI,
mapiv1beta1.MachineAuthorityMachineAPI,
)
capiMachineSet, awsMachineTemplate := waitForMAPIMachineSetMirrors(machineSetName)
trackResource(awsMachineTemplate)

return machineSetMigrationDisruptiveFixture{
awsMachineTemplate: awsMachineTemplate,
capiMachineSet: capiMachineSet,
mapiMachineSet: mapiMachineSet,
}
}

var _ = Describe("[sig-cluster-lifecycle][OCPFeatureGate:MachineAPIMigration][Disruptive] MachineSet Migration Outage Tests", Ordered, Serial, func() {
var (
disruptionState *machineSetMigrationDisruptionState
disruptionStateRestored bool
fixtureA machineSetMigrationDisruptiveFixture
fixtureB machineSetMigrationDisruptiveFixture
)

BeforeAll(func() {
if platform != configv1.AWSPlatformType {
Skip(fmt.Sprintf("Skipping tests on %s, this is only supported on AWS", platform))
}

if !capiframework.IsFeatureGateEnabled(ctx, cl, features.FeatureGateMachineAPIMigration) {
Skip("Skipping, this feature is only supported on MachineAPIMigration enabled clusters")
}

Comment thread
RadekManak marked this conversation as resolved.
DeferCleanup(func() {
By("Cleaning up MachineSet outage test resources")
cleanupMachineSetTestResources(
ctx,
cl,
[]*clusterv1.MachineSet{fixtureA.capiMachineSet, fixtureB.capiMachineSet},
[]*awsv1.AWSMachineTemplate{fixtureA.awsMachineTemplate, fixtureB.awsMachineTemplate},
[]*mapiv1beta1.MachineSet{fixtureA.mapiMachineSet, fixtureB.mapiMachineSet},
)
})

DeferCleanup(func() {
if disruptionState == nil || disruptionStateRestored {
return
}

By("Restoring Deployment/openshift-cluster-api/capi-controller-manager to its original replica count")
scaleDeploymentAndWaitForAvailableReplicas(
ctx,
cl,
capiframework.CAPINamespace,
capiControllerManagerDeploymentName,
disruptionState.capiControllerManagerReplicas,
)

By("Restoring Deployment/openshift-cluster-api-operator/capi-operator to its original replica count")
scaleDeploymentAndWaitForAvailableReplicas(
ctx,
cl,
capiframework.CAPIOperatorNamespace,
capiOperatorDeploymentName,
disruptionState.capiOperatorReplicas,
)

if disruptionState.capiOperatorOverrideExpectedAbsent {
By("Removing the targeted ClusterVersion unmanaged override for Deployment/openshift-cluster-api-operator/capi-operator")
setMachineSetMigrationCAPIOperatorOverride(ctx, cl, false)
}

waitForClusterAPIOperatorHealthy(ctx, cl)
})
})

It("should reuse one outage to verify paused-target and unpaused-target rollback behavior", func() {
By("Creating the paused-target rollback fixture before the outage")
fixtureA = createZeroReplicaMachineSetMigrationDisruptiveFixture("ms-disruptive-paused-target-")
verifyMAPIMachineSetSynchronizedState(
fixtureA.mapiMachineSet,
mapiv1beta1.MachineAuthorityMachineAPI,
mapiv1beta1.MachineAPISynchronized,
)
verifyCAPIMachineSetPausedState(fixtureA.capiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)

By("Creating the unpaused-target rollback fixture before the outage")
fixtureB = createZeroReplicaMachineSetMigrationDisruptiveFixture("ms-disruptive-unpaused-target-")
verifyMAPIMachineSetSynchronizedState(
fixtureB.mapiMachineSet,
mapiv1beta1.MachineAuthorityMachineAPI,
mapiv1beta1.MachineAPISynchronized,
)
verifyCAPIMachineSetPausedState(fixtureB.capiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)

By("Migrating the unpaused-target rollback fixture to a healthy ClusterAPI steady state before the outage")
switchMachineSetAuthoritativeAPI(fixtureB.mapiMachineSet, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMAPIMachineSetSynchronizedState(
fixtureB.mapiMachineSet,
mapiv1beta1.MachineAuthorityClusterAPI,
mapiv1beta1.ClusterAPISynchronized,
)
verifyMachineSetPausedCondition(fixtureB.mapiMachineSet, mapiv1beta1.MachineAuthorityClusterAPI)
verifyCAPIMachineSetPausedState(fixtureB.capiMachineSet, mapiv1beta1.MachineAuthorityClusterAPI)

By("Reading and validating the outage baseline after both fixtures are prepared")
disruptionStateValue := readAndValidateMachineSetMigrationDisruptionBaseline(ctx, cl)
disruptionState = &disruptionStateValue

By("Marking Deployment/openshift-cluster-api-operator/capi-operator unmanaged through ClusterVersion overrides")
setMachineSetMigrationCAPIOperatorOverride(ctx, cl, true)

By("Creating the shared outage by scaling Deployment/openshift-cluster-api-operator/capi-operator to zero")
scaleDeploymentAndWaitForAvailableReplicas(
ctx,
cl,
capiframework.CAPIOperatorNamespace,
capiOperatorDeploymentName,
0,
)

By("Scaling Deployment/openshift-cluster-api/capi-controller-manager to zero in the same outage window")
scaleDeploymentAndWaitForAvailableReplicas(
ctx,
cl,
capiframework.CAPINamespace,
capiControllerManagerDeploymentName,
0,
)

By("Verifying rollback succeeds during the outage when the target CAPI MachineSet was never observed unpaused")
switchMachineSetAuthoritativeAPI(fixtureA.mapiMachineSet, mapiv1beta1.MachineAuthorityClusterAPI)
verifyMachineSetAuthoritative(fixtureA.mapiMachineSet, mapiv1beta1.MachineAuthorityClusterAPI)
switchMachineSetAuthoritativeAPI(fixtureA.mapiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)
verifyMAPIMachineSetSynchronizedState(
fixtureA.mapiMachineSet,
mapiv1beta1.MachineAuthorityMachineAPI,
mapiv1beta1.MachineAPISynchronized,
)
verifyCAPIMachineSetPausedState(fixtureA.capiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)

By("Requesting rollback during the outage after the target CAPI MachineSet was observed unpaused")
switchMachineSetAuthoritativeAPI(fixtureB.mapiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)

By("Verifying rollback stays pinned at ClusterAPI while the outage persists and the target CAPI MachineSet remains unpaused")
consistentlyVerifyMachineSetRollbackPinnedAtClusterAPI(
fixtureB.mapiMachineSet,
fixtureB.capiMachineSet,
10*time.Second,
)

By("Starting recovery for Deployment/openshift-cluster-api/capi-controller-manager and Deployment/openshift-cluster-api-operator/capi-operator together")
scaleDeployment(
ctx,
cl,
capiframework.CAPINamespace,
capiControllerManagerDeploymentName,
disruptionState.capiControllerManagerReplicas,
)
scaleDeployment(
ctx,
cl,
capiframework.CAPIOperatorNamespace,
capiOperatorDeploymentName,
disruptionState.capiOperatorReplicas,
)

By("Waiting for Deployment/openshift-cluster-api/capi-controller-manager to become healthy after recovery starts")
waitForDeploymentAvailableReplicas(
ctx,
cl,
capiframework.CAPINamespace,
capiControllerManagerDeploymentName,
disruptionState.capiControllerManagerReplicas,
)

By("Waiting for Deployment/openshift-cluster-api-operator/capi-operator to become healthy after recovery starts")
waitForDeploymentAvailableReplicas(
ctx,
cl,
capiframework.CAPIOperatorNamespace,
capiOperatorDeploymentName,
disruptionState.capiOperatorReplicas,
)

if disruptionState.capiOperatorOverrideExpectedAbsent {
By("Removing the targeted ClusterVersion unmanaged override for Deployment/openshift-cluster-api-operator/capi-operator")
setMachineSetMigrationCAPIOperatorOverride(ctx, cl, false)
}

By("Waiting for the Cluster API operator to return to a healthy state after the outage")
waitForClusterAPIOperatorHealthy(ctx, cl)
disruptionStateRestored = true

By("Verifying the already-requested rollback resumes automatically after recovery")
verifyMAPIMachineSetSynchronizedState(
fixtureB.mapiMachineSet,
mapiv1beta1.MachineAuthorityMachineAPI,
mapiv1beta1.MachineAPISynchronized,
)
verifyCAPIMachineSetPausedState(fixtureB.capiMachineSet, mapiv1beta1.MachineAuthorityMachineAPI)
})
})
Loading