Skip to content

WIP: Add test verifies that OLMv1 does not revert user-initiated changes to deployed resources#2512

Open
camilamacedo86 wants to merge 1 commit intooperator-framework:mainfrom
camilamacedo86:test-asked
Open

WIP: Add test verifies that OLMv1 does not revert user-initiated changes to deployed resources#2512
camilamacedo86 wants to merge 1 commit intooperator-framework:mainfrom
camilamacedo86:test-asked

Conversation

@camilamacedo86
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 16, 2026 17:56
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 16, 2026
@netlify
Copy link

netlify bot commented Feb 16, 2026

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 6893e06
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/69935e23dd8c7600087df6aa
😎 Deploy Preview https://deploy-preview-2512--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci
Copy link

openshift-ci bot commented Feb 16, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign grokspawn for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an end-to-end test to verify that OLMv1, when using Server-Side Apply, does not revert user-initiated changes to deployed resources. The test specifically validates the scenario where a user runs kubectl rollout restart deployment, which was problematic in OLMv0. The PR is explicitly marked as Work In Progress (WIP).

Changes:

  • Added new feature file rollout-restart.feature with a scenario testing user-initiated deployment changes
  • Implemented three new step functions: UserAddsRestartAnnotation, ResourceHasRestartAnnotation, and ClusterExtensionAnnotationIsSet

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
test/e2e/features/rollout-restart.feature New feature file defining the test scenario for verifying OLMv1 doesn't revert user-initiated changes to deployments
test/e2e/steps/steps.go Added three new step functions to support the rollout restart test scenario and registered them in the step definitions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 1184 to 1188
parts := strings.Split(resourceName, "/")
if len(parts) != 2 {
return fmt.Errorf("invalid resource name format: %s (expected kind/name)", resourceName)
}
kind := parts[0]
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use strings.Cut instead of strings.Split for parsing resource names in the format "kind/name". This is the established pattern used consistently throughout this codebase, as seen in functions like ResourceAvailable (line 535), ResourceRemoved (line 549), and ResourceEventuallyNotFound (line 569). The strings.Cut function is more appropriate here as it returns a boolean indicating whether the separator was found, allowing for clearer error handling.

Suggested change
parts := strings.Split(resourceName, "/")
if len(parts) != 2 {
return fmt.Errorf("invalid resource name format: %s (expected kind/name)", resourceName)
}
kind := parts[0]
kind, _, ok := strings.Cut(resourceName, "/")
if !ok {
return fmt.Errorf("invalid resource name format: %s (expected kind/name)", resourceName)
}

Copilot uses AI. Check for mistakes.
Comment on lines 1206 to 1237
func ResourceHasRestartAnnotation(ctx context.Context, resourceName string) error {
sc := scenarioCtx(ctx)

// Parse the resource name (format: "deployment/test-operator")
parts := strings.Split(resourceName, "/")
if len(parts) != 2 {
return fmt.Errorf("invalid resource name format: %s (expected kind/name)", resourceName)
}
kind := parts[0]
deploymentName := parts[1]

if kind != "deployment" {
return fmt.Errorf("only deployment resources are supported for restart annotation check, got: %s", kind)
}

// Check for the restart annotation added by kubectl rollout restart
restartAnnotationKey := "kubectl.kubernetes.io/restartedAt"

waitFor(ctx, func() bool {
// Get the restart annotation from the deployment's pod template
out, err := k8sClient("get", "deployment", deploymentName, "-n", sc.namespace,
"-o", fmt.Sprintf("jsonpath={.spec.template.metadata.annotations['%s']}", restartAnnotationKey))
if err != nil {
return false
}

// If the annotation exists and has a value, it persisted
return out != ""
})

return nil
}
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function should apply substituteScenarioVars to the resourceName parameter, consistent with other similar functions in this codebase such as ResourceAvailable, ResourceRemoved, and ResourceEventuallyNotFound. This ensures that template variables are properly substituted before parsing.

Copilot uses AI. Check for mistakes.
Comment on lines 1210 to 1212
parts := strings.Split(resourceName, "/")
if len(parts) != 2 {
return fmt.Errorf("invalid resource name format: %s (expected kind/name)", resourceName)
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use strings.Cut instead of strings.Split for parsing resource names in the format "kind/name". This is the established pattern used consistently throughout this codebase, as seen in functions like ResourceAvailable (line 535), ResourceRemoved (line 549), and ResourceEventuallyNotFound (line 569).

Copilot uses AI. Check for mistakes.
Comment on lines 1180 to 1202
func UserAddsRestartAnnotation(ctx context.Context, resourceName string) error {
sc := scenarioCtx(ctx)

// Parse the resource name (format: "deployment/test-operator")
parts := strings.Split(resourceName, "/")
if len(parts) != 2 {
return fmt.Errorf("invalid resource name format: %s (expected kind/name)", resourceName)
}
kind := parts[0]

if kind != "deployment" {
return fmt.Errorf("only deployment resources are supported for restart annotation, got: %s", kind)
}

// Use kubectl rollout restart to add the restart annotation
// This is the actual command users would run, ensuring we test real-world behavior
_, err := k8sClient("rollout", "restart", resourceName, "-n", sc.namespace)
if err != nil {
return fmt.Errorf("failed to rollout restart %s: %w", resourceName, err)
}

return nil
}
Copy link

Copilot AI Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function should apply substituteScenarioVars to the resourceName parameter, consistent with other similar functions in this codebase such as ResourceAvailable, ResourceRemoved, and ResourceEventuallyNotFound. This ensures that template variables like ${TEST_NAMESPACE} are properly substituted.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant