Skip to content

OCPNODE-4031: Add criocredentialprovider tests#30821

Draft
QiWang19 wants to merge 2 commits intoopenshift:mainfrom
QiWang19:criocptests
Draft

OCPNODE-4031: Add criocredentialprovider tests#30821
QiWang19 wants to merge 2 commits intoopenshift:mainfrom
QiWang19:criocptests

Conversation

@QiWang19
Copy link
Member

@QiWang19 QiWang19 commented Feb 28, 2026

Summary by CodeRabbit

  • Chores

    • Updated OpenShift API and client dependencies to the latest versions.
  • Tests

    • Added comprehensive end-to-end test coverage for CRIO credential provider configuration in Node environments.
    • Refactored test helper functions for improved test code organization.

Signed-off-by: Qi Wang <qiwan@redhat.com>
@openshift-ci-robot
Copy link

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 28, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 28, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai
Copy link

coderabbitai bot commented Feb 28, 2026

Walkthrough

This PR updates two OpenShift API and client-go dependencies in go.mod, exports two MCP-related helper functions in the imagepolicy test module by renaming them from private to public, and introduces a new comprehensive end-to-end test suite for CRIO credential provider configuration in OpenShift Node tests.

Changes

Cohort / File(s) Summary
Dependency Updates
go.mod
Updated github.com/openshift/api and github.com/openshift/client-go to newer snapshot versions dated February 2026.
Function Exports
test/extended/imagepolicy/imagepolicy.go
Renamed and exported two private helper functions (getMCPCurrentSpecConfigName → GetMCPCurrentSpecConfigName, waitForMCPConfigSpecChangeAndUpdated → WaitForMCPConfigSpecChangeAndUpdated) with all call sites updated accordingly.
New Test Suite
test/extended/node/criocredentialprovider.go
Added comprehensive Ginkgo-based end-to-end test suite for CRIO credential provider configuration, including test setup, MCP manipulation, ImageDigestMirrorSet creation, credential provisioning verification, and platform-specific config path detection with multiple helper functions and cleanup routines.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.53% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning Test code has multiple quality issues: unregistered cleanup for initial CRIOCredentialProviderConfig, hardcoded values instead of table parameters, missing pod cleanup handler, missing RestartPolicy in pod spec, and unvalidated error return value. Register DeferCleanup immediately after line 63, replace hardcoded values with table parameters, capture pod creation error and register cleanup, add RestartPolicy to pod spec, and validate WaitForPodContainerToFail error return.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Stable And Deterministic Test Names ✅ Passed All test names in criocredentialprovider.go are stable and deterministic, using only static descriptive strings without dynamic values.
Title check ✅ Passed The pull request title accurately summarizes the main change: adding criocredentialprovider tests, which aligns with the primary content of the changeset (new test file and supporting function exports).

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@QiWang19 QiWang19 changed the title Criocptests OCPNODE-4031: Add criocredentialprovider tests Feb 28, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Feb 28, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 28, 2026

@QiWang19: This pull request references OCPNODE-4031 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Feb 28, 2026

@QiWang19: This pull request references OCPNODE-4031 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Summary by CodeRabbit

  • Chores

  • Updated OpenShift API and client dependencies to the latest versions.

  • Tests

  • Added comprehensive end-to-end test coverage for CRIO credential provider configuration in Node environments.

  • Refactored test helper functions for improved test code organization.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the vendor-update Touching vendor dir or related files label Feb 28, 2026
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 28, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

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

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (4)
test/extended/node/criocredentialprovider.go (4)

163-184: Inconsistent error handling pattern.

Functions like cleanupCRIOCredentialProviderConfig, createIDMSResources, cleanupIDMSResources, createNamespaceRBAC, and createSecret return error but always return nil after using o.Expect() internally. Since o.Expect() fails the test on error, the return value is never meaningful.

Consider either removing the return type (since these are test helpers that fail the test on error) or propagating the actual error for caller handling:

-func cleanupCRIOCredentialProviderConfig(oc *exutil.CLI) error {
+func cleanupCRIOCredentialProviderConfig(oc *exutil.CLI) {
     // ... implementation ...
     o.Expect(err).NotTo(o.HaveOccurred(), "error cleaning up image config")
     // ...
-    return nil
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/node/criocredentialprovider.go` around lines 163 - 184, The
helper functions (e.g., cleanupCRIOCredentialProviderConfig,
createIDMSResources, cleanupIDMSResources, createNamespaceRBAC, createSecret)
declare and return error but call o.Expect(...) which fails the test and then
always return nil, making the error return useless; either remove the error
return from these helper signatures and callers (convert to void helpers that
call o.Expect on failures) or stop using o.Expect inside them and instead return
the encountered error (propagate the error up) so callers can handle it—pick one
approach and apply consistently: update the function signatures (remove error)
or replace o.Expect(...) with returning the error in functions like
cleanupCRIOCredentialProviderConfig, and update all call sites accordingly.

14-21: Consider consolidating duplicate import aliases.

The file imports the same packages with multiple aliases:

  • corev1 and kapiv1 both alias k8s.io/api/core/v1
  • framework and e2e both alias k8s.io/kubernetes/test/e2e/framework
♻️ Suggested cleanup
-	corev1 "k8s.io/api/core/v1"
-	kapiv1 "k8s.io/api/core/v1"
+	corev1 "k8s.io/api/core/v1"
 	rbacv1 "k8s.io/api/rbac/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/client-go/util/retry"
-	"k8s.io/kubernetes/test/e2e/framework"
 	e2e "k8s.io/kubernetes/test/e2e/framework"

Then update usages of kapiv1 to corev1 and framework to e2e throughout the file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/node/criocredentialprovider.go` around lines 14 - 21, There are
duplicate import aliases: both `corev1` and `kapiv1` point to
"k8s.io/api/core/v1", and `framework` and `e2e` point to
"k8s.io/kubernetes/test/e2e/framework"; remove the redundant aliases (keep
`corev1` and `e2e`) and update all references in this file (e.g., any uses of
`kapiv1` and `framework` within functions like the CRI credential provider test
helpers and test cases) to use `corev1` and `e2e` respectively so imports are
consolidated and usages are consistent.

305-310: Consider using ServiceAccount kind for RBAC subject.

The subject uses Kind: rbacv1.UserKind with a manually constructed service account name. The idiomatic approach is to use ServiceAccount kind:

♻️ Suggested improvement
 		Subjects: []rbacv1.Subject{
 			{
-				APIGroup: rbacv1.GroupName,
-				Kind:     rbacv1.UserKind,
-				Name:     "system:serviceaccount:" + f.Namespace.Name + ":default",
+				Kind:      rbacv1.ServiceAccountKind,
+				Name:      "default",
+				Namespace: f.Namespace.Name,
 			},
 		},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/node/criocredentialprovider.go` around lines 305 - 310, The
RBAC Subject is incorrectly using rbacv1.UserKind with a constructed
service-account string; change the Subject to use Kind:
rbacv1.ServiceAccountKind, clear APIGroup (empty string), put the namespace into
Subject.Namespace (e.g. f.Namespace.Name) and use Name: "default" (the SA name)
so the Subjects entry (the slice being built) becomes a proper ServiceAccount
subject; update the block that constructs the Subject accordingly.

208-213: Redundant type conversions.

Since apicfgv1alpha1.MatchImage is a string type alias, the conversions string(apicfgv1alpha1.MatchImage(img)) are redundant when img is already a string.

♻️ Suggested simplification
 	for _, img := range expectedMatchImages {
-		o.Expect(out).To(o.ContainSubstring(string(apicfgv1alpha1.MatchImage(img))), "expected match image %s not found in CRIOCredentialProviderConfig on node %s", img, nodeName)
+		o.Expect(out).To(o.ContainSubstring(img), "expected match image %s not found in CRIOCredentialProviderConfig on node %s", img, nodeName)
 	}
 	for _, img := range excludedMatchImages {
-		o.Expect(out).NotTo(o.ContainSubstring(string(apicfgv1alpha1.MatchImage(img))), "excluded match image %s found in CRIOCredentialProviderConfig on node %s", img, nodeName)
+		o.Expect(out).NotTo(o.ContainSubstring(img), "excluded match image %s found in CRIOCredentialProviderConfig on node %s", img, nodeName)
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/node/criocredentialprovider.go` around lines 208 - 213, The
code is doing redundant conversions like string(apicfgv1alpha1.MatchImage(img))
even though img is already a string; update the two checks to use the plain img
(or apicfgv1alpha1.MatchImage(img) without the extra string(...) wrapper) when
calling o.ContainSubstring/NotTo(o.ContainSubstring) for variables
expectedMatchImages and excludedMatchImages, keeping the rest of the assertion
text and references to out, o.Expect and nodeName unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/extended/node/criocredentialprovider.go`:
- Around line 65-66: The test call to
verifyWorkerNodeCRIOCredentialProviderConfig incorrectly passes hardcoded values
(nil, true) instead of the table-driven variables; change the invocation to pass
excludedMatchImages and expectCRIOProviderConfigEntry (i.e., restore the
commented-out form) so the test uses the parameterized values for
excludedMatchImages and expectCRIOProviderConfigEntry when calling
verifyWorkerNodeCRIOCredentialProviderConfig with oc, expectedMatchImages,
workerNodes[0], and credentialProviderConfigPath.
- Around line 346-357: Pod spec omits RestartPolicy, so the container that runs
"exit 0" will keep restarting; update the PodSpec literal where Spec:
kapiv1.PodSpec{... NodeName: nodeName,} to include RestartPolicy:
kapiv1.RestartPolicyNever (same behavior as imagepolicy.launchTestPod) next to
NodeName to ensure the pod does not restart the exited container; look for the
PodSpec that uses contName and image in this file and add the RestartPolicy
field.
- Around line 61-78: The test registers cleanup only in the conditional branch,
causing config changes from updateCRIOCredentialProviderConfig to persist; call
g.DeferCleanup(cleanupCRIOCredentialProviderConfig, oc) immediately after the
initial updateCRIOCredentialProviderConfig(oc, expectedMatchImages, false)
(i.e., unconditionally inside the DescribeTable body) so cleanup is always
registered; keep the existing conditional cleanup registration for the update
path if desired but ensure the initial update always has a DeferCleanup to avoid
test pollution.
- Around line 117-118: The call to e2epod.WaitForPodContainerToFail discards its
error and also uses "ImagePullBackOff" which is a pod condition reason, not a
container termination reason; update the test to capture and check the returned
error from launchTestPod and from e2epod.WaitForPodContainerToFail (or replace
the latter with e2epod.WaitForPodCondition / clif.ClientSet wait helper) to wait
for the pod to reach the ImagePullBackOff pod condition, e.g. call launchTestPod
and handle its error, then call e2epod.WaitForPodCondition (or equivalent) to
assert pod.Status.Reason == "ImagePullBackOff" and fail the test on any returned
error from those calls.

---

Nitpick comments:
In `@test/extended/node/criocredentialprovider.go`:
- Around line 163-184: The helper functions (e.g.,
cleanupCRIOCredentialProviderConfig, createIDMSResources, cleanupIDMSResources,
createNamespaceRBAC, createSecret) declare and return error but call
o.Expect(...) which fails the test and then always return nil, making the error
return useless; either remove the error return from these helper signatures and
callers (convert to void helpers that call o.Expect on failures) or stop using
o.Expect inside them and instead return the encountered error (propagate the
error up) so callers can handle it—pick one approach and apply consistently:
update the function signatures (remove error) or replace o.Expect(...) with
returning the error in functions like cleanupCRIOCredentialProviderConfig, and
update all call sites accordingly.
- Around line 14-21: There are duplicate import aliases: both `corev1` and
`kapiv1` point to "k8s.io/api/core/v1", and `framework` and `e2e` point to
"k8s.io/kubernetes/test/e2e/framework"; remove the redundant aliases (keep
`corev1` and `e2e`) and update all references in this file (e.g., any uses of
`kapiv1` and `framework` within functions like the CRI credential provider test
helpers and test cases) to use `corev1` and `e2e` respectively so imports are
consolidated and usages are consistent.
- Around line 305-310: The RBAC Subject is incorrectly using rbacv1.UserKind
with a constructed service-account string; change the Subject to use Kind:
rbacv1.ServiceAccountKind, clear APIGroup (empty string), put the namespace into
Subject.Namespace (e.g. f.Namespace.Name) and use Name: "default" (the SA name)
so the Subjects entry (the slice being built) becomes a proper ServiceAccount
subject; update the block that constructs the Subject accordingly.
- Around line 208-213: The code is doing redundant conversions like
string(apicfgv1alpha1.MatchImage(img)) even though img is already a string;
update the two checks to use the plain img (or apicfgv1alpha1.MatchImage(img)
without the extra string(...) wrapper) when calling
o.ContainSubstring/NotTo(o.ContainSubstring) for variables expectedMatchImages
and excludedMatchImages, keeping the rest of the assertion text and references
to out, o.Expect and nodeName unchanged.

ℹ️ Review info

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 02e33c2 and 3b8fd60.

⛔ Files ignored due to path filters (105)
  • go.sum is excluded by !**/*.sum
  • vendor/github.com/openshift/api/.coderabbit.yaml is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/.golangci.go-validated.yaml is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/.golangci.yaml is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/Makefile is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/apiextensions/v1alpha1/types_compatibilityrequirement.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/apiextensions/v1alpha1/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/apiextensions/v1alpha1/zz_generated.swagger_doc_generated.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/apps/v1/types.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/apps/v1/zz_prerelease_lifecycle_generated.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1/types_apiserver.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1/types_authentication.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1/types_infrastructure.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1/types_insights.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1/types_network.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1/types_tlssecurityprofile.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/config/v1/zz_generated.swagger_doc_generated.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/config/v1alpha1/register.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1alpha1/types_backup.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1alpha1/types_cluster_monitoring.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1alpha1/types_crio_credential_provider_config.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1alpha1/types_insights.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1alpha1/zz_generated.deepcopy.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/config/v1alpha1/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/config/v1alpha1/zz_generated.swagger_doc_generated.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/config/v1alpha2/types_insights.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/config/v1alpha2/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/console/v1/types_console_sample.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/etcd/README.md is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/etcd/install.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/etcd/v1alpha1/Makefile is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/etcd/v1alpha1/doc.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/etcd/v1alpha1/register.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/etcd/v1alpha1/types_pacemakercluster.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/etcd/v1alpha1/zz_generated.deepcopy.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/etcd/v1alpha1/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/etcd/v1alpha1/zz_generated.swagger_doc_generated.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/features.md is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/features/features.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/features/legacyfeaturegates.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/features/util.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/install.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/machine/v1/types_controlplanemachineset.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/machine/v1/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/machine/v1beta1/types_awsprovider.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/machine/v1beta1/types_machine.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/machine/v1beta1/types_machineset.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/machine/v1beta1/zz_generated.deepcopy.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/machine/v1beta1/zz_generated.swagger_doc_generated.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/machineconfiguration/v1/types.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/machineconfiguration/v1alpha1/types_osimagestream.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/machineconfiguration/v1alpha1/zz_generated.swagger_doc_generated.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/operator/v1/types_machineconfiguration.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/operator/v1/types_network.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/operator/v1/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/operator/v1alpha1/register.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/operator/v1alpha1/types_clusterapi.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.deepcopy.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/operator/v1alpha1/zz_generated.swagger_doc_generated.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/operatoringress/v1/types.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/api/operatoringress/v1/zz_generated.featuregated-crd-manifests.yaml is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/api/operatoringress/v1/zz_generated.swagger_doc_generated.go is excluded by !**/vendor/**, !vendor/**, !**/zz_generated*
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/acceptrisk.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/clusterversionstatus.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/conditionalupdate.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/conditionalupdaterisk.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/oidcprovider.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/tokenclaimvalidationcelrule.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/tokenclaimvalidationrule.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/tokenissuer.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/tokenuservalidationrule.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1/update.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1alpha1/clustermonitoringspec.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1alpha1/criocredentialproviderconfig.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1alpha1/criocredentialproviderconfigspec.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1alpha1/criocredentialproviderconfigstatus.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/config/v1alpha1/prometheusoperatorconfig.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/internal/internal.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/applyconfigurations/utils.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1alpha1/config_client.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1alpha1/criocredentialproviderconfig.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1alpha1/fake/fake_config_client.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1alpha1/fake/fake_criocredentialproviderconfig.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/clientset/versioned/typed/config/v1alpha1/generated_expansion.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/informers/externalversions/config/v1alpha1/criocredentialproviderconfig.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/informers/externalversions/config/v1alpha1/interface.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/informers/externalversions/generic.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/listers/config/v1alpha1/criocredentialproviderconfig.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/config/listers/config/v1alpha1/expansion_generated.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/machine/applyconfigurations/internal/internal.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinesetstatus.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/machine/applyconfigurations/machine/v1beta1/machinestatus.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/applyconfigurations/internal/internal.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/applyconfigurations/operator/v1alpha1/clusterapi.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/applyconfigurations/operator/v1alpha1/clusterapiinstallercomponent.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/applyconfigurations/operator/v1alpha1/clusterapiinstallercomponentimage.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/applyconfigurations/operator/v1alpha1/clusterapiinstallerrevision.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/applyconfigurations/operator/v1alpha1/clusterapispec.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/applyconfigurations/operator/v1alpha1/clusterapistatus.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/clientset/versioned/typed/operator/v1alpha1/clusterapi.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/clientset/versioned/typed/operator/v1alpha1/generated_expansion.go is excluded by !**/vendor/**, !vendor/**
  • vendor/github.com/openshift/client-go/operator/clientset/versioned/typed/operator/v1alpha1/operator_client.go is excluded by !**/vendor/**, !vendor/**
  • vendor/modules.txt is excluded by !**/vendor/**, !vendor/**
📒 Files selected for processing (3)
  • go.mod
  • test/extended/imagepolicy/imagepolicy.go
  • test/extended/node/criocredentialprovider.go

Comment on lines +61 to +78
g.DescribeTable("criocredentialproviderconfig tests",
func(expectedMatchImages, updatedMatchImages, excludedMatchImages []string, expectCRIOProviderConfigEntry bool) {
updateCRIOCredentialProviderConfig(oc, expectedMatchImages, false)

// verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, nil, workerNodes[0], credentialProviderConfigPath, true)

if updatedMatchImages != nil && expectCRIOProviderConfigEntry {
updateCRIOCredentialProviderConfig(oc, updatedMatchImages, false)
g.DeferCleanup(cleanupCRIOCredentialProviderConfig, oc)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, updatedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, true)
}

if !expectCRIOProviderConfigEntry {
cleanupCRIOCredentialProviderConfig(oc)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, nil, nil, workerNodes[0], credentialProviderConfigPath, false)
}

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Missing cleanup registration for all test entries.

The first test entry ("pass update criocredentialproviderconfig...") modifies the config at line 63 but g.DeferCleanup is only registered conditionally inside the if block at line 70. This means the config won't be cleaned up after the first test entry, potentially causing test pollution.

🐛 Proposed fix
 	g.DescribeTable("criocredentialproviderconfig tests",
 		func(expectedMatchImages, updatedMatchImages, excludedMatchImages []string, expectCRIOProviderConfigEntry bool) {
 			updateCRIOCredentialProviderConfig(oc, expectedMatchImages, false)
+			g.DeferCleanup(cleanupCRIOCredentialProviderConfig, oc)

-			// verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
-			verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, nil, workerNodes[0], credentialProviderConfigPath, true)
+			verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)

 			if updatedMatchImages != nil && expectCRIOProviderConfigEntry {
 				updateCRIOCredentialProviderConfig(oc, updatedMatchImages, false)
-				g.DeferCleanup(cleanupCRIOCredentialProviderConfig, oc)
 				verifyWorkerNodeCRIOCredentialProviderConfig(oc, updatedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, true)
 			}

-			if !expectCRIOProviderConfigEntry {
-				cleanupCRIOCredentialProviderConfig(oc)
-				verifyWorkerNodeCRIOCredentialProviderConfig(oc, nil, nil, workerNodes[0], credentialProviderConfigPath, false)
-			}
-
 		},
📝 Committable suggestion

‼️ 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.

Suggested change
g.DescribeTable("criocredentialproviderconfig tests",
func(expectedMatchImages, updatedMatchImages, excludedMatchImages []string, expectCRIOProviderConfigEntry bool) {
updateCRIOCredentialProviderConfig(oc, expectedMatchImages, false)
// verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, nil, workerNodes[0], credentialProviderConfigPath, true)
if updatedMatchImages != nil && expectCRIOProviderConfigEntry {
updateCRIOCredentialProviderConfig(oc, updatedMatchImages, false)
g.DeferCleanup(cleanupCRIOCredentialProviderConfig, oc)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, updatedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, true)
}
if !expectCRIOProviderConfigEntry {
cleanupCRIOCredentialProviderConfig(oc)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, nil, nil, workerNodes[0], credentialProviderConfigPath, false)
}
g.DescribeTable("criocredentialproviderconfig tests",
func(expectedMatchImages, updatedMatchImages, excludedMatchImages []string, expectCRIOProviderConfigEntry bool) {
updateCRIOCredentialProviderConfig(oc, expectedMatchImages, false)
g.DeferCleanup(cleanupCRIOCredentialProviderConfig, oc)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
if updatedMatchImages != nil && expectCRIOProviderConfigEntry {
updateCRIOCredentialProviderConfig(oc, updatedMatchImages, false)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, updatedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, true)
}
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/node/criocredentialprovider.go` around lines 61 - 78, The test
registers cleanup only in the conditional branch, causing config changes from
updateCRIOCredentialProviderConfig to persist; call
g.DeferCleanup(cleanupCRIOCredentialProviderConfig, oc) immediately after the
initial updateCRIOCredentialProviderConfig(oc, expectedMatchImages, false)
(i.e., unconditionally inside the DescribeTable body) so cleanup is always
registered; keep the existing conditional cleanup registration for the update
path if desired but ensure the initial update always has a DeferCleanup to avoid
test pollution.

Comment on lines +65 to +66
// verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, nil, workerNodes[0], credentialProviderConfigPath, true)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Test logic is using hardcoded values instead of table parameters.

Line 65 is commented out and line 66 uses hardcoded nil and true instead of the table parameters excludedMatchImages and expectCRIOProviderConfigEntry. This defeats the purpose of the parameterized test.

🐛 Proposed fix
-			// verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
-			verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, nil, workerNodes[0], credentialProviderConfigPath, true)
+			verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
📝 Committable suggestion

‼️ 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.

Suggested change
// verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, nil, workerNodes[0], credentialProviderConfigPath, true)
verifyWorkerNodeCRIOCredentialProviderConfig(oc, expectedMatchImages, excludedMatchImages, workerNodes[0], credentialProviderConfigPath, expectCRIOProviderConfigEntry)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/node/criocredentialprovider.go` around lines 65 - 66, The test
call to verifyWorkerNodeCRIOCredentialProviderConfig incorrectly passes
hardcoded values (nil, true) instead of the table-driven variables; change the
invocation to pass excludedMatchImages and expectCRIOProviderConfigEntry (i.e.,
restore the commented-out form) so the test uses the parameterized values for
excludedMatchImages and expectCRIOProviderConfigEntry when calling
verifyWorkerNodeCRIOCredentialProviderConfig with oc, expectedMatchImages,
workerNodes[0], and credentialProviderConfigPath.

Comment on lines +117 to +118
pod, _ := launchTestPod(context.Background(), clif, "dummy-pod", dummypodImage, workerNodes[0].Name)
e2epod.WaitForPodContainerToFail(context.Background(), clif.ClientSet, pod.Namespace, pod.Name, 0, "ImagePullBackOff", e2e.PodStartShortTimeout)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Error handling missing and potential incorrect wait condition.

The return value from WaitForPodContainerToFail is discarded. Additionally, ImagePullBackOff is a pod waiting reason, not typically a container termination reason that WaitForPodContainerToFail checks.

Consider using e2epod.WaitForPodCondition or similar to wait for the expected image pull failure state, and verify the error is handled:

-		pod, _ := launchTestPod(context.Background(), clif, "dummy-pod", dummypodImage, workerNodes[0].Name)
-		e2epod.WaitForPodContainerToFail(context.Background(), clif.ClientSet, pod.Namespace, pod.Name, 0, "ImagePullBackOff", e2e.PodStartShortTimeout)
+		pod, err := launchTestPod(context.Background(), clif, "dummy-pod", dummypodImage, workerNodes[0].Name)
+		o.Expect(err).NotTo(o.HaveOccurred())
+		g.DeferCleanup(func() { clif.ClientSet.CoreV1().Pods(pod.Namespace).Delete(context.Background(), pod.Name, metav1.DeleteOptions{}) })
+		// Verify image pull failure - consider using WaitForPodCondition for waiting reasons
+		err = e2epod.WaitForPodContainerToFail(context.Background(), clif.ClientSet, pod.Namespace, pod.Name, 0, "ImagePullBackOff", e2e.PodStartShortTimeout)
+		o.Expect(err).NotTo(o.HaveOccurred())
#!/bin/bash
# Check WaitForPodContainerToFail signature and usage in e2e framework
ast-grep --pattern 'func WaitForPodContainerToFail($$$) $$$'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/node/criocredentialprovider.go` around lines 117 - 118, The
call to e2epod.WaitForPodContainerToFail discards its error and also uses
"ImagePullBackOff" which is a pod condition reason, not a container termination
reason; update the test to capture and check the returned error from
launchTestPod and from e2epod.WaitForPodContainerToFail (or replace the latter
with e2epod.WaitForPodCondition / clif.ClientSet wait helper) to wait for the
pod to reach the ImagePullBackOff pod condition, e.g. call launchTestPod and
handle its error, then call e2epod.WaitForPodCondition (or equivalent) to assert
pod.Status.Reason == "ImagePullBackOff" and fail the test on any returned error
from those calls.

Comment on lines +346 to +357
Spec: kapiv1.PodSpec{
Containers: []kapiv1.Container{
{
Name: contName,
Image: image,
ImagePullPolicy: kapiv1.PullAlways,
Command: []string{"/bin/sh", "-c", "exit 0"},
},
},
NodeName: nodeName,
},
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Missing RestartPolicy in pod spec.

The pod spec is missing RestartPolicy. Without it, the default is Always, which would cause the container running exit 0 to restart continuously. Compare with imagepolicy.launchTestPod which sets RestartPolicy: kapiv1.RestartPolicyNever.

🐛 Proposed fix
 		Spec: kapiv1.PodSpec{
 			Containers: []kapiv1.Container{
 				{
 					Name:            contName,
 					Image:           image,
 					ImagePullPolicy: kapiv1.PullAlways,
 					Command:         []string{"/bin/sh", "-c", "exit 0"},
 				},
 			},
-			NodeName: nodeName,
+			NodeName:      nodeName,
+			RestartPolicy: kapiv1.RestartPolicyNever,
 		},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/extended/node/criocredentialprovider.go` around lines 346 - 357, Pod
spec omits RestartPolicy, so the container that runs "exit 0" will keep
restarting; update the PodSpec literal where Spec: kapiv1.PodSpec{... NodeName:
nodeName,} to include RestartPolicy: kapiv1.RestartPolicyNever (same behavior as
imagepolicy.launchTestPod) next to NodeName to ensure the pod does not restart
the exited container; look for the PodSpec that uses contName and image in this
file and add the RestartPolicy field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. vendor-update Touching vendor dir or related files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants