← Back to Pull requests

e2e: add test to check the image validation #4693

Merged
shajmakh merged 5 files (179 lines) on Jul 30, 2026 09:59 UTC
View on GitHub
shajmakh shajmakh commented on Jul 20, 2026 07:46 UTC
Author

Add an e2e test to verify the image validation causing the scheduler CR
to be degraded after not complying to the validation criteria.

Diff: 179 lines (+177 / -2) across 5 files Reviewer: Tal-or Review duration: 14533m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.40) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 179 lines diff across 5 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.91 · 5 substantive comment(s)
0.91
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
91%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.311
Real PR Conversation Timeline
38 items
coderabbitai[bot] coderabbitai[bot] commented on Jul 20, 2026 07:46 UTC
Bot

<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->

![Review Change Stack](https://app.coderabbit.ai/change-stack/openshift-kni/numaresources-operator/pull/4693?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)

<!-- review_stack_entry_end -->
<!-- This is an auto-generated comment: review paused by coderabbit.ai -->

[!NOTE]

## Reviews paused

> It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

> Use the following commands to manage reviews:

- @coderabbitai resume to resume automatic reviews.

- @coderabbitai review to trigger a single review.

> Use the checkboxes below for quick actions:

- [ ] <!-- {"checkboxId": "7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> ▶️ Resume reviews

- [ ] <!-- {"checkboxId": "e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review

<!-- end of auto-generated comment: review paused by coderabbit.ai -->
<!-- walkthrough_start -->

<details>
<summary>📝 Walkthrough</summary>

Walkthrough

Adds a scheduler image validation E2E suite covering invalid and untrusted images, validation overrides, and status transitions. The Makefile builds the new test binary and getdigests, while the E2E runner executes the validation suite and records JUnit output.

Changes

Scheduler image validation e2e coverage

|Layer / File(s)|Summary|
|---|---|
|Scheduler image validation test flow <br> test/e2e/sched/image_validation/*, test/internal/envvar/envvar.go|Adds suite initialization and validates degraded, available, and cleanup states for invalid scheduler images and validation overrides. Polling uses the per-iteration context.|
|Scheduler validation binary and runner wiring <br> Makefile, hack/run-test-e2e.sh|Builds the scheduler image validation and getdigests binaries, then runs the validation suite when scheduler tests are enabled.|

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: mrniranjan, yanirq

Sequence Diagram(s)

sequenceDiagram
  participant E2ETest
  participant NUMAResourcesScheduler
  participant Operator
  participant Deployment
  E2ETest->>NUMAResourcesScheduler: Set invalid scheduler image
  NUMAResourcesScheduler-->>E2ETest: Report InvalidSchedulerImage degradation
  E2ETest->>NUMAResourcesScheduler: Set untrusted digest-pinned image
  NUMAResourcesScheduler-->>E2ETest: Report InvalidSchedulerImage degradation
  E2ETest->>Operator: Set allowed scheduler image digest
  Operator->>Deployment: Roll out updated environment
  E2ETest->>NUMAResourcesScheduler: Recheck scheduler status
  NUMAResourcesScheduler-->>E2ETest: Report available and not degraded

</details>

<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->

<details>
<summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary>

❌ Failed checks (1 warning)

| Check name | Status | Explanation | Resolution |
| :----------------: | :--------- | :----------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 8.51% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |

<details>
<summary>✅ Passed checks (4 passed)</summary>

| Check name | Status | Explanation |
| :------------------------: | :------- | :--------------------------------------------------------------------------------------------------------- |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Title check | ✅ Passed | The title clearly summarizes the main change: adding an e2e image validation test. |
| Description check | ✅ Passed | The description is directly related to the change and matches the new scheduler image validation e2e test. |

</details>

</details>

<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

<details>
<summary>🧪 Generate unit tests (beta)</summary>

  • <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests
  • </details>

    </details>

    <!-- finishing_touch_checkbox_end -->
    <!-- tips_start -->

    ---

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    <details>
    <summary>❤️ Share</summary>

  • X

  • Mastodon

  • Reddit

  • LinkedIn
  • </details>

    <sub>Comment @coderabbitai help to get the list of available commands.</sub>

    <!-- tips_end -->

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 20, 2026 07:55 UTC
    Code Review
    test/e2e/must-gather/must_gather_suite_test.go:1
    @@ -81,7 +84,23 @@ var _ = BeforeSuite(func() {
     
     	deployment = deploy.NewForPlatform(configuration.Plat)
     	_ = deployment.Deploy(ctx, configuration.MachineConfigPoolUpdateTimeout) // we don't care about the nrop instance
    +
    +	if !e2esched.IsSchedulerImageValidationEnabled() {
    +		// for e2e verification we disable the image validation because handling pulling images in the CI from the
    +		// production registry is troublesome, and so is handling changing the digests on each branch. Testing e2e
    +		// for the image validation will be handled in a separate test.
    +		By("identify the source of operator installation and disable scheduler image validation")
    +		var err error
    +		restoreFunc, err := e2eenvvar.SetOperatorEnvVar(ctx, e2eclient.Client, intsched.SchedulerImageValidationEnvVar, "false")
    +		Expect(err).NotTo(HaveOccurred())
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			By("restoring scheduler image validation settings")
    +			Expect(restoreFunc(cleanupCtx)).To(Succeed())
    +		})
    +	}

    _📐 Maintainability & Code Quality_ | _🟠 Major_ | _⚡ Quick win_

    Disable-validation boilerplate is duplicated near-verbatim across five suite setup files. Each suite repeats the same "if not validation-enabled → SetOperatorEnvVar(..., 'false') → assert → DeferCleanup restore" block; consolidating into one shared helper (e.g. in test/internal/envvar or test/internal/nrosched) taking (ctx, cli) and internally registering the DeferCleanup would remove the duplication and prevent future drift between suites.

  • test/e2e/must-gather/must_gather_suite_test.go#L88-L100: replace this block with a call to the shared helper.

  • test/e2e/sched/install/test_suite_install_test.go#L41-L53: replace this block with a call to the shared helper.

  • test/e2e/sched/uninstall/test_suite_uninstall_test.go#L41-L53: replace this block with a call to the shared helper.

  • test/e2e/serial/e2e_serial_test.go#L53-L65: replace this block with a call to the shared helper.

  • test/e2e/sched/test_suite_sched_test.go#L39-L57: fold suiteSchedValidationSetup and its surrounding if/DeferCleanup into the same shared helper instead of a package-local partial extraction.
  • <details>
    <summary>📍 Affects 5 files</summary>

  • test/e2e/must-gather/must_gather_suite_test.go#L88-L100 (this comment)

  • test/e2e/sched/install/test_suite_install_test.go#L41-L53

  • test/e2e/sched/uninstall/test_suite_uninstall_test.go#L41-L53

  • test/e2e/serial/e2e_serial_test.go#L53-L65

  • test/e2e/sched/test_suite_sched_test.go#L39-L57
  • </details>

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@test/e2e/must-gather/must_gather_suite_test.go` around lines 88 - 100,
    Introduce one shared helper that accepts ctx and the Kubernetes client, checks
    IsSchedulerImageValidationEnabled, disables validation via SetOperatorEnvVar,
    asserts success, and registers cleanup to restore it. Replace the duplicated
    blocks in test/e2e/must-gather/must_gather_suite_test.go#L88-L100,
    test/e2e/sched/install/test_suite_install_test.go#L41-L53,
    test/e2e/sched/uninstall/test_suite_uninstall_test.go#L41-L53, and
    test/e2e/serial/e2e_serial_test.go#L53-L65 with calls to that helper; in
    test/e2e/sched/test_suite_sched_test.go#L39-L57, remove
    suiteSchedValidationSetup and its surrounding setup/cleanup in favor of the same
    helper.
    

    </details>

    <!-- consolidated_sites_start -->
    <!--
    <consolidated_sites>
    <site>
    <role>anchor</role>
    <file>test/e2e/must-gather/must_gather_suite_test.go</file>
    <line_range>88-100</line_range>
    </site>
    <site>
    <role>sibling</role>
    <file>test/e2e/sched/install/test_suite_install_test.go</file>
    <line_range>41-53</line_range>
    </site>
    <site>
    <role>sibling</role>
    <file>test/e2e/sched/uninstall/test_suite_uninstall_test.go</file>
    <line_range>41-53</line_range>
    </site>
    <site>
    <role>sibling</role>
    <file>test/e2e/serial/e2e_serial_test.go</file>
    <line_range>53-65</line_range>
    </site>
    <site>
    <role>sibling</role>
    <file>test/e2e/sched/test_suite_sched_test.go</file>
    <line_range>39-57</line_range>
    </site>
    </consolidated_sites>
    -->
    <!-- consolidated_sites_end -->

    <!-- fingerprinting:phantom:medusa:beignet -->

    <!-- cr-indicator-types:refactor_suggestion -->

    <!-- cr-comment:v1:652a985b26f2017231d9b284 -->

    <!-- This is an auto-generated reply by CodeRabbit -->

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 20, 2026 07:55 UTC
    Code Review
    test/e2e/sched/sched_test.go:1
    @@ -136,6 +136,42 @@ var _ = Describe("[Scheduler] scheduler object updates", func() {
     			Expect(err).ToNot(HaveOccurred())
     		})
     
    +		It("should degrade status when scheduler image is invalid and validation is enabled", func(ctx context.Context) {
    +			// intentionally ignore the restore function because when the test fails and ginkgo retries it,
    +			// the restore function will be pointing to inacurate values. Thus we do the defer cleanup
    +			// based on the suite setup.
    +			_, err := e2eenvvar.SetOperatorEnvVar(ctx, e2eclient.Client, scheduler.SchedulerImageValidationEnvVar, "true")
    +			Expect(err).NotTo(HaveOccurred())
    +			// eventhough BeforeEach handles the restoration of the environment variable to the initial state, we need to restore it here
    +			// because we don't want to depend on the order of the cleanup functions in BeforeEach.
    +			DeferCleanup(func(cleanupCtx context.Context) {
    +				if !e2esched.IsSchedulerImageValidationEnabled() {
    +					_, err := suiteSchedValidationSetup(ctx, e2eclient.Client)
    +					Expect(err).NotTo(HaveOccurred())
    +				}
    +			})
    +
    +			testSchedObj := &nropv1.NUMAResourcesScheduler{}
    +			e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria", e2eimages.SchedTestImageCI)
    +			Eventually(func(g Gomega) {
    +				g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    +				testSchedObj.Spec.SchedulerImage = e2eimages.SchedTestImageCI
    +				g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +			Eventually(func(g Gomega) {
    +				g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    +				klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +				degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +				g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +				g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +				g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +			}).WithTimeout(3 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +			// BeforeEach handles the restoration of the scheduler spec to the initial state
    +		})
    +

    _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_

    DeferCleanup restores validation using the stale outer ctx instead of cleanupCtx.

    Line 149 calls suiteSchedValidationSetup(ctx, e2eclient.Client) inside the DeferCleanup(func(cleanupCtx context.Context) {...}) closure, but uses the captured outer ctx rather than the supplied cleanupCtx. If the spec's context is already cancelled or past its deadline when cleanup runs (e.g. on failure/timeout — the exact scenario this cleanup exists to handle robustly), the restore call can fail with a cancelled context, leaving scheduler image validation enabled for subsequent specs/suites.

    <details>
    <summary>🐛 Proposed fix</summary>

     			DeferCleanup(func(cleanupCtx context.Context) {
     				if !e2esched.IsSchedulerImageValidationEnabled() {
    -					_, err := suiteSchedValidationSetup(ctx, e2eclient.Client)
    +					_, err := suiteSchedValidationSetup(cleanupCtx, e2eclient.Client)
     					Expect(err).NotTo(HaveOccurred())
     				}
     			})
    

    </details>

    <!-- suggestion_start -->

    <details>
    <summary>📝 Committable suggestion</summary>

    ‼️ IMPORTANT

    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    		It("should degrade status when scheduler image is invalid and validation is enabled", func(ctx context.Context) {
    			// intentionally ignore the restore function because when the test fails and ginkgo retries it,
    			// the restore function will be pointing to inacurate values. Thus we do the defer cleanup
    			// based on the suite setup.
    			_, err := e2eenvvar.SetOperatorEnvVar(ctx, e2eclient.Client, scheduler.SchedulerImageValidationEnvVar, "true")
    			Expect(err).NotTo(HaveOccurred())
    			// eventhough BeforeEach handles the restoration of the environment variable to the initial state, we need to restore it here
    			// because we don't want to depend on the order of the cleanup functions in BeforeEach.
    			DeferCleanup(func(cleanupCtx context.Context) {
    				if !e2esched.IsSchedulerImageValidationEnabled() {
    					_, err := suiteSchedValidationSetup(cleanupCtx, e2eclient.Client)
    					Expect(err).NotTo(HaveOccurred())
    				}
    			})
    
    			testSchedObj := &nropv1.NUMAResourcesScheduler{}
    			e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria", e2eimages.SchedTestImageCI)
    			Eventually(func(g Gomega) {
    				g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    				testSchedObj.Spec.SchedulerImage = e2eimages.SchedTestImageCI
    				g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    
    			Eventually(func(g Gomega) {
    				g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    				klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    
    				degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    				g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    				g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    				g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    			}).WithTimeout(3 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    
    			// BeforeEach handles the restoration of the scheduler spec to the initial state
    		})
    

    </details>

    <!-- suggestion_end -->

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@test/e2e/sched/sched_test.go` around lines 139 - 174, Update the DeferCleanup
    closure in the scheduler image validation test to pass cleanupCtx, not the
    captured ctx, to suiteSchedValidationSetup when restoring validation. Keep the
    existing conditional restoration and error assertion unchanged.
    

    </details>

    <!-- fingerprinting:phantom:medusa:beignet -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:f5d2e1bac23c3e5480d2f262 -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits 0210ab7 to b2e74d5

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 20, 2026 07:55 UTC
    Code Review
    test/internal/envvar/envvar.go:1
    @@ -0,0 +1,480 @@
    +/*
    + * 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 envvar
    +
    +import (
    +	"context"
    +	"fmt"
    +	"os"
    +	"reflect"
    +	"slices"
    +	"sort"
    +	"strings"
    +	"time"
    +
    +	appsv1 "k8s.io/api/apps/v1"
    +	corev1 "k8s.io/api/core/v1"
    +	"k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
    +	"k8s.io/apimachinery/pkg/runtime/schema"
    +	"k8s.io/apimachinery/pkg/types"
    +	k8swait "k8s.io/apimachinery/pkg/util/wait"
    +	"k8s.io/client-go/util/retry"
    +	"k8s.io/klog/v2"
    +
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +
    +	"github.com/openshift-kni/numaresources-operator/internal/podlist"
    +	"github.com/openshift-kni/numaresources-operator/internal/wait"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/consts"
    +)
    +
    +var subscriptionGVK = schema.GroupVersionKind{
    +	Group:   "operators.coreos.com",
    +	Version: "v1alpha1",
    +	Kind:    "Subscription",
    +}
    +
    +type RestoreFunc func(ctx context.Context) error
    +
    +var noOpRestoreFunc RestoreFunc = func(ctx context.Context) error { return nil }
    +
    +// SetOperatorEnvVar sets envName to envValue on the operator's OLM subscription when present,
    +// otherwise on the manager container in the operator deployment. It returns a restore function.
    +func SetOperatorEnvVar(ctx context.Context, cli client.Client, envName, envValue string) (RestoreFunc, error) {
    +	dp, err := findOperatorDeployment(ctx, cli)
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	sub, err := findOperatorSubscription(ctx, cli, dp.Namespace)
    +	if err == nil {
    +		klog.InfoS("setting operator env via OLM subscription", "name", sub.GetName(), "namespace", sub.GetNamespace(), "env", envName, "value", envValue)
    +		return setOperatorEnvViaSubscription(ctx, cli, sub, envName, envValue)
    +	}
    +	if !errors.IsNotFound(err) {
    +		return nil, err
    +	}
    +
    +	klog.InfoS("setting operator env via operator deployment", "name", dp.Name, "namespace", dp.Namespace, "env", envName, "value", envValue)
    +	return setOperatorEnvViaDeployment(ctx, cli, dp, envName, envValue)
    +}
    +
    +func findOperatorSubscription(ctx context.Context, cli client.Client, fromNamespace string) (*unstructured.Unstructured, error) {
    +	subList := &unstructured.UnstructuredList{}
    +	subList.SetGroupVersionKind(subscriptionGVK.GroupVersion().WithKind("SubscriptionList"))
    +
    +	if err := cli.List(ctx, subList, client.InNamespace(fromNamespace)); err != nil {
    +		return nil, err
    +	}
    +
    +	// use the subscription name option if set for more flexxibility and debugging purposes
    +	subName := os.Getenv("E2E_OPERATOR_SUBSCRIPTION_NAME")
    +	if subName != "" {
    +		for i := range subList.Items {
    +			if subList.Items[i].GetName() == subName {
    +				return subList.Items[i].DeepCopy(), nil
    +			}
    +		}
    +	}
    +
    +	// in case the subscription name is not set, we pick the subscription that has the correct package name based
    +	// on the subscription spec. Some OLM installations configures the only one of either the package or the name,
    +	// but either way they have similar value.
    +	for i := range subList.Items {
    +		pkg, pkgFound, pkgErr := unstructured.NestedString(subList.Items[i].Object, "spec", "package")
    +		name, nameFound, nameErr := unstructured.NestedString(subList.Items[i].Object, "spec", "name")
    +		if pkgErr != nil && nameErr != nil {
    +			return nil, fmt.Errorf("failed to get package or name from subscription: pkgErr=%v nameErr=%v sub=%v", pkgErr, nameErr, subList.Items[i].Object)
    +		}
    +		if pkgFound {
    +			if pkg == consts.SubscriptionSpecNamePackage {
    +				return subList.Items[i].DeepCopy(), nil
    +			}
    +		}
    +		if nameFound {
    +			if name == consts.SubscriptionSpecNamePackage {
    +				return subList.Items[i].DeepCopy(), nil
    +			}
    +		}
    +	}
    +	klog.InfoS("no subscription found with the correct package name", "subscriptions", subList.Items)
    +	return nil, errors.NewNotFound(schema.GroupResource{Group: subscriptionGVK.Group, Resource: "subscriptions"}, subName)
    +}
    +
    +func findOperatorDeployment(ctx context.Context, cli client.Client) (*appsv1.Deployment, error) {
    +	dpList := &appsv1.DeploymentList{}
    +	if err := cli.List(ctx, dpList, client.MatchingLabels(consts.OperatorDeploymentLabels)); err != nil {
    +		return nil, err
    +	}
    +
    +	for i := range dpList.Items {
    +		dp := &dpList.Items[i]
    +		if dp.Name != consts.OperatorDeploymentName {
    +			continue
    +		}
    +
    +		return dp, nil
    +	}
    +	return nil, errors.NewNotFound(schema.GroupResource{Group: appsv1.SchemeGroupVersion.Group, Resource: "deployments"}, consts.OperatorDeploymentName)
    +}
    +
    +func setOperatorEnvViaSubscription(ctx context.Context, cli client.Client, sub *unstructured.Unstructured, envName, envValue string) (RestoreFunc, error) {
    +	dpKey := client.ObjectKey{Namespace: sub.GetNamespace(), Name: consts.OperatorDeploymentName}
    +	initialDp, initialPods, err := getPodsForDeployment(ctx, cli, dpKey)
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	subKey := client.ObjectKeyFromObject(sub)
    +	current := &unstructured.Unstructured{}
    +	current.SetGroupVersionKind(subscriptionGVK)
    +	if err := cli.Get(ctx, subKey, current); err != nil {
    +		return nil, err
    +	}
    +	originalEnv, err := getSubscriptionEnv(current)
    +	if err != nil {
    +		return nil, err
    +	}
    +	klog.InfoS("original env", "env", originalEnv)
    +
    +	klog.InfoS("checking if the env is already set")
    +	originalEnvVars := toEnvVars(originalEnv)
    +	if slices.ContainsFunc(originalEnvVars, func(env corev1.EnvVar) bool {
    +		return env.Name == envName && env.Value == envValue
    +	}) {
    +		klog.InfoS("env is already set", "env", envName, "value", envValue)
    +		return noOpRestoreFunc, nil
    +	}
    +
    +	updatedEnv := buildSubscriptionWithNewEnvVal(originalEnv, envName, envValue)
    +	klog.InfoS("updated env", "env", updatedEnv)
    +	// TODO: extract this to a function and use it in creating the restore function
    +	if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
    +		current := &unstructured.Unstructured{}
    +		current.SetGroupVersionKind(subscriptionGVK)
    +		if err := cli.Get(ctx, subKey, current); err != nil {
    +			return err
    +		}
    +		if err := setSubscriptionEnv(current, updatedEnv); err != nil {
    +			return err
    +		}
    +		return cli.Update(ctx, current)
    +	}); err != nil {
    +		return nil, err
    +	}
    +	if err := ensureSubscriptionIsUpdated(ctx, cli, subKey, updatedEnv); err != nil {
    +		return nil, err
    +	}
    +	if err := waitForDeploymentRolloutAfterSubscriptionUpdate(ctx, cli, initialDp, initialPods, []corev1.EnvVar{{Name: envName, Value: envValue}}); err != nil {
    +		return nil, err
    +	}
    +
    +	return func(ctx context.Context) error {
    +		dp, pods, err := getPodsForDeployment(ctx, cli, dpKey)
    +		if err != nil {
    +			return fmt.Errorf("failed to get deployment details for restore: err=%v", err)
    +		}
    +
    +		klog.InfoS("restoring subscription env", "env", originalEnv)
    +		current := &unstructured.Unstructured{}
    +		if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
    +			current.SetGroupVersionKind(subscriptionGVK)
    +			if err := cli.Get(ctx, subKey, current); err != nil {
    +				return err
    +			}
    +			if err := setSubscriptionEnv(current, originalEnv); err != nil {
    +				return err
    +			}
    +			return cli.Update(ctx, current)
    +		}); err != nil {
    +			return fmt.Errorf("failed to update subscription during restore: err=%v", err)
    +		}
    +		if err := ensureSubscriptionIsUpdated(ctx, cli, subKey, originalEnv); err != nil {
    +			return err
    +		}
    +		return waitForDeploymentRolloutAfterSubscriptionUpdate(ctx, cli, dp, pods, originalEnvVars)
    +	}, nil
    +}
    +
    +func setOperatorEnvViaDeployment(ctx context.Context, cli client.Client, dp *appsv1.Deployment, envName, envValue string) (RestoreFunc, error) {
    +	dpKey := client.ObjectKeyFromObject(dp)
    +	current := &appsv1.Deployment{}
    +	if err := cli.Get(ctx, dpKey, current); err != nil {
    +		return nil, err
    +	}
    +	initialDp := current.DeepCopy()
    +	klog.InfoS("initial env", "env", toString(initialDp.Spec.Template.Spec.Containers[0].Env))
    +	mngContainerIdx := -1
    +	for idx := range dp.Spec.Template.Spec.Containers {
    +		if dp.Spec.Template.Spec.Containers[idx].Name == consts.OperatorManagerContainer {
    +			mngContainerIdx = idx
    +			break
    +		}
    +	}
    +	if mngContainerIdx == -1 {
    +		return nil, errors.NewNotFound(schema.GroupResource{Group: appsv1.SchemeGroupVersion.Group, Resource: "containers"}, consts.OperatorManagerContainer)
    +	}
    +	mngContainer := initialDp.Spec.Template.Spec.Containers[mngContainerIdx].DeepCopy()
    +	updated := false
    +	for i := range mngContainer.Env {
    +		if mngContainer.Env[i].Name == envName {
    +			if mngContainer.Env[i].Value == envValue {
    +				klog.InfoS("env is already set", "env", envName, "value", envValue)
    +				return noOpRestoreFunc, nil
    +			}
    +			mngContainer.Env[i].Value = envValue
    +			updated = true
    +			break
    +		}
    +	}
    +	if !updated {
    +		mngContainer.Env = append(mngContainer.Env, corev1.EnvVar{Name: envName, Value: envValue})
    +	}
    +	if err := updateDeploymentContainerAndWaitForRollout(ctx, cli, dpKey, mngContainerIdx, mngContainer); err != nil {
    +		return nil, err
    +	}
    +
    +	return func(ctx context.Context) error {
    +		return updateDeploymentContainerAndWaitForRollout(ctx, cli, dpKey, mngContainerIdx, initialDp.Spec.Template.Spec.Containers[mngContainerIdx].DeepCopy())
    +	}, nil
    +}
    +
    +func getPodsForDeployment(ctx context.Context, cli client.Client, dpKey client.ObjectKey) (*appsv1.Deployment, []corev1.Pod, error) {
    +	klog.InfoS("getting deployment pods", "key", dpKey.String())
    +	dp := &appsv1.Deployment{}
    +	if err := cli.Get(ctx, dpKey, dp); err != nil {
    +		return nil, nil, err
    +	}
    +	pods, err := podlist.With(cli).ByDeployment(ctx, *dp)
    +	if len(pods) == 0 || err != nil {
    +		return nil, nil, fmt.Errorf("failed to get deployment pods: err=%v pods=%v", err, pods)
    +	}
    +	return dp, pods, nil
    +}
    +
    +func waitForDeploymentRolloutAfterSubscriptionUpdate(ctx context.Context, cli client.Client, dp *appsv1.Deployment, initialPods []corev1.Pod, expectedEnvVarValues []corev1.EnvVar) error {
    +	// Sometimes OLM fails to immediately update the deployment with the new env value,
    +	// so we workaround this by explicitly deleting the deployment. Note that recreating
    +	// the deployment can also take some time, being affected by the OLM rollout behavior,
    +	// hence we give long enough time for its recreation.
    +	klog.Info("deleting deployment")
    +	if err := cli.Delete(ctx, dp); err != nil {
    +		return err
    +	}
    +
    +	err := k8swait.PollUntilContextTimeout(ctx, 10*time.Second, 15*time.Minute, true, func(aContext context.Context) (bool, error) {
    +		if err := cli.Get(ctx, client.ObjectKeyFromObject(dp), dp); err != nil {
    +			klog.Warningf("failed getting the deployment %s: %v", dp.Name, err)
    +			return false, nil
    +		}
    +		return true, nil
    +	})
    +	if err != nil {
    +		return fmt.Errorf("failed to wait for deployment to be recreated: err=%v", err)
    +	}
    +	return waitForDeploymentRollout(ctx, cli, dp, initialPods, expectedEnvVarValues)
    +}

    _🩺 Stability & Availability_ | _🟡 Minor_ | _⚡ Quick win_

    Poll callback ignores aContext, using stale outer ctx instead.

    The PollUntilContextTimeout callback parameter aContext is unused; the Get call on line 281 uses the outer ctx. The sibling loop in waitForDeploymentRollout (line 322) correctly uses aContext. This is inconsistent and means the per-attempt Get doesn't respect the poll's own derived context.

    <details>
    <summary>🔧 Proposed fix</summary>

     	err := k8swait.PollUntilContextTimeout(ctx, 10*time.Second, 15*time.Minute, true, func(aContext context.Context) (bool, error) {
    -		if err := cli.Get(ctx, client.ObjectKeyFromObject(dp), dp); err != nil {
    +		if err := cli.Get(aContext, client.ObjectKeyFromObject(dp), dp); err != nil {
     			klog.Warningf("failed getting the deployment %s: %v", dp.Name, err)
     			return false, nil
     		}
     		return true, nil
     	})
    

    </details>

    <!-- suggestion_start -->

    <details>
    <summary>📝 Committable suggestion</summary>

    ‼️ IMPORTANT

    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    func waitForDeploymentRolloutAfterSubscriptionUpdate(ctx context.Context, cli client.Client, dp *appsv1.Deployment, initialPods []corev1.Pod, expectedEnvVarValues []corev1.EnvVar) error {
    	// Sometimes OLM fails to immediately update the deployment with the new env value,
    	// so we workaround this by explicitly deleting the deployment. Note that recreating
    	// the deployment can also take some time, being affected by the OLM rollout behavior,
    	// hence we give long enough time for its recreation.
    	klog.Info("deleting deployment")
    	if err := cli.Delete(ctx, dp); err != nil {
    		return err
    	}
    
    	err := k8swait.PollUntilContextTimeout(ctx, 10*time.Second, 15*time.Minute, true, func(aContext context.Context) (bool, error) {
    		if err := cli.Get(aContext, client.ObjectKeyFromObject(dp), dp); err != nil {
    			klog.Warningf("failed getting the deployment %s: %v", dp.Name, err)
    			return false, nil
    		}
    		return true, nil
    	})
    	if err != nil {
    		return fmt.Errorf("failed to wait for deployment to be recreated: err=%v", err)
    	}
    	return waitForDeploymentRollout(ctx, cli, dp, initialPods, expectedEnvVarValues)
    }
    

    </details>

    <!-- suggestion_end -->

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@test/internal/envvar/envvar.go` around lines 270 - 291, Update the
    PollUntilContextTimeout callback in
    waitForDeploymentRolloutAfterSubscriptionUpdate to use its aContext parameter
    for the cli.Get call instead of the outer ctx. Preserve the existing retry and
    error-handling behavior.
    

    </details>

    <!-- fingerprinting:phantom:medusa:beignet -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:f6c2bbacf1388a304b6447bd -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits 535e436 to 9e92094

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 20, 2026 07:55 UTC
    Code Review
    test/internal/envvar/envvar.go:1
    @@ -0,0 +1,480 @@
    +/*
    + * 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 envvar
    +
    +import (
    +	"context"
    +	"fmt"
    +	"os"
    +	"reflect"
    +	"slices"
    +	"sort"
    +	"strings"
    +	"time"
    +
    +	appsv1 "k8s.io/api/apps/v1"
    +	corev1 "k8s.io/api/core/v1"
    +	"k8s.io/apimachinery/pkg/api/errors"
    +	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
    +	"k8s.io/apimachinery/pkg/runtime/schema"
    +	"k8s.io/apimachinery/pkg/types"
    +	k8swait "k8s.io/apimachinery/pkg/util/wait"
    +	"k8s.io/client-go/util/retry"
    +	"k8s.io/klog/v2"
    +
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +
    +	"github.com/openshift-kni/numaresources-operator/internal/podlist"
    +	"github.com/openshift-kni/numaresources-operator/internal/wait"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/consts"
    +)
    +
    +var subscriptionGVK = schema.GroupVersionKind{
    +	Group:   "operators.coreos.com",
    +	Version: "v1alpha1",
    +	Kind:    "Subscription",
    +}
    +
    +type RestoreFunc func(ctx context.Context) error
    +
    +var noOpRestoreFunc RestoreFunc = func(ctx context.Context) error { return nil }
    +
    +// SetOperatorEnvVar sets envName to envValue on the operator's OLM subscription when present,
    +// otherwise on the manager container in the operator deployment. It returns a restore function.
    +func SetOperatorEnvVar(ctx context.Context, cli client.Client, envName, envValue string) (RestoreFunc, error) {
    +	dp, err := findOperatorDeployment(ctx, cli)
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	sub, err := findOperatorSubscription(ctx, cli, dp.Namespace)
    +	if err == nil {
    +		klog.InfoS("setting operator env via OLM subscription", "name", sub.GetName(), "namespace", sub.GetNamespace(), "env", envName, "value", envValue)
    +		return setOperatorEnvViaSubscription(ctx, cli, sub, envName, envValue)
    +	}
    +	if !errors.IsNotFound(err) {
    +		return nil, err
    +	}
    +
    +	klog.InfoS("setting operator env via operator deployment", "name", dp.Name, "namespace", dp.Namespace, "env", envName, "value", envValue)
    +	return setOperatorEnvViaDeployment(ctx, cli, dp, envName, envValue)
    +}
    +
    +func findOperatorSubscription(ctx context.Context, cli client.Client, fromNamespace string) (*unstructured.Unstructured, error) {
    +	subList := &unstructured.UnstructuredList{}
    +	subList.SetGroupVersionKind(subscriptionGVK.GroupVersion().WithKind("SubscriptionList"))
    +
    +	if err := cli.List(ctx, subList, client.InNamespace(fromNamespace)); err != nil {
    +		return nil, err
    +	}
    +
    +	// use the subscription name option if set for more flexxibility and debugging purposes
    +	subName := os.Getenv("E2E_OPERATOR_SUBSCRIPTION_NAME")
    +	if subName != "" {
    +		for i := range subList.Items {
    +			if subList.Items[i].GetName() == subName {
    +				return subList.Items[i].DeepCopy(), nil
    +			}
    +		}
    +	}
    +
    +	// in case the subscription name is not set, we pick the subscription that has the correct package name based
    +	// on the subscription spec. Some OLM installations configures the only one of either the package or the name,
    +	// but either way they have similar value.
    +	for i := range subList.Items {
    +		pkg, pkgFound, pkgErr := unstructured.NestedString(subList.Items[i].Object, "spec", "package")
    +		name, nameFound, nameErr := unstructured.NestedString(subList.Items[i].Object, "spec", "name")
    +		if pkgErr != nil && nameErr != nil {
    +			return nil, fmt.Errorf("failed to get package or name from subscription: pkgErr=%v nameErr=%v sub=%v", pkgErr, nameErr, subList.Items[i].Object)
    +		}
    +		if pkgFound {
    +			if pkg == consts.SubscriptionSpecNamePackage {
    +				return subList.Items[i].DeepCopy(), nil
    +			}
    +		}
    +		if nameFound {
    +			if name == consts.SubscriptionSpecNamePackage {
    +				return subList.Items[i].DeepCopy(), nil
    +			}
    +		}
    +	}
    +	klog.InfoS("no subscription found with the correct package name", "subscriptions", subList.Items)
    +	return nil, errors.NewNotFound(schema.GroupResource{Group: subscriptionGVK.Group, Resource: "subscriptions"}, subName)
    +}
    +
    +func findOperatorDeployment(ctx context.Context, cli client.Client) (*appsv1.Deployment, error) {
    +	dpList := &appsv1.DeploymentList{}
    +	if err := cli.List(ctx, dpList, client.MatchingLabels(consts.OperatorDeploymentLabels)); err != nil {
    +		return nil, err
    +	}
    +
    +	for i := range dpList.Items {
    +		dp := &dpList.Items[i]
    +		if dp.Name != consts.OperatorDeploymentName {
    +			continue
    +		}
    +
    +		return dp, nil
    +	}
    +	return nil, errors.NewNotFound(schema.GroupResource{Group: appsv1.SchemeGroupVersion.Group, Resource: "deployments"}, consts.OperatorDeploymentName)
    +}
    +
    +func setOperatorEnvViaSubscription(ctx context.Context, cli client.Client, sub *unstructured.Unstructured, envName, envValue string) (RestoreFunc, error) {
    +	dpKey := client.ObjectKey{Namespace: sub.GetNamespace(), Name: consts.OperatorDeploymentName}
    +	initialDp, initialPods, err := getPodsForDeployment(ctx, cli, dpKey)
    +	if err != nil {
    +		return nil, err
    +	}
    +
    +	subKey := client.ObjectKeyFromObject(sub)
    +	current := &unstructured.Unstructured{}
    +	current.SetGroupVersionKind(subscriptionGVK)
    +	if err := cli.Get(ctx, subKey, current); err != nil {
    +		return nil, err
    +	}
    +	originalEnv, err := getSubscriptionEnv(current)
    +	if err != nil {
    +		return nil, err
    +	}
    +	klog.InfoS("original env", "env", originalEnv)
    +
    +	klog.InfoS("checking if the env is already set")
    +	originalEnvVars := toEnvVars(originalEnv)
    +	if slices.ContainsFunc(originalEnvVars, func(env corev1.EnvVar) bool {
    +		return env.Name == envName && env.Value == envValue
    +	}) {
    +		klog.InfoS("env is already set", "env", envName, "value", envValue)
    +		return noOpRestoreFunc, nil
    +	}
    +
    +	updatedEnv := buildSubscriptionWithNewEnvVal(originalEnv, envName, envValue)
    +	klog.InfoS("updated env", "env", updatedEnv)
    +	// TODO: extract this to a function and use it in creating the restore function
    +	if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
    +		current := &unstructured.Unstructured{}
    +		current.SetGroupVersionKind(subscriptionGVK)
    +		if err := cli.Get(ctx, subKey, current); err != nil {
    +			return err
    +		}
    +		if err := setSubscriptionEnv(current, updatedEnv); err != nil {
    +			return err
    +		}
    +		return cli.Update(ctx, current)
    +	}); err != nil {
    +		return nil, err
    +	}
    +	if err := ensureSubscriptionIsUpdated(ctx, cli, subKey, updatedEnv); err != nil {
    +		return nil, err
    +	}
    +	if err := waitForDeploymentRolloutAfterSubscriptionUpdate(ctx, cli, initialDp, initialPods, []corev1.EnvVar{{Name: envName, Value: envValue}}); err != nil {
    +		return nil, err
    +	}
    +
    +	return func(ctx context.Context) error {
    +		dp, pods, err := getPodsForDeployment(ctx, cli, dpKey)
    +		if err != nil {
    +			return fmt.Errorf("failed to get deployment details for restore: err=%v", err)
    +		}
    +
    +		klog.InfoS("restoring subscription env", "env", originalEnv)
    +		current := &unstructured.Unstructured{}
    +		if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
    +			current.SetGroupVersionKind(subscriptionGVK)
    +			if err := cli.Get(ctx, subKey, current); err != nil {
    +				return err
    +			}
    +			if err := setSubscriptionEnv(current, originalEnv); err != nil {
    +				return err
    +			}
    +			return cli.Update(ctx, current)
    +		}); err != nil {
    +			return fmt.Errorf("failed to update subscription during restore: err=%v", err)
    +		}
    +		if err := ensureSubscriptionIsUpdated(ctx, cli, subKey, originalEnv); err != nil {
    +			return err
    +		}
    +		return waitForDeploymentRolloutAfterSubscriptionUpdate(ctx, cli, dp, pods, originalEnvVars)
    +	}, nil
    +}
    +
    +func setOperatorEnvViaDeployment(ctx context.Context, cli client.Client, dp *appsv1.Deployment, envName, envValue string) (RestoreFunc, error) {
    +	dpKey := client.ObjectKeyFromObject(dp)
    +	current := &appsv1.Deployment{}
    +	if err := cli.Get(ctx, dpKey, current); err != nil {
    +		return nil, err
    +	}
    +	initialDp := current.DeepCopy()
    +	klog.InfoS("initial env", "env", toString(initialDp.Spec.Template.Spec.Containers[0].Env))
    +	mngContainerIdx := -1
    +	for idx := range dp.Spec.Template.Spec.Containers {
    +		if dp.Spec.Template.Spec.Containers[idx].Name == consts.OperatorManagerContainer {
    +			mngContainerIdx = idx
    +			break
    +		}
    +	}
    +	if mngContainerIdx == -1 {
    +		return nil, errors.NewNotFound(schema.GroupResource{Group: appsv1.SchemeGroupVersion.Group, Resource: "containers"}, consts.OperatorManagerContainer)
    +	}
    +	mngContainer := initialDp.Spec.Template.Spec.Containers[mngContainerIdx].DeepCopy()
    +	updated := false
    +	for i := range mngContainer.Env {
    +		if mngContainer.Env[i].Name == envName {
    +			if mngContainer.Env[i].Value == envValue {
    +				klog.InfoS("env is already set", "env", envName, "value", envValue)
    +				return noOpRestoreFunc, nil
    +			}
    +			mngContainer.Env[i].Value = envValue
    +			updated = true
    +			break
    +		}
    +	}
    +	if !updated {
    +		mngContainer.Env = append(mngContainer.Env, corev1.EnvVar{Name: envName, Value: envValue})
    +	}
    +	if err := updateDeploymentContainerAndWaitForRollout(ctx, cli, dpKey, mngContainerIdx, mngContainer); err != nil {
    +		return nil, err
    +	}
    +
    +	return func(ctx context.Context) error {
    +		return updateDeploymentContainerAndWaitForRollout(ctx, cli, dpKey, mngContainerIdx, initialDp.Spec.Template.Spec.Containers[mngContainerIdx].DeepCopy())
    +	}, nil
    +}
    +
    +func getPodsForDeployment(ctx context.Context, cli client.Client, dpKey client.ObjectKey) (*appsv1.Deployment, []corev1.Pod, error) {
    +	klog.InfoS("getting deployment pods", "key", dpKey.String())
    +	dp := &appsv1.Deployment{}
    +	if err := cli.Get(ctx, dpKey, dp); err != nil {
    +		return nil, nil, err
    +	}
    +	pods, err := podlist.With(cli).ByDeployment(ctx, *dp)
    +	if len(pods) == 0 || err != nil {
    +		return nil, nil, fmt.Errorf("failed to get deployment pods: err=%v pods=%v", err, pods)
    +	}
    +	return dp, pods, nil
    +}
    +
    +func waitForDeploymentRolloutAfterSubscriptionUpdate(ctx context.Context, cli client.Client, dp *appsv1.Deployment, initialPods []corev1.Pod, expectedEnvVarValues []corev1.EnvVar) error {
    +	// Sometimes OLM fails to immediately update the deployment with the new env value,
    +	// so we workaround this by explicitly deleting the deployment. Note that recreating
    +	// the deployment can also take some time, being affected by the OLM rollout behavior,
    +	// hence we give long enough time for its recreation.
    +	klog.Info("deleting deployment")
    +	if err := cli.Delete(ctx, dp); err != nil {
    +		return err
    +	}
    +
    +	err := k8swait.PollUntilContextTimeout(ctx, 10*time.Second, 15*time.Minute, true, func(aContext context.Context) (bool, error) {
    +		if err := cli.Get(ctx, client.ObjectKeyFromObject(dp), dp); err != nil {
    +			klog.Warningf("failed getting the deployment %s: %v", dp.Name, err)
    +			return false, nil
    +		}
    +		return true, nil
    +	})
    +	if err != nil {
    +		return fmt.Errorf("failed to wait for deployment to be recreated: err=%v", err)
    +	}
    +	return waitForDeploymentRollout(ctx, cli, dp, initialPods, expectedEnvVarValues)
    +}
    +
    +func waitForDeploymentRollout(ctx context.Context, cli client.Client, dp *appsv1.Deployment, initialPods []corev1.Pod, expectedEnvVarValues []corev1.EnvVar) error {
    +	if len(initialPods) == 0 {
    +		klog.Info("no initial pods to wait for to be terminated")
    +	} else {
    +		klog.Info("waiting for initial pods to be terminated")
    +		for _, pod := range initialPods {
    +			if err := cli.Delete(ctx, &pod); err != nil {
    +				if !errors.IsNotFound(err) {
    +					return err
    +				}
    +				continue
    +			}
    +		}
    +
    +		err := wait.With(cli).Interval(30*time.Second).Timeout(5*time.Minute).ForPodsAllDeleted(ctx, podlist.ToPods(initialPods))
    +		if err != nil {
    +			return fmt.Errorf("failed to delete initial pods: err=%v", err)
    +		}
    +	}
    +
    +	klog.InfoS("polling deployment until it's updated with the new env value", "expected", toString(expectedEnvVarValues))
    +	expectedEnvsSorted := make([]corev1.EnvVar, len(expectedEnvVarValues))
    +	copy(expectedEnvsSorted, expectedEnvVarValues)
    +	sort.Slice(expectedEnvsSorted, func(i, j int) bool {
    +		return expectedEnvsSorted[i].Name < expectedEnvsSorted[j].Name
    +	})
    +	dpKey := client.ObjectKeyFromObject(dp)
    +	updatedDp := &appsv1.Deployment{}
    +	err := k8swait.PollUntilContextTimeout(ctx, 10*time.Second, 15*time.Minute, true, func(aContext context.Context) (bool, error) {
    +		err := cli.Get(aContext, dpKey, updatedDp)
    +		if err != nil {
    +			klog.Warningf("failed getting the deployment %s: %v", dpKey.String(), err)
    +			return false, err
    +		}
    +
    +		for _, expectedEnv := range expectedEnvVarValues {
    +			found := false
    +			for _, env := range updatedDp.Spec.Template.Spec.Containers[0].Env {
    +				if env.Name == expectedEnv.Name {
    +					if env.Value == expectedEnv.Value {
    +						found = true
    +						break
    +					}
    +				}
    +			}
    +			if !found {
    +				klog.InfoS("deployment not yet updated with the new env value",
    +					"varname", expectedEnv.Name,
    +					"varvalue", expectedEnv.Value,
    +					"found", toString(updatedDp.Spec.Template.Spec.Containers[0].Env))
    +				return false, nil
    +			}
    +		}
    +		return true, nil
    +	})
    +	if err != nil {
    +		return fmt.Errorf("deployment was not updated with the new env value: err=%v", err)
    +	}
    +
    +	klog.InfoS("deployment updated as expected", "env", toString(updatedDp.Spec.Template.Spec.Containers[0].Env))
    +	klog.Info("waiting for updated deployment to be complete")
    +	_, err = wait.With(cli).Interval(30*time.Second).Timeout(5*time.Minute).ForDeploymentComplete(ctx, dp)
    +	return err
    +}
    +
    +func updateDeploymentContainerAndWaitForRollout(ctx context.Context, cli client.Client, key types.NamespacedName, containerIdx int, newContainer *corev1.Container) error {
    +	updatedSuccessfully := false
    +	retries := 10
    +	interval := 2 * time.Second
    +	dp, initialPods, err := getPodsForDeployment(ctx, cli, key)
    +	if err != nil {
    +		return fmt.Errorf("failed to get deployment details: err=%v", err)
    +	}
    +
    +	klog.Info("updated deployment container")
    +	updated := &appsv1.Deployment{}
    +	for i := 0; i < retries; i++ {
    +		if err := cli.Get(ctx, key, updated); err != nil {
    +			continue
    +		}
    +
    +		updated.Spec.Template.Spec.Containers[containerIdx] = *newContainer
    +		if err := cli.Update(ctx, updated); err == nil {
    +			updatedSuccessfully = true
    +			break
    +		}
    +		time.Sleep(interval)
    +	}
    +
    +	if !updatedSuccessfully {
    +		return fmt.Errorf("failed to update deployment %q", key.String())
    +	}
    +
    +	return waitForDeploymentRollout(ctx, cli, dp, initialPods, newContainer.Env)
    +}
    +
    +func getSubscriptionEnv(sub *unstructured.Unstructured) ([]any, error) {
    +	env, found, err := unstructured.NestedSlice(sub.Object, "spec", "config", "env")
    +	if err != nil {
    +		return nil, err
    +	}
    +	if !found {
    +		return []any{}, nil
    +	}
    +
    +	if len(env) == 0 {
    +		return []any{}, nil
    +	}
    +	cloned := make([]any, len(env))
    +	for i, item := range env {
    +		if entry, ok := item.(map[string]any); ok {
    +			entryCopy := make(map[string]any, len(entry))
    +			for k, v := range entry {
    +				entryCopy[k] = v
    +			}
    +			cloned[i] = entryCopy
    +			continue
    +		}
    +		cloned[i] = item
    +	}
    +	return cloned, nil
    +}
    +
    +func setSubscriptionEnv(sub *unstructured.Unstructured, env []any) error {
    +	return unstructured.SetNestedSlice(sub.Object, env, "spec", "config", "env")
    +}
    +
    +func buildSubscriptionWithNewEnvVal(env []any, name, value string) []any {
    +	for i, item := range env {
    +		entry, ok := item.(map[string]any)
    +		if !ok {
    +			continue
    +		}
    +		entryName, _ := entry["name"].(string)
    +		if entryName != name {
    +			continue
    +		}
    +		entry["value"] = value
    +		env[i] = entry
    +		return env
    +	}
    +	return append(env, map[string]any{
    +		"name":  name,
    +		"value": value,
    +	})
    +}
    +
    +func ensureSubscriptionIsUpdated(ctx context.Context, cli client.Client, subKey client.ObjectKey, expectedEnv []any) error {
    +	klog.InfoS("ensuring subscription is updated with the correct env value")
    +	current := &unstructured.Unstructured{}
    +	current.SetGroupVersionKind(subscriptionGVK)
    +	if err := cli.Get(ctx, subKey, current); err != nil {
    +		return err
    +	}
    +	foundEnv, err := getSubscriptionEnv(current)
    +	if err != nil {
    +		return err
    +	}
    +	foundEnvVars := toEnvVars(foundEnv)
    +	expectedEnvVars := toEnvVars(expectedEnv)
    +	if !reflect.DeepEqual(foundEnvVars, expectedEnvVars) {
    +		return fmt.Errorf("subscription env is not updated with the correct env value: found=%v expected=%v", foundEnvVars, expectedEnvVars)
    +	}
    +	return nil
    +}
    +
    +func toString(envs []corev1.EnvVar) string {
    +	sb := strings.Builder{}
    +	for _, env := range envs {
    +		sb.WriteString(fmt.Sprintf("%s=%s, ", env.Name, env.Value))
    +	}
    +	return sb.String()
    +}
    +
    +func toEnvVars(envs []any) []corev1.EnvVar {
    +	envVars := []corev1.EnvVar{}
    +	for _, env := range envs {
    +		entry, ok := env.(map[string]any)
    +		if !ok {
    +			continue
    +		}
    +		envVars = append(envVars, corev1.EnvVar{
    +			Name:  entry["name"].(string),
    +			Value: entry["value"].(string),
    +		})
    +	}
    +	return envVars
    +}

    _🩺 Stability & Availability_ | _🟠 Major_ | _⚡ Quick win_

    Unchecked type assertions can panic on valueFrom-based env entries.

    entry["name"].(string) and entry["value"].(string) use the single-value form. If a pre-existing subscription env entry uses valueFrom (secretKeyRef/configMapKeyRef) rather than a literal value, the "value" key is absent (nil), and this assertion panics, crashing the e2e run instead of failing gracefully.

    <details>
    <summary>🛡️ Proposed fix using safe type assertions</summary>

     func toEnvVars(envs []any) []corev1.EnvVar {
     	envVars := []corev1.EnvVar{}
     	for _, env := range envs {
     		entry, ok := env.(map[string]any)
     		if !ok {
     			continue
     		}
    -		envVars = append(envVars, corev1.EnvVar{
    -			Name:  entry["name"].(string),
    -			Value: entry["value"].(string),
    -		})
    +		name, ok := entry["name"].(string)
    +		if !ok {
    +			continue
    +		}
    +		value, _ := entry["value"].(string)
    +		envVars = append(envVars, corev1.EnvVar{Name: name, Value: value})
     	}
     	return envVars
     }
    

    </details>

    <!-- suggestion_start -->

    <details>
    <summary>📝 Committable suggestion</summary>

    ‼️ IMPORTANT

    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    func toEnvVars(envs []any) []corev1.EnvVar {
    	envVars := []corev1.EnvVar{}
    	for _, env := range envs {
    		entry, ok := env.(map[string]any)
    		if !ok {
    			continue
    		}
    		name, ok := entry["name"].(string)
    		if !ok {
    			continue
    		}
    		value, _ := entry["value"].(string)
    		envVars = append(envVars, corev1.EnvVar{Name: name, Value: value})
    	}
    	return envVars
    }
    

    </details>

    <!-- suggestion_end -->

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@test/internal/envvar/envvar.go` around lines 467 - 480, Update toEnvVars to
    use checked type assertions for the name and value fields before appending an
    EnvVar. Skip entries missing a string literal value, including valueFrom-based
    entries, and avoid panics from absent or incorrectly typed fields while
    preserving conversion of valid literal env entries.
    

    </details>

    <!-- fingerprinting:phantom:medusa:beignet -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:e4b5e966d62de8d021746ee8 -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits 42f8b0d to 756a55a

    coderabbitai[bot] coderabbitai[bot] commented on Jul 20, 2026 07:55 UTC
    Reviewer

    Actionable comments posted: 4

    <details>
    <summary>🧹 Nitpick comments (1)</summary><blockquote>

    <details>
    <summary>test/internal/envvar/envvar.go (1)</summary><blockquote>

    358-387: _📐 Maintainability & Code Quality_ | _🔵 Trivial_

    Custom retry loop duplicates retry.RetryOnConflict and busy-loops on Get failures.

    This hand-rolled retry duplicates functionality already used elsewhere in this file (retry.RetryOnConflict, lines 167/195). Additionally, when cli.Get fails, the loop continues without sleeping (the time.Sleep(interval) only runs after a failed Update), so repeated Get failures retry immediately without backoff.

    <details>
    <summary>♻️ Suggested consolidation</summary>

    -	updated := &appsv1.Deployment{}
    -	for i := 0; i < retries; i++ {
    -		if err := cli.Get(ctx, key, updated); err != nil {
    -			continue
    -		}
    -
    -		updated.Spec.Template.Spec.Containers[containerIdx] = *newContainer
    -		if err := cli.Update(ctx, updated); err == nil {
    -			updatedSuccessfully = true
    -			break
    -		}
    -		time.Sleep(interval)
    -	}
    -
    -	if !updatedSuccessfully {
    -		return fmt.Errorf("failed to update deployment %q", key.String())
    -	}
    +	updated := &appsv1.Deployment{}
    +	if err := retry.RetryOnConflict(retry.DefaultBackoff, func() error {
    +		if err := cli.Get(ctx, key, updated); err != nil {
    +			return err
    +		}
    +		updated.Spec.Template.Spec.Containers[containerIdx] = *newContainer
    +		return cli.Update(ctx, updated)
    +	}); err != nil {
    +		return fmt.Errorf("failed to update deployment %q: %w", key.String(), err)
    +	}
    

    </details>

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@test/internal/envvar/envvar.go` around lines 358 - 387, Replace the
    hand-rolled retry loop in updateDeploymentContainerAndWaitForRollout with
    retry.RetryOnConflict, including both cli.Get and cli.Update in the retried
    operation so Get failures receive the same backoff and retry handling. Preserve
    the existing successful update behavior and return an error when retries are
    exhausted.
    

    </details>

    <!-- cr-comment:v1:e77af8e7d913d1028773751c -->

    </blockquote></details>

    </blockquote></details>

    <details>
    <summary>🤖 Prompt for all review comments with AI agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    Inline comments:
    In `@test/e2e/must-gather/must_gather_suite_test.go`:
    - Around line 88-100: Introduce one shared helper that accepts ctx and the
    Kubernetes client, checks IsSchedulerImageValidationEnabled, disables validation
    via SetOperatorEnvVar, asserts success, and registers cleanup to restore it.
    Replace the duplicated blocks in
    test/e2e/must-gather/must_gather_suite_test.go#L88-L100,
    test/e2e/sched/install/test_suite_install_test.go#L41-L53,
    test/e2e/sched/uninstall/test_suite_uninstall_test.go#L41-L53, and
    test/e2e/serial/e2e_serial_test.go#L53-L65 with calls to that helper; in
    test/e2e/sched/test_suite_sched_test.go#L39-L57, remove
    suiteSchedValidationSetup and its surrounding setup/cleanup in favor of the same
    helper.
    
    In `@test/e2e/sched/sched_test.go`:
    - Around line 139-174: Update the DeferCleanup closure in the scheduler image
    validation test to pass cleanupCtx, not the captured ctx, to
    suiteSchedValidationSetup when restoring validation. Keep the existing
    conditional restoration and error assertion unchanged.
    
    In `@test/internal/envvar/envvar.go`:
    - Around line 270-291: Update the PollUntilContextTimeout callback in
    waitForDeploymentRolloutAfterSubscriptionUpdate to use its aContext parameter
    for the cli.Get call instead of the outer ctx. Preserve the existing retry and
    error-handling behavior.
    - Around line 467-480: Update toEnvVars to use checked type assertions for the
    name and value fields before appending an EnvVar. Skip entries missing a string
    literal value, including valueFrom-based entries, and avoid panics from absent
    or incorrectly typed fields while preserving conversion of valid literal env
    entries.
    
    ---
    
    Nitpick comments:
    In `@test/internal/envvar/envvar.go`:
    - Around line 358-387: Replace the hand-rolled retry loop in
    updateDeploymentContainerAndWaitForRollout with retry.RetryOnConflict, including
    both cli.Get and cli.Update in the retried operation so Get failures receive the
    same backoff and retry handling. Preserve the existing successful update
    behavior and return an error when retries are exhausted.
    

    </details>

    <details>
    <summary>🪄 Autofix (Beta)</summary>

    Fix all unresolved CodeRabbit comments on this PR:

  • <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)

  • <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
  • </details>

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

    Configuration used: Organization UI

    Review profile: CHILL

    Plan: Enterprise

    Run ID: 0283ff08-0390-4202-b90b-b308ab07ed49

    </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between 464a04f6ac3af60b2cb4f441e6ee913b53fe0431 and be4a80c3a5111312739771082d03189bbe5b5b52.

    </details>

    <details>
    <summary>📒 Files selected for processing (13)</summary>

    .konflux/bundle/overlay/pin_images.in.yaml
    .konflux/catalog/bundle.builds.in.yaml
    test/e2e/must-gather/must_gather_suite_test.go
    test/e2e/must-gather/must_gather_test.go
    test/e2e/sched/install/test_suite_install_test.go
    test/e2e/sched/sched_test.go
    test/e2e/sched/test_suite_sched_test.go
    test/e2e/sched/uninstall/test_suite_uninstall_test.go
    test/e2e/serial/README.md
    test/e2e/serial/e2e_serial_test.go
    test/internal/consts/consts.go
    test/internal/envvar/envvar.go

  • test/internal/nrosched/nrosched.go
  • </details>

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    shajmakh shajmakh commented on Jul 20, 2026 12:34 UTC
    Author

    /retest

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 23, 2026 08:59 UTC
    Code Review
    test/e2e/sched/image_validation/validation_test.go:1
    @@ -0,0 +1,140 @@
    +/*
    + * Copyright 2021 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 sched
    +
    +import (
    +	"context"
    +	"time"
    +
    +	metahelper "k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	klog "k8s.io/klog/v2"
    +
    +	"sigs.k8s.io/controller-runtime/pkg/client"
    +
    +	nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
    +	intsched "github.com/openshift-kni/numaresources-operator/internal/api/scheduler"
    +	"github.com/openshift-kni/numaresources-operator/internal/podlist"
    +	"github.com/openshift-kni/numaresources-operator/internal/wait"
    +	"github.com/openshift-kni/numaresources-operator/pkg/status"
    +	e2eclient "github.com/openshift-kni/numaresources-operator/test/internal/clients"
    +	e2eenvvar "github.com/openshift-kni/numaresources-operator/test/internal/envvar"
    +	e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/objects"
    +
    +	. "github.com/onsi/ginkgo/v2"
    +	. "github.com/onsi/gomega"
    +)
    +
    +var _ = Describe("[Scheduler] scheduler object updates", func() {
    +	nroSchedObj := &nropv1.NUMAResourcesScheduler{}
    +	BeforeEach(func() {
    +		nroSchedKey := objects.NROSchedObjectKey()
    +		Expect(e2eclient.Client.Get(context.TODO(), nroSchedKey, nroSchedObj)).ToNot(HaveOccurred(), "cannot get %q in the cluster", nroSchedKey.String())
    +		initialNroSchedObj := nroSchedObj.DeepCopy()
    +
    +		DeferCleanup(func() {
    +			Eventually(func() error {
    +				err := e2eclient.Client.Get(context.TODO(), nroSchedKey, nroSchedObj)
    +				if err != nil {
    +					return err
    +				}
    +
    +				nroSchedObj.Spec = initialNroSchedObj.Spec
    +				return e2eclient.Client.Update(context.TODO(), nroSchedObj)
    +			}).Should(Succeed(), "failed to revert changes to %q during cleanup", nroSchedKey)
    +
    +			dp, err := podlist.With(e2eclient.Client).DeploymentByOwnerReference(context.TODO(), nroSchedObj.UID)
    +			Expect(err).ToNot(HaveOccurred(), "unable to get deployment by owner reference")
    +
    +			_, err = wait.With(e2eclient.Client).Timeout(5*time.Minute).Interval(10*time.Second).ForDeploymentCompleteWithReplicas(context.TODO(), dp, *dp.Spec.Replicas)
    +			Expect(err).ToNot(HaveOccurred())
    +		})
    +	})
    +
    +	It("should degrade status when scheduler image is invalid and validation is enabled - default operator installation", func(ctx context.Context) {
    +		testSchedObj := &nropv1.NUMAResourcesScheduler{}
    +		// existing image but not valid because it's not pinned to a specific digest
    +		invalidImage := "quay.io/openshift-kni/scheduler-plugins:4.12-snapshot"
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - not pinned by digest", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		digest := "sha256:c1b0456fa8b7b96325a9cd2509c19c1e407e9d2cd7523ca62dd5db30cadb73b9"
    +		invalidImage = "quay.io/openshift-kni/scheduler-plugins@" + digest
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - digest not trusted", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())

    _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_

    Ensure the untrusted-image assertion observes the second update.

    The prior case already leaves Degraded=True with ReasonInvalidSchedulerImage, so this poll can pass before reconciliation evaluates the untrusted digest. Assert that the condition’s ObservedGeneration equals the fetched resource generation.

    <details><summary>Proposed fix</summary>

     			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
     			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
     			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +			g.Expect(degradedCondition.ObservedGeneration).To(Equal(testSchedObj.Generation), "degraded condition has not observed the current scheduler generation")
    

    </details>

    <!-- suggestion_start -->

    <details>
    <summary>📝 Committable suggestion</summary>

    ‼️ IMPORTANT

    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    		Eventually(func(g Gomega) {
    			g.Expect(e2eclient.Client.Get(ctx, client.ObjectKeyFromObject(nroSchedObj), testSchedObj)).To(Succeed())
    			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    
    			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    			g.Expect(degradedCondition.ObservedGeneration).To(Equal(testSchedObj.Generation), "degraded condition has not observed the current scheduler generation")
    		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    

    </details>

    <!-- suggestion_end -->

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@test/e2e/sched/image_validation/sched_test.go` around lines 107 - 115, In the
    Eventually assertion for the fetched scheduler object, also verify that
    degradedCondition.ObservedGeneration matches testSchedObj.Generation. Keep the
    existing status and reason checks, ensuring the untrusted-image assertion only
    passes after the second reconciliation update is observed.
    

    </details>

    <!-- fingerprinting:phantom:poseidon:terra -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:1ec1b595e16fc6974c79be52 -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits 535e436 to 9e92094

    coderabbitai[bot] coderabbitai[bot] commented on Jul 23, 2026 08:59 UTC
    Reviewer

    Actionable comments posted: 1

    <details>
    <summary>🤖 Prompt for all review comments with AI agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    Inline comments:
    In `@test/e2e/sched/image_validation/sched_test.go`:
    - Around line 107-115: In the Eventually assertion for the fetched scheduler
    object, also verify that degradedCondition.ObservedGeneration matches
    testSchedObj.Generation. Keep the existing status and reason checks, ensuring
    the untrusted-image assertion only passes after the second reconciliation update
    is observed.
    

    </details>

    <details>
    <summary>🪄 Autofix (Beta)</summary>

    Fix all unresolved CodeRabbit comments on this PR:

  • <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)

  • <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
  • </details>

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

    Configuration used: Organization UI

    Review profile: CHILL

    Plan: Pro Plus

    Run ID: 1f51fa90-58a4-48d2-8f32-fc1476f3f000

    </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between b2e74d539794d566de46fa976b1465ce8666bc8f and 756a55a800c7480601d0dd1416ea9bf5a0e377be.

    </details>

    <details>
    <summary>📒 Files selected for processing (4)</summary>

    Makefile
    hack/run-test-e2e.sh
    test/e2e/sched/image_validation/sched_test.go
    test/e2e/sched/image_validation/test_suite_sched_test.go

    </details>

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 23, 2026 11:50 UTC
    Code Review
    test/e2e/sched/image_validation/validation_test.go:1
    @@ -0,0 +1,127 @@
    +/*
    + * Copyright 2021 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 sched
    +
    +import (
    +	"context"
    +	"time"
    +
    +	metahelper "k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	klog "k8s.io/klog/v2"
    +
    +	nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
    +	intsched "github.com/openshift-kni/numaresources-operator/internal/api/scheduler"
    +	"github.com/openshift-kni/numaresources-operator/pkg/status"
    +	e2eclient "github.com/openshift-kni/numaresources-operator/test/internal/clients"
    +	e2eenvvar "github.com/openshift-kni/numaresources-operator/test/internal/envvar"
    +	e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/objects"
    +
    +	. "github.com/onsi/ginkgo/v2"
    +	. "github.com/onsi/gomega"
    +)
    +
    +var _ = Describe("[Scheduler] scheduler object updates", func() {
    +	It("should degrade status when scheduler image is invalid and validation is enabled - default operator installation", func(ctx context.Context) {
    +		initialSched := &nropv1.NUMAResourcesScheduler{}
    +		nroSchedKey := objects.NROSchedObjectKey()
    +		Expect(e2eclient.Client.Get(context.TODO(), nroSchedKey, initialSched)).ToNot(HaveOccurred(), "cannot get %q in the cluster", nroSchedKey.String())
    +
    +		testSchedObj := &nropv1.NUMAResourcesScheduler{}
    +		// existing image but not valid because it's not pinned to a specific digest
    +		invalidImage := "quay.io/openshift-kni/scheduler-plugins:4.12-snapshot"
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - not pinned by digest", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			e2efixture.By("restore the scheduler image")
    +			Eventually(func(g Gomega) {
    +				schedObj := &nropv1.NUMAResourcesScheduler{}
    +				g.Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +				testSchedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
    +				g.Expect(e2eclient.Client.Update(cleanupCtx, schedObj)).To(Succeed())
    +			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())

    _🎯 Functional Correctness_ | _🟠 Major_ | _⚡ Quick win_

    Restore the fetched scheduler object.

    Line 60 updates testSchedObj, but line 61 persists schedObj; cleanup therefore leaves the invalid image configured and can contaminate later E2E tests.

    <details>
    <summary>Proposed fix</summary>

    -				testSchedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
    +				schedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
     				g.Expect(e2eclient.Client.Update(cleanupCtx, schedObj)).To(Succeed())
    

    </details>

    <!-- suggestion_start -->

    <details>
    <summary>📝 Committable suggestion</summary>

    ‼️ IMPORTANT

    Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

    		DeferCleanup(func(cleanupCtx context.Context) {
    			e2efixture.By("restore the scheduler image")
    			Eventually(func(g Gomega) {
    				schedObj := &nropv1.NUMAResourcesScheduler{}
    				g.Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    				schedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
    				g.Expect(e2eclient.Client.Update(cleanupCtx, schedObj)).To(Succeed())
    			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    

    </details>

    <!-- suggestion_end -->

    <details>
    <summary>🤖 Prompt for AI Agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    In `@test/e2e/sched/image_validation/validation_test.go` around lines 55 - 62, In
    the DeferCleanup scheduler-image restoration, assign
    initialSched.Spec.SchedulerImage to the fetched schedObj.Spec.SchedulerImage
    before calling e2eclient.Client.Update. Keep the existing fetch, retry, timeout,
    and polling behavior unchanged so the restored object is the one persisted.
    

    </details>

    <!-- fingerprinting:phantom:poseidon:terra -->

    <!-- cr-indicator-types:potential_issue -->

    <!-- cr-comment:v1:9304f6e0ebb9d913b09715f5 -->

    <!-- This is an auto-generated comment by CodeRabbit -->

    ✅ Addressed in commits 2f91649 to 691ec3a

    coderabbitai[bot] coderabbitai[bot] commented on Jul 23, 2026 11:50 UTC
    Reviewer

    Actionable comments posted: 1

    <details>
    <summary>🤖 Prompt for all review comments with AI agents</summary>

    Verify each finding against current code. Fix only still-valid issues, skip the
    rest with a brief reason, keep changes minimal, and validate.
    
    Inline comments:
    In `@test/e2e/sched/image_validation/validation_test.go`:
    - Around line 55-62: In the DeferCleanup scheduler-image restoration, assign
    initialSched.Spec.SchedulerImage to the fetched schedObj.Spec.SchedulerImage
    before calling e2eclient.Client.Update. Keep the existing fetch, retry, timeout,
    and polling behavior unchanged so the restored object is the one persisted.
    

    </details>

    <details>
    <summary>🪄 Autofix (Beta)</summary>

    Fix all unresolved CodeRabbit comments on this PR:

  • <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended)

  • <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes
  • </details>

    ---

    <details>
    <summary>ℹ️ Review info</summary>

    <details>
    <summary>⚙️ Run configuration</summary>

    Configuration used: Organization UI

    Review profile: CHILL

    Plan: Pro Plus

    Run ID: e497d3ed-b4d9-49d6-b0f8-8ae3a1338652

    </details>

    <details>
    <summary>📥 Commits</summary>

    Reviewing files that changed from the base of the PR and between 756a55a800c7480601d0dd1416ea9bf5a0e377be and e4b4d685aceb9ba6ee53d4bd385659df2cbbe8b3.

    </details>

    <details>
    <summary>📒 Files selected for processing (5)</summary>

    Makefile
    hack/run-test-e2e.sh
    test/e2e/sched/image_validation/test_suite_validation_test.go
    test/e2e/sched/image_validation/validation_test.go
    test/internal/envvar/envvar.go

    </details>

    <details>
    <summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

    Makefile

    </details>

    </details>

    <!-- This is an auto-generated comment by CodeRabbit for review status -->

    shajmakh shajmakh commented on Jul 23, 2026 12:41 UTC
    Author

    /retest

    shajmakh shajmakh commented on Jul 28, 2026 09:01 UTC
    Author

    /retest

    shajmakh shajmakh commented on code on Jul 28, 2026 10:52 UTC
    Code Review
    test/e2e/must-gather/must_gather_suite_test.go:1
    @@ -81,7 +84,23 @@ var _ = BeforeSuite(func() {
     
     	deployment = deploy.NewForPlatform(configuration.Plat)
     	_ = deployment.Deploy(ctx, configuration.MachineConfigPoolUpdateTimeout) // we don't care about the nrop instance
    +
    +	if !e2esched.IsSchedulerImageValidationEnabled() {
    +		// for e2e verification we disable the image validation because handling pulling images in the CI from the
    +		// production registry is troublesome, and so is handling changing the digests on each branch. Testing e2e
    +		// for the image validation will be handled in a separate test.
    +		By("identify the source of operator installation and disable scheduler image validation")
    +		var err error
    +		restoreFunc, err := e2eenvvar.SetOperatorEnvVar(ctx, e2eclient.Client, intsched.SchedulerImageValidationEnvVar, "false")
    +		Expect(err).NotTo(HaveOccurred())
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			By("restoring scheduler image validation settings")
    +			Expect(restoreFunc(cleanupCtx)).To(Succeed())
    +		})
    +	}

    handling in a different PR

    coderabbitai[bot] coderabbitai[bot] commented on code on Jul 28, 2026 10:53 UTC
    Code Review
    test/e2e/must-gather/must_gather_suite_test.go:1
    @@ -81,7 +84,23 @@ var _ = BeforeSuite(func() {
     
     	deployment = deploy.NewForPlatform(configuration.Plat)
     	_ = deployment.Deploy(ctx, configuration.MachineConfigPoolUpdateTimeout) // we don't care about the nrop instance
    +
    +	if !e2esched.IsSchedulerImageValidationEnabled() {
    +		// for e2e verification we disable the image validation because handling pulling images in the CI from the
    +		// production registry is troublesome, and so is handling changing the digests on each branch. Testing e2e
    +		// for the image validation will be handled in a separate test.
    +		By("identify the source of operator installation and disable scheduler image validation")
    +		var err error
    +		restoreFunc, err := e2eenvvar.SetOperatorEnvVar(ctx, e2eclient.Client, intsched.SchedulerImageValidationEnvVar, "false")
    +		Expect(err).NotTo(HaveOccurred())
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			By("restoring scheduler image validation settings")
    +			Expect(restoreFunc(cleanupCtx)).To(Succeed())
    +		})
    +	}

    @shajmakh, acknowledged—this refactor can be handled in the follow-up PR. Would you like me to open a tracking issue for it?

    🐇‍↕️

    <!-- This is an auto-generated reply by CodeRabbit -->

    shajmakh shajmakh commented on Jul 28, 2026 12:32 UTC
    Author

    e2e passed, rerunning to ensure its success is stable:
    /retest ci-e2e

    shajmakh shajmakh commented on Jul 28, 2026 12:32 UTC
    Author

    /test ci-e2e

    Tal-or Tal-or commented on code on Jul 29, 2026 08:14 UTC
    Code Review
    test/e2e/sched/image_validation/test_suite_validation_test.go:1
    @@ -0,0 +1,36 @@
    +/*
    + * Copyright 2021 Red Hat, Inc.

    IIRC we agreed to remove the year, which is wrong date anyway.

    Tal-or Tal-or commented on code on Jul 29, 2026 08:15 UTC
    Code Review
    hack/run-test-e2e.sh:1
    @@ -54,6 +54,7 @@ if [ "$ENABLE_SCHED_TESTS" = true ]; then
       # --flake-attempts: rerun the test if it fails
       # -requireSuite: fail if tests are not executed because of missing suite
       ${BIN_DIR}/e2e-nrop-sched.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched.xml
    +  ${BIN_DIR}/e2e-nrop-sched-image-validation.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched-image-validation.xml

    Is there a reason to have the sched-image-validation test as a separate binary from the rest of sched tests?

    Tal-or Tal-or commented on code on Jul 29, 2026 08:15 UTC
    Code Review
    test/e2e/sched/image_validation/validation_test.go:1
    @@ -0,0 +1,131 @@
    +/*
    + * Copyright 2021 Red Hat, Inc.

    ditto

    rshemtov13 rshemtov13 commented on code on Jul 29, 2026 08:22 UTC
    Code Review
    test/e2e/sched/image_validation/validation_test.go:1
    @@ -0,0 +1,131 @@
    +/*
    + * Copyright 2021 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 sched
    +
    +import (
    +	"context"
    +	"time"
    +
    +	metahelper "k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	klog "k8s.io/klog/v2"
    +
    +	nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
    +	intsched "github.com/openshift-kni/numaresources-operator/internal/api/scheduler"
    +	"github.com/openshift-kni/numaresources-operator/pkg/status"
    +	e2eclient "github.com/openshift-kni/numaresources-operator/test/internal/clients"
    +	e2eenvvar "github.com/openshift-kni/numaresources-operator/test/internal/envvar"
    +	e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/objects"
    +
    +	. "github.com/onsi/ginkgo/v2"
    +	. "github.com/onsi/gomega"
    +)
    +
    +var _ = Describe("[Scheduler] scheduler object updates", func() {
    +	It("should degrade status when scheduler image is invalid and validation is enabled - default operator installation", func(ctx context.Context) {
    +		initialSched := &nropv1.NUMAResourcesScheduler{}
    +		nroSchedKey := objects.NROSchedObjectKey()
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, initialSched)).ToNot(HaveOccurred(), "cannot get %q in the cluster", nroSchedKey.String())
    +
    +		testSchedObj := &nropv1.NUMAResourcesScheduler{}
    +		// existing image but not valid because it's not pinned to a specific digest
    +		invalidImage := "quay.io/openshift-kni/scheduler-plugins:4.12-snapshot"
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - not pinned by digest", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			e2efixture.By("restore the scheduler image")
    +			schedObj := &nropv1.NUMAResourcesScheduler{}
    +			Eventually(func(g Gomega) {
    +				g.Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +				schedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
    +				g.Expect(e2eclient.Client.Update(cleanupCtx, schedObj)).To(Succeed())
    +			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +			Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +			klog.InfoS("scheduler spec", "spec", schedObj.Spec)
    +			Expect(schedObj.Spec.SchedulerImage).To(Equal(initialSched.Spec.SchedulerImage))
    +		})
    +
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		digest := "sha256:c1b0456fa8b7b96325a9cd2509c19c1e407e9d2cd7523ca62dd5db30cadb73b9"
    +		invalidImage = "quay.io/openshift-kni/scheduler-plugins@" + digest

    Maybe here just keep the digest and remove the sha256 and pass it into invalidImage.
    Another quick question can we get the digest dynamically instead of hardcoding or is it too much overhead?

    Tal-or Tal-or commented on code on Jul 29, 2026 08:24 UTC
    Code Review
    test/e2e/sched/image_validation/validation_test.go:1
    @@ -0,0 +1,131 @@
    +/*
    + * Copyright 2021 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 sched
    +
    +import (
    +	"context"
    +	"time"
    +
    +	metahelper "k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	klog "k8s.io/klog/v2"
    +
    +	nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
    +	intsched "github.com/openshift-kni/numaresources-operator/internal/api/scheduler"
    +	"github.com/openshift-kni/numaresources-operator/pkg/status"
    +	e2eclient "github.com/openshift-kni/numaresources-operator/test/internal/clients"
    +	e2eenvvar "github.com/openshift-kni/numaresources-operator/test/internal/envvar"
    +	e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/objects"
    +
    +	. "github.com/onsi/ginkgo/v2"
    +	. "github.com/onsi/gomega"
    +)
    +
    +var _ = Describe("[Scheduler] scheduler object updates", func() {
    +	It("should degrade status when scheduler image is invalid and validation is enabled - default operator installation", func(ctx context.Context) {
    +		initialSched := &nropv1.NUMAResourcesScheduler{}
    +		nroSchedKey := objects.NROSchedObjectKey()
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, initialSched)).ToNot(HaveOccurred(), "cannot get %q in the cluster", nroSchedKey.String())
    +
    +		testSchedObj := &nropv1.NUMAResourcesScheduler{}
    +		// existing image but not valid because it's not pinned to a specific digest
    +		invalidImage := "quay.io/openshift-kni/scheduler-plugins:4.12-snapshot"
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - not pinned by digest", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			e2efixture.By("restore the scheduler image")
    +			schedObj := &nropv1.NUMAResourcesScheduler{}
    +			Eventually(func(g Gomega) {
    +				g.Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +				schedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
    +				g.Expect(e2eclient.Client.Update(cleanupCtx, schedObj)).To(Succeed())
    +			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +			Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +			klog.InfoS("scheduler spec", "spec", schedObj.Spec)
    +			Expect(schedObj.Spec.SchedulerImage).To(Equal(initialSched.Spec.SchedulerImage))
    +		})
    +
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		digest := "sha256:c1b0456fa8b7b96325a9cd2509c19c1e407e9d2cd7523ca62dd5db30cadb73b9"
    +		invalidImage = "quay.io/openshift-kni/scheduler-plugins@" + digest
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - digest not trusted", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.ObservedGeneration).To(Equal(testSchedObj.Generation), "degraded condition generation mismatch")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		By("identify the source of operator installation and disable scheduler image validation")
    +		var err error
    +		restoreFunc, err := e2eenvvar.SetOperatorEnvVar(ctx, e2eclient.Client, intsched.CustomSchedulerDigestsEnvVar, digest)
    +		Expect(err).NotTo(HaveOccurred())
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			By("restoring scheduler image validation settings")
    +			Expect(restoreFunc(cleanupCtx)).To(Succeed())

    this is the only place where we call restoreFunc why not simply inline the function?

    Tal-or Tal-or commented on Jul 29, 2026 08:26 UTC
    Reviewer

    overall looking good
    minor comments

    shajmakh shajmakh commented on code on Jul 29, 2026 08:36 UTC
    Code Review
    test/e2e/sched/image_validation/validation_test.go:1
    @@ -0,0 +1,131 @@
    +/*
    + * Copyright 2021 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 sched
    +
    +import (
    +	"context"
    +	"time"
    +
    +	metahelper "k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	klog "k8s.io/klog/v2"
    +
    +	nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
    +	intsched "github.com/openshift-kni/numaresources-operator/internal/api/scheduler"
    +	"github.com/openshift-kni/numaresources-operator/pkg/status"
    +	e2eclient "github.com/openshift-kni/numaresources-operator/test/internal/clients"
    +	e2eenvvar "github.com/openshift-kni/numaresources-operator/test/internal/envvar"
    +	e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/objects"
    +
    +	. "github.com/onsi/ginkgo/v2"
    +	. "github.com/onsi/gomega"
    +)
    +
    +var _ = Describe("[Scheduler] scheduler object updates", func() {
    +	It("should degrade status when scheduler image is invalid and validation is enabled - default operator installation", func(ctx context.Context) {
    +		initialSched := &nropv1.NUMAResourcesScheduler{}
    +		nroSchedKey := objects.NROSchedObjectKey()
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, initialSched)).ToNot(HaveOccurred(), "cannot get %q in the cluster", nroSchedKey.String())
    +
    +		testSchedObj := &nropv1.NUMAResourcesScheduler{}
    +		// existing image but not valid because it's not pinned to a specific digest
    +		invalidImage := "quay.io/openshift-kni/scheduler-plugins:4.12-snapshot"
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - not pinned by digest", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			e2efixture.By("restore the scheduler image")
    +			schedObj := &nropv1.NUMAResourcesScheduler{}
    +			Eventually(func(g Gomega) {
    +				g.Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +				schedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
    +				g.Expect(e2eclient.Client.Update(cleanupCtx, schedObj)).To(Succeed())
    +			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +			Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +			klog.InfoS("scheduler spec", "spec", schedObj.Spec)
    +			Expect(schedObj.Spec.SchedulerImage).To(Equal(initialSched.Spec.SchedulerImage))
    +		})
    +
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		digest := "sha256:c1b0456fa8b7b96325a9cd2509c19c1e407e9d2cd7523ca62dd5db30cadb73b9"
    +		invalidImage = "quay.io/openshift-kni/scheduler-plugins@" + digest

    Maybe here just keep the digest and remove the sha256 and pass it into invalidImage.

    we need the digest with the sha because we will use that in the next step to verify that intsched.CustomSchedulerDigestsEnvVar works as expected.

    Another quick question can we get the digest dynamically instead of hardcoding or is it too much overhead?

    not with the available infra, because pulling/inspecting the image dynamically needs a special infra. in this case all what we care about is the conditions of the scheduler so it doesn't matter the custom image we are using if it is old or not. I added a comment to clarify this. Thanks for raising this topic.

    shajmakh shajmakh commented on code on Jul 29, 2026 08:38 UTC
    Code Review
    test/e2e/sched/image_validation/test_suite_validation_test.go:1
    @@ -0,0 +1,36 @@
    +/*
    + * Copyright 2021 Red Hat, Inc.

    I'll remove it entirely, thanks!

    shajmakh shajmakh commented on code on Jul 29, 2026 08:41 UTC
    Code Review
    test/e2e/sched/image_validation/validation_test.go:1
    @@ -0,0 +1,131 @@
    +/*
    + * Copyright 2021 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 sched
    +
    +import (
    +	"context"
    +	"time"
    +
    +	metahelper "k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	klog "k8s.io/klog/v2"
    +
    +	nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
    +	intsched "github.com/openshift-kni/numaresources-operator/internal/api/scheduler"
    +	"github.com/openshift-kni/numaresources-operator/pkg/status"
    +	e2eclient "github.com/openshift-kni/numaresources-operator/test/internal/clients"
    +	e2eenvvar "github.com/openshift-kni/numaresources-operator/test/internal/envvar"
    +	e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/objects"
    +
    +	. "github.com/onsi/ginkgo/v2"
    +	. "github.com/onsi/gomega"
    +)
    +
    +var _ = Describe("[Scheduler] scheduler object updates", func() {
    +	It("should degrade status when scheduler image is invalid and validation is enabled - default operator installation", func(ctx context.Context) {
    +		initialSched := &nropv1.NUMAResourcesScheduler{}
    +		nroSchedKey := objects.NROSchedObjectKey()
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, initialSched)).ToNot(HaveOccurred(), "cannot get %q in the cluster", nroSchedKey.String())
    +
    +		testSchedObj := &nropv1.NUMAResourcesScheduler{}
    +		// existing image but not valid because it's not pinned to a specific digest
    +		invalidImage := "quay.io/openshift-kni/scheduler-plugins:4.12-snapshot"
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - not pinned by digest", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			e2efixture.By("restore the scheduler image")
    +			schedObj := &nropv1.NUMAResourcesScheduler{}
    +			Eventually(func(g Gomega) {
    +				g.Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +				schedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
    +				g.Expect(e2eclient.Client.Update(cleanupCtx, schedObj)).To(Succeed())
    +			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +			Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +			klog.InfoS("scheduler spec", "spec", schedObj.Spec)
    +			Expect(schedObj.Spec.SchedulerImage).To(Equal(initialSched.Spec.SchedulerImage))
    +		})
    +
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		digest := "sha256:c1b0456fa8b7b96325a9cd2509c19c1e407e9d2cd7523ca62dd5db30cadb73b9"
    +		invalidImage = "quay.io/openshift-kni/scheduler-plugins@" + digest
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - digest not trusted", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.ObservedGeneration).To(Equal(testSchedObj.Generation), "degraded condition generation mismatch")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		By("identify the source of operator installation and disable scheduler image validation")
    +		var err error
    +		restoreFunc, err := e2eenvvar.SetOperatorEnvVar(ctx, e2eclient.Client, intsched.CustomSchedulerDigestsEnvVar, digest)
    +		Expect(err).NotTo(HaveOccurred())
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			By("restoring scheduler image validation settings")
    +			Expect(restoreFunc(cleanupCtx)).To(Succeed())

    it's a returned function from SetOperatorEnvVar we connot inline it because we don't know what is it: https://github.com/shajmakh/numaresources-operator/blob/main/test/internal/envvar/envvar.go#L52

    rshemtov13 rshemtov13 commented on code on Jul 29, 2026 08:41 UTC
    Code Review
    test/e2e/sched/image_validation/validation_test.go:1
    @@ -0,0 +1,131 @@
    +/*
    + * Copyright 2021 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 sched
    +
    +import (
    +	"context"
    +	"time"
    +
    +	metahelper "k8s.io/apimachinery/pkg/api/meta"
    +	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    +	klog "k8s.io/klog/v2"
    +
    +	nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
    +	intsched "github.com/openshift-kni/numaresources-operator/internal/api/scheduler"
    +	"github.com/openshift-kni/numaresources-operator/pkg/status"
    +	e2eclient "github.com/openshift-kni/numaresources-operator/test/internal/clients"
    +	e2eenvvar "github.com/openshift-kni/numaresources-operator/test/internal/envvar"
    +	e2efixture "github.com/openshift-kni/numaresources-operator/test/internal/fixture"
    +	"github.com/openshift-kni/numaresources-operator/test/internal/objects"
    +
    +	. "github.com/onsi/ginkgo/v2"
    +	. "github.com/onsi/gomega"
    +)
    +
    +var _ = Describe("[Scheduler] scheduler object updates", func() {
    +	It("should degrade status when scheduler image is invalid and validation is enabled - default operator installation", func(ctx context.Context) {
    +		initialSched := &nropv1.NUMAResourcesScheduler{}
    +		nroSchedKey := objects.NROSchedObjectKey()
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, initialSched)).ToNot(HaveOccurred(), "cannot get %q in the cluster", nroSchedKey.String())
    +
    +		testSchedObj := &nropv1.NUMAResourcesScheduler{}
    +		// existing image but not valid because it's not pinned to a specific digest
    +		invalidImage := "quay.io/openshift-kni/scheduler-plugins:4.12-snapshot"
    +		e2efixture.By("switching the NROS image to %s which does not pass the image validation criteria - not pinned by digest", invalidImage)
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			testSchedObj.Spec.SchedulerImage = invalidImage
    +			g.Expect(e2eclient.Client.Update(ctx, testSchedObj)).To(Succeed())
    +		}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		DeferCleanup(func(cleanupCtx context.Context) {
    +			e2efixture.By("restore the scheduler image")
    +			schedObj := &nropv1.NUMAResourcesScheduler{}
    +			Eventually(func(g Gomega) {
    +				g.Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +				schedObj.Spec.SchedulerImage = initialSched.Spec.SchedulerImage
    +				g.Expect(e2eclient.Client.Update(cleanupCtx, schedObj)).To(Succeed())
    +			}).WithTimeout(time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +			Expect(e2eclient.Client.Get(cleanupCtx, nroSchedKey, schedObj)).To(Succeed())
    +			klog.InfoS("scheduler spec", "spec", schedObj.Spec)
    +			Expect(schedObj.Spec.SchedulerImage).To(Equal(initialSched.Spec.SchedulerImage))
    +		})
    +
    +		Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +		klog.InfoS("scheduler spec", "spec", testSchedObj.Spec)
    +		Expect(testSchedObj.Spec.SchedulerImage).To(Equal(invalidImage))
    +
    +		Eventually(func(g Gomega) {
    +			g.Expect(e2eclient.Client.Get(ctx, nroSchedKey, testSchedObj)).To(Succeed())
    +			klog.InfoS("scheduler conditions", "conditions", testSchedObj.Status.Conditions)
    +
    +			degradedCondition := metahelper.FindStatusCondition(testSchedObj.Status.Conditions, status.ConditionDegraded)
    +			g.Expect(degradedCondition).ToNot(BeNil(), "degraded condition not found")
    +			g.Expect(degradedCondition.Status).To(Equal(metav1.ConditionTrue), "degraded condition status is not true")
    +			g.Expect(degradedCondition.Reason).To(Equal(string(status.ReasonInvalidSchedulerImage)), "degraded condition reason is not untrusted scheduler image")
    +		}).WithTimeout(5 * time.Minute).WithPolling(time.Second * 10).Should(Succeed())
    +
    +		digest := "sha256:c1b0456fa8b7b96325a9cd2509c19c1e407e9d2cd7523ca62dd5db30cadb73b9"
    +		invalidImage = "quay.io/openshift-kni/scheduler-plugins@" + digest

    Ack, yes adding a comment explaining that for future purposes is beneficial.
    Thanks!

    shajmakh shajmakh commented on code on Jul 29, 2026 08:50 UTC
    Code Review
    hack/run-test-e2e.sh:1
    @@ -54,6 +54,7 @@ if [ "$ENABLE_SCHED_TESTS" = true ]; then
       # --flake-attempts: rerun the test if it fails
       # -requireSuite: fail if tests are not executed because of missing suite
       ${BIN_DIR}/e2e-nrop-sched.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched.xml
    +  ${BIN_DIR}/e2e-nrop-sched-image-validation.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched-image-validation.xml

    good question, yes, because there seems an OLM issue updating the subscription with the different values of env var consecutively, as raised n https://github.com/openshift-kni/numaresources-operator/pull/4595#issuecomment-5019925191. This test requires re-enabling the image validation right after having it disabled so we can check the default behavior of the validation. after many retries, I've seen that the multiple updates of the subcription and hence the operator deployment gets stuck for a while (sometimes over 15 mins) and is not stable in the prow ci. The last resort I had (before moving this test to d/s pipeline handling for more control over the operator installation - skipping subscription updates) was to have a new suite that works with the default configuration (meaning enabled image validation), so we don't hit the consecutive subscription updates.
    I haven't spent enough time investigating the OLM timing issue because after a while, the updates resolve to the expected state.

    shajmakh shajmakh commented on code on Jul 29, 2026 08:55 UTC
    Code Review
    hack/run-test-e2e.sh:1
    @@ -54,6 +54,7 @@ if [ "$ENABLE_SCHED_TESTS" = true ]; then
       # --flake-attempts: rerun the test if it fails
       # -requireSuite: fail if tests are not executed because of missing suite
       ${BIN_DIR}/e2e-nrop-sched.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched.xml
    +  ${BIN_DIR}/e2e-nrop-sched-image-validation.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched-image-validation.xml

    I added a note about this in the suite in case we wondered about this in the future.

    Tal-or Tal-or commented on code on Jul 29, 2026 09:03 UTC
    Code Review
    hack/run-test-e2e.sh:1
    @@ -54,6 +54,7 @@ if [ "$ENABLE_SCHED_TESTS" = true ]; then
       # --flake-attempts: rerun the test if it fails
       # -requireSuite: fail if tests are not executed because of missing suite
       ${BIN_DIR}/e2e-nrop-sched.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched.xml
    +  ${BIN_DIR}/e2e-nrop-sched-image-validation.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched-image-validation.xml

    sure. lets add a comment and I'll approve (I don't see the comment atm)

    shajmakh shajmakh commented on code on Jul 29, 2026 09:04 UTC
    Code Review
    hack/run-test-e2e.sh:1
    @@ -54,6 +54,7 @@ if [ "$ENABLE_SCHED_TESTS" = true ]; then
       # --flake-attempts: rerun the test if it fails
       # -requireSuite: fail if tests are not executed because of missing suite
       ${BIN_DIR}/e2e-nrop-sched.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched.xml
    +  ${BIN_DIR}/e2e-nrop-sched-image-validation.test ${NO_COLOR} --ginkgo.v --ginkgo.timeout=5h --ginkgo.flake-attempts=2 --ginkgo.junit-report=${REPORT_DIR}/e2e-sched-image-validation.xml
    Tal-or Tal-or approved these changes on Jul 29, 2026 09:06 UTC
    Approved Reviewer

    /lgtm

    Thank you for the changes

    shajmakh shajmakh commented on Jul 30, 2026 07:56 UTC
    Author

    rebased to get this update: https://github.com/openshift-kni/numaresources-operator/pull/4784
    no change in the reviewed and approved code.

    Tal-or Tal-or approved these changes on Jul 30, 2026 08:03 UTC
    Approved Reviewer

    /lgtm

    openshift-ci[bot] openshift-ci[bot] commented on Jul 30, 2026 08:03 UTC
    Bot

    [APPROVALNOTIFIER] This PR is APPROVED

    This pull-request has been approved by: <a href="https://github.com/openshift-kni/numaresources-operator/pull/4693#" title="Author self-approved">shajmakh</a>, <a href="https://github.com/openshift-kni/numaresources-operator/pull/4693#pullrequestreview-4816658129" title="LGTM">Tal-or</a>

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

    The pull request process is described here

    <details >
    Needs approval from an approver in each of these files:

  • ~~OWNERS~~ [Tal-or,shajmakh]
  • Approvers can indicate their approval by writing /approve in a comment
    Approvers can cancel approval by writing /approve cancel in a comment
    </details>
    <!-- META={"approvers":[]} -->

    shajmakh shajmakh commented on Jul 30, 2026 10:09 UTC
    Author

    /cherry-pick release-4.22

    openshift-cherrypick-robot openshift-cherrypick-robot commented on Jul 30, 2026 10:09 UTC
    Contributor

    @shajmakh: #4693 failed to apply on top of branch "release-4.22":

    Applying: e2e: add test to check the image validation
    Using index info to reconstruct a base tree...
    M	Makefile
    Falling back to patching base and 3-way merge...
    Auto-merging Makefile
    CONFLICT (content): Merge conflict in Makefile
    error: Failed to merge in the changes.
    hint: Use 'git am --show-current-patch=diff' to see the failed patch
    hint: When you have resolved this problem, run "git am --continue".
    hint: If you prefer to skip this patch, run "git am --skip" instead.
    hint: To restore the original branch and stop patching, run "git am --abort".
    hint: Disable this message with "git config set advice.mergeConflict false"
    Patch failed at 0001 e2e: add test to check the image validation
    
    

    <details>

    In response to this:

    >/cherry-pick release-4.22

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
    </details>

    Reviewers
    Assignees
    shajmakh shajmakh
    Labels
    risk: low confidence: 91.2% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.9% (MEDIUM) · Higher = larger blast radius
    39.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 91.2% · Lower = rushed or shallow review
    91.2%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3.5% · Safe to merge
    3.5%