-
Notifications
You must be signed in to change notification settings - Fork 59
OCPCLOUD-2998: implement synchronizedAPI #376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RadekManak
wants to merge
1
commit into
openshift:main
Choose a base branch
from
RadekManak:synchronizedAPI
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,798
−1,611
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| 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") | ||
| } | ||
|
|
||
|
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) | ||
| }) | ||
| }) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.