Skip to content

OCPNODE-4535: Automate OCP-44820 change container registry config#31182

Open
Chandan9112 wants to merge 1 commit into
openshift:mainfrom
Chandan9112:automate-ocp-44820
Open

OCPNODE-4535: Automate OCP-44820 change container registry config#31182
Chandan9112 wants to merge 1 commit into
openshift:mainfrom
Chandan9112:automate-ocp-44820

Conversation

@Chandan9112
Copy link
Copy Markdown
Contributor

@Chandan9112 Chandan9112 commented May 15, 2026

Summary

  • Automates OCP-44820: verifies that updating image.config.openshift.io/cluster with containerRuntimeSearchRegistries and allowedRegistries triggers an MCO rollout and the change is reflected in /etc/containers/registries.conf.d/01-image-searchRegistries.conf on worker nodes.

Here is the test case link: Polarian-44820

Test Results

It passed successfully while executing on a live OCP 4.22 cluster:

./openshift-tests run-test "[Suite:openshift/disruptive-longrunning][sig-node][Disruptive] Image registry config [OTP] change container registry config [OCP-44820] [Serial]"

  Running Suite:  - /Users/cmaurya/go/src/github.com/openshift/origin
  ===================================================================
  Random Seed: 1778749374 - will randomize all specs

  Will run 1 of 1 specs
  ------------------------------
  [Suite:openshift/disruptive-longrunning][sig-node][Disruptive] Image registry config [OTP] change container registry config [OCP-44820]
  github.com/openshift/origin/test/extended/node/node_e2e/node.go:289
    STEP: Creating a kubernetes client @ 05/14/26 14:32:59.323
  I0514 14:32:59.324618    9619 discovery.go:214] Invalidating discovery information
  I0514 14:32:59.325418 9619 framework.go:2330] [precondition-check] checking if cluster is MicroShift
  I0514 14:32:59.634319 9619 framework.go:2353] IsMicroShiftCluster: microshift-version configmap not found, not MicroShift
    STEP: Save the original image.config for later restore @ 05/14/26 14:32:59.634
    STEP: Update image.config to add search registry and allowed registries @ 05/14/26 14:33:00.652
    STEP: Wait for worker and master MCP rollout to complete @ 05/14/26 14:33:01.282
  I0514 14:33:01.282442 9619 imagepolicy.go:694] Waiting for pool worker to complete
  I0514 14:44:33.911003 9619 imagepolicy.go:694] Waiting for pool master to complete
    STEP: Verify search registries config on a worker node @ 05/14/26 14:54:32.895
  I0514 14:54:48.170782 9619 node.go:368] Registries config on ci-ln-dj6qsnt-72292-vqk8q-worker-a-v5hd4:
  unqualified-search-registries = ["registry.access.redhat.com", "docker.io", "quay.io", "qe.quay.io"]
  short-name-mode = ""
  additional-layer-store-auth-helper = ""
  I0514 14:54:48.179261 9619 node.go:301] Cleanup: restoring original image.config
  I0514 14:54:49.484899 9619 imagepolicy.go:694] Waiting for pool worker to complete
  I0514 15:03:15.423287 9619 imagepolicy.go:694] Waiting for pool master to complete
  I0514 15:11:03.589844 9619 node.go:321] Cleanup: waiting for all cluster operators to settle
  I0514 15:11:03.675772 9619 settle.go:38] Waiting for operators to settle
  • [1964.612 seconds]
  ------------------------------

  Ran 1 of 1 Specs in 1964.614 seconds
  SUCCESS! -- 1 Passed | 0 Failed | 0 Pending | 0 Skipped

Summary by CodeRabbit

  • Tests
    • Added a disruptive long-running e2e suite "Image registry config" to verify a configured search registry is applied on ready, schedulable worker nodes.
    • Skips MicroShift clusters and when cluster-type detection fails.
    • Applies and restores cluster image registry settings with conflict-aware retries, waits for machine-config pool rollouts, optionally waits for cluster operators to settle, and logs warnings if restore/convergence/settle steps fail.

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

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-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 15, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 15, 2026

@Chandan9112: This pull request references OCPNODE-4535 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 "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Migrates OCP-45351 (ContainerRuntimeConfig pidsLimit + conmon verification) from openshift-tests-private to Origin.
  • Automates OCP-44820 (change container registry config: add search registries and allowedRegistries via image.config.openshift.io/cluster, verify MCO rollout lands on nodes).
  • Uses existing helper functions (imagepolicy.WaitForMCPConfigSpecChangeAndUpdated, nodeutils.ExecOnNodeWithChroot, operator.WaitForOperatorsToSettle) and follows Ginkgo style guide conventions.

Test plan

  • Both tests pass on a local cluster ([OCP-45351] and [OCP-44820])
  • CI passes

/cc @openshift/sig-node

Made with Cursor

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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 15, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 15, 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

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 15, 2026

@Chandan9112: GitHub didn't allow me to request PR reviews from the following users: openshift/sig-node.

Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs.

Details

In response to this:

Summary

  • Migrates OCP-45351 (ContainerRuntimeConfig pidsLimit + conmon verification) from openshift-tests-private to Origin.
  • Automates OCP-44820 (change container registry config: add search registries and allowedRegistries via image.config.openshift.io/cluster, verify MCO rollout lands on nodes).
  • Uses existing helper functions (imagepolicy.WaitForMCPConfigSpecChangeAndUpdated, nodeutils.ExecOnNodeWithChroot, operator.WaitForOperatorsToSettle) and follows Ginkgo style guide conventions.

Test plan

  • Both tests pass on a local cluster ([OCP-45351] and [OCP-44820])
  • CI passes

/cc @openshift/sig-node

Made with Cursor

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

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:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds imports for conflict-aware retries and an operator test helper, and a disruptive serial e2e that patches cluster ImageConfig (allowed/search registries) with RetryOnConflict, waits for MCP rollout, verifies node registry config, and restores the original ImageConfig.

Changes

Node e2e registry config

Layer / File(s) Summary
Imports update
test/extended/node/node_e2e/node.go
Adds Kubernetes retry utilities and the operator test helper to the node e2e imports.
Image registry config test suite
test/extended/node/node_e2e/node.go
Adds a [sig-node][Disruptive] Image registry config e2e: records current image.config.openshift.io/cluster, updates AllowedRegistries and ContainerRuntimeSearchRegistries (adds a search registry) using retry.RetryOnConflict, waits for MachineConfigPool rollout, verifies /etc/containers/registries.conf.d/01-image-searchRegistries.conf on a ready schedulable worker via Eventually, and defers cleanup that restores the original ImageConfig with conflict-aware retries and waits for MCP/cluster operator convergence.
sequenceDiagram
  participant Test as ImageRegistryConfigTest
  participant API as ImageConfig API
  participant MCP as MachineConfigPool
  participant Node as Worker node
  Test->>API: GET current image.config.openshift.io/cluster
  Test->>API: RetryOnConflict PATCH update registry sources
  API->>MCP: apply updated spec
  MCP->>Node: rollout MachineConfig
  Test->>Node: check /etc/containers/registries.conf.d/01-image-searchRegistries.conf
  Test->>API: RetryOnConflict PATCH restore original image.config
  MCP->>Node: converge to restored spec
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • openshift/origin#31142: Adds a similar disruptive e2e in test/extended/node/node_e2e/node.go that patches image/registry configuration and waits for MCP rollout before verifying node registry files.

Suggested reviewers

  • mrunalp
🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Single Node Openshift (Sno) Test Compatibility ⚠️ Warning Test expects multiple worker nodes. GetReadySchedulableWorkerNodes filters out master-labeled nodes. SNO nodes have both labels, causing empty list and test failure. Add [Skipped:SingleReplicaTopology] label to test line 335, or add exutil.IsSingleNode() skip check. See custom check instructions for implementation details.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: automating a test (OCP-44820) for container registry config updates, which matches the file additions and test suite introduction.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Stable And Deterministic Test Names ✅ Passed Test names are static and deterministic with no dynamic information, timestamps, UUIDs, node names, or pod names. Dynamic values are appropriately placed in test bodies.
Test Structure And Quality ✅ Passed Single responsibility (one behavior tested), setup/cleanup properly used, timeouts on cluster operations, descriptive assertion messages, consistent with codebase patterns.
Microshift Test Compatibility ✅ Passed Test has BeforeEach hook in Describe block that checks exutil.IsMicroShiftCluster() and skips if MicroShift detected, protecting test from unavailable MachineConfig APIs.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only test/extended/node/node_e2e/node.go—a test file, not a deployment manifest, operator, or controller. Check applies only to production resources.
Ote Binary Stdout Contract ✅ Passed No stdout contract violations detected. Module code limited to g.Describe. No init(), main(), problematic prints, or klog writes. Logging via e2e.Logf (framework-safe). Clean test structure.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Test has no IPv4 assumptions or external connectivity requirements. It only updates Kubernetes config and verifies via local node file reads.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@Chandan9112 Chandan9112 force-pushed the automate-ocp-44820 branch from ef40051 to 6e92bbc Compare May 15, 2026 09:01
@Chandan9112 Chandan9112 changed the title OCPNODE-4535: Automate OCP-44820 and OCP-45351 node tests OCPNODE-4535: Automate OCP-44820 change container registry config May 15, 2026
@openshift-merge-bot openshift-merge-bot Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label May 15, 2026
Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (1)
test/extended/node/node_e2e/node.go (1)

357-360: 💤 Low value

Early return on restore failure prevents MCP convergence wait.

If restoring the original image.config fails, the cleanup returns immediately without waiting for MCP rollout or operator stabilization. This may leave the cluster in an intermediate state. However, since the restore itself failed, there's little value in waiting for MCP convergence of a potentially incomplete update.

Consider adding a log message indicating that MCP waits are being skipped due to restore failure, to make the behavior more explicit.

📝 Proposed improvement for clarity
 		if restoreErr != nil {
-			e2e.Logf("WARNING: failed to restore original image.config: %v", restoreErr)
+			e2e.Logf("WARNING: failed to restore original image.config: %v; skipping MCP convergence wait", restoreErr)
 			return
 		}
🤖 Prompt for AI Agents
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/extended/node/node_e2e/node.go` around lines 357 - 360, The cleanup path
currently returns immediately when restoreErr != nil in the block that attempts
to restore the original image.config; update that block (the if restoreErr !=
nil branch) to log an explicit message that MCP rollout/operator stabilization
waits are being skipped because the restore failed (mention restoreErr in the
log for context) before returning so readers know why MCP waits are omitted;
modify the code around the restore of image.config (the restoreErr check) to add
this log entry referencing restoreErr and then return as before.
🤖 Prompt for all review comments with AI agents
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/extended/node/node_e2e/node.go`:
- Around line 373-389: The code assigns to imageConfig.Spec.RegistrySources
fields without nil-checking; inside the retry.RetryOnConflict block (where you
call oc.AdminConfigClient().ConfigV1().Images().Get and later Update), check if
imageConfig.Spec.RegistrySources is nil and if so initialize it (e.g., set
imageConfig.Spec.RegistrySources = &configv1.RegistrySources{} ) before setting
AllowedRegistries and ContainerRuntimeSearchRegistries to avoid a runtime panic
when RegistrySources is nil.

---

Nitpick comments:
In `@test/extended/node/node_e2e/node.go`:
- Around line 357-360: The cleanup path currently returns immediately when
restoreErr != nil in the block that attempts to restore the original
image.config; update that block (the if restoreErr != nil branch) to log an
explicit message that MCP rollout/operator stabilization waits are being skipped
because the restore failed (mention restoreErr in the log for context) before
returning so readers know why MCP waits are omitted; modify the code around the
restore of image.config (the restoreErr check) to add this log entry referencing
restoreErr and then return as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: f2d72291-5f8c-48e4-9b6b-2790534d5327

📥 Commits

Reviewing files that changed from the base of the PR and between ef40051 and 6e92bbc.

📒 Files selected for processing (1)
  • test/extended/node/node_e2e/node.go

Comment thread test/extended/node/node_e2e/node.go Outdated
Comment on lines +373 to +389
g.By("Update image.config to add search registry and allowed registries")
err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
imageConfig, getErr := oc.AdminConfigClient().ConfigV1().Images().Get(ctx, "cluster", metav1.GetOptions{})
if getErr != nil {
return getErr
}
imageConfig.Spec.RegistrySources.AllowedRegistries = []string{
"registry.access.redhat.com", "docker.io", "quay.io", searchRegistry,
"image-registry.openshift-image-registry.svc:5000",
}
imageConfig.Spec.RegistrySources.ContainerRuntimeSearchRegistries = []string{
"registry.access.redhat.com", "docker.io", "quay.io", searchRegistry,
}
_, updateErr := oc.AdminConfigClient().ConfigV1().Images().Update(ctx, imageConfig, metav1.UpdateOptions{})
return updateErr
})
o.Expect(err).NotTo(o.HaveOccurred(), "failed to update image.config.openshift.io/cluster")
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot May 15, 2026

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Guard against nil RegistrySources to prevent panic.

Lines 379 and 383 set fields on imageConfig.Spec.RegistrySources without checking if it's nil. In the OpenShift configv1 API, ImageSpec.RegistrySources is a pointer and may be nil on a fresh cluster or after certain operations. Accessing fields on a nil pointer will cause a runtime panic.

🛡️ Proposed fix to initialize RegistrySources if nil
 		g.By("Update image.config to add search registry and allowed registries")
 		err = retry.RetryOnConflict(retry.DefaultBackoff, func() error {
 			imageConfig, getErr := oc.AdminConfigClient().ConfigV1().Images().Get(ctx, "cluster", metav1.GetOptions{})
 			if getErr != nil {
 				return getErr
 			}
+			if imageConfig.Spec.RegistrySources == nil {
+				imageConfig.Spec.RegistrySources = &configv1.RegistrySources{}
+			}
 			imageConfig.Spec.RegistrySources.AllowedRegistries = []string{
 				"registry.access.redhat.com", "docker.io", "quay.io", searchRegistry,
 				"image-registry.openshift-image-registry.svc:5000",
 			}
🤖 Prompt for AI Agents
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/extended/node/node_e2e/node.go` around lines 373 - 389, The code assigns
to imageConfig.Spec.RegistrySources fields without nil-checking; inside the
retry.RetryOnConflict block (where you call
oc.AdminConfigClient().ConfigV1().Images().Get and later Update), check if
imageConfig.Spec.RegistrySources is nil and if so initialize it (e.g., set
imageConfig.Spec.RegistrySources = &configv1.RegistrySources{} ) before setting
AllowedRegistries and ContainerRuntimeSearchRegistries to avoid a runtime panic
when RegistrySources is nil.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed in latest commit

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -n "RegistrySources" test/extended/node/node_e2e/node.go

Length of output: 235


@Chandan9112, it looks like the nil guard hasn't landed in the PR branch yet. The current code on automate-ocp-44820 still directly accesses RegistrySources fields without checking for nil (Lines 379 and 383):

imageConfig.Spec.RegistrySources.AllowedRegistries = []string{...}
imageConfig.Spec.RegistrySources.ContainerRuntimeSearchRegistries = []string{...}

Could you double-check that the commit was pushed to the remote branch? Once the nil guard is present, the fix would look like:

if imageConfig.Spec.RegistrySources == nil {
    imageConfig.Spec.RegistrySources = &configv1.RegistrySources{}
}
imageConfig.Spec.RegistrySources.AllowedRegistries = []string{
    "registry.access.redhat.com", "docker.io", "quay.io", searchRegistry,
    "image-registry.openshift-image-registry.svc:5000",
}
imageConfig.Spec.RegistrySources.ContainerRuntimeSearchRegistries = []string{
    "registry.access.redhat.com", "docker.io", "quay.io", searchRegistry,
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Chandan9112 Could you please address this comment. Thanks

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@coderabbitai., RegistrySources is a value type (struct), not a pointer, so it's always safe to assign fields on it directly — there's no nil dereference risk here. So I think no guard needed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find the ImageSpec and RegistrySources type definitions in the configv1 package
rg -n "RegistrySources" vendor/github.com/openshift/api/config/v1/ -A2 -B2 | head -60

Length of output: 83


🏁 Script executed:

#!/bin/bash
# Find the openshift API config v1 types file
fd "types_image.go" --type f
fd "types.go" --type f | xargs grep -l "RegistrySources" 2>/dev/null | head -5

Length of output: 0


🏁 Script executed:

#!/bin/bash
# Try to find the types_image.go file in the repo
fd "types_image" --type f 2>/dev/null
# Also search in any Go file for ImageSpec definition
rg -n "RegistrySources\s" --type go -A1 -B1 2>/dev/null | head -30

Length of output: 358


🏁 Script executed:

#!/bin/bash
# Check the image_registry_config.go file
cat test/extended/node/node_e2e/image_registry_config.go

echo "---"
# Find where openshift/api is defined (go.mod)
grep "openshift/api" go.mod | head -5

echo "---"
# Search for ImageSpec struct definition in any Go file in the repo
rg -n "type ImageSpec struct" --type go -A 10 2>/dev/null | head -40

echo "---"
# Check the Go module cache or vendor paths
find . -path "*/openshift/api/config/v1/types_image.go" 2>/dev/null | head -3

Length of output: 5272


🌐 Web query:

openshift api config v1 ImageSpec RegistrySources struct type definition golang

💡 Result:

Top web search findings:

  1. config/v1/types_image.go at 406574a7aa1eb0e916f4029433e5c28c6a53099b · openshift/api: // Image holds cluster-wide information about how to handle images. The canonical name is cluster type Image struct { metav1.TypeMeta json:",inline" // Standard object's metadata. metav1.ObjectMeta json:"metadata,omitempty" // spec holds user settable values for configuration // +kubebuilder:validation:Required // +required Spec ImageSpec json:"spec" // status holds observed values from the cluster. They may not be overridden. // +optional Status ImageStatus json:"status" } [...] type ImageSpec struct { // AllowedRegistriesForImport limits the container image registries that normal users may import // images from. Set this list to the registries that you trust to contain valid Docker // images and that you want applications to be able to import from. Users with // permission to create Images or ImageStreamMappings via the API are not affected by // this policy - typically only administrators or system integrations will have those // permissions. // +optional AllowedRegistriesForImport []RegistryLocation json:"allowedRegistriesForImport,omitempty" // externalRegistryHostnames provides the hostnames for the default external image // registry. The external hostname should be set only when the image registry // is exposed externally. The first value is used in 'publicDockerImageRepository' // field in ImageStreams. The value must be in "hostname[:port]" format. // +optional ExternalRegistryHostnames []string json:"externalRegistryHostnames,omitempty" [...] // AdditionalTrustedCA is a reference to a ConfigMap containing additional CAs that // should be trusted during imagestream import, pod image pull, and imageregistry // pullthrough. // The namespace for this config map is openshift-config. // +optional AdditionalTrustedCA ConfigMapNameReference json:"additionalTrustedCA" // RegistrySources contains configuration that determines how the container runtime // should treat individual registries when accessing images for builds+pods. (e.g. // whether or not to allow insecure access). It does not contain configuration for the // internal cluster registry. // +optional RegistrySources RegistrySources json:"registrySources" } [...] // RegistrySources holds cluster-wide information about how to handle the registries config. type RegistrySources struct { // InsecureRegistries are registries which do not have a valid TLS certificates or only support HTTP connections. // +optional InsecureRegistries []string json:"insecureRegistries,omitempty" // BlockedRegistries are blacklisted from image pull/push. All other registries are allowed. // // Only one of BlockedRegistries or AllowedRegistries may be set. // +optional BlockedRegistries []string json:"blockedRegistries,omitempty" // AllowedRegistries are whitelisted for image pull/push. All other registries are blocked. // // Only one of BlockedRegistries or AllowedRegistries may be set. // +optional AllowedRegistries []string json:"allowedRegistries,omitempty" }
  2. v1 package versions - github.com/openshift/api/config/v1 - Go Packages: +type Image struct [...] +type ImageSpec struct [...] +AdditionalTrustedCA ConfigMapNameReference [...] +AllowedRegistriesForImport []RegistryLocation [...] +ExternalRegistryHostnames []string [...] +RegistrySources RegistrySources [...] +func (ImageSpec) SwaggerDoc() map[string]string [...] +func (in *ImageSpec) DeepCopy() *ImageSpec [...] +func (in *ImageSpec) DeepCopyInto(out *ImageSpec)
  3. Chapter 6. Image configuration resources | Images | OpenShift Container Platform | 4.1 | Red Hat Documentation: ImageSpec [...] that you trust to [...] registrySources: Contains configuration that determines how the container runtime should treat individual registries when accessing images for builds and pods. For instance, whether or not to allow insecure access. It does not contain configuration for the internal cluster registry. [...] RegistrySources [...] Holds cluster-wide information about how to handle the registries config. [...] ```yaml name: myconfigmap registrySources: [...] registrySources: Contains configuration that determines how the container runtime should treat individual registries when accessing images for builds and pods. For instance, whether or not to allow insecure access. It does not contain configuration for the internal cluster registry. [...] spec: allowedRegistriesForImport: - domainName: quay.io insecure: false additionalTrustedCA: name: myconfigmap registrySources: insecureRegistries:
  4. v1 package - github.com/openshift/api/config/v1 - Go Packages: The canonical location of the OpenShift API definition. This repo holds the API type definitions and serialization code used by openshift/client-go APIs in this repo ship inside OCP payloads. [...] ## defining new APIs [...] When defining a new API, please follow the OpenShift API conventions, and then follow the instructions below to regenerate CRDs (if necessary) and submit a pull request with your new API definitions and generated files. [...] New APIs (new CRDs) must be added first as an unstable API (v1alpha1). Once the feature is more developed, and ready to be promoted to stable, the API can be promoted to v1. [...] ### Adding a new stable API (v1) [...] // // Compatibility level 1 [...] Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). [...] // +openshift:compatibility-gen [...] level=1 [...] // +openshift [...] _50 [...] operatorOrdering=01 [...] // +kubebuilder:object:root=true // +kubebuilder:subresource:status // +kubebuilder:resource:path=myapis,scope=Cluster // +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/ // +openshift:capability=IfYouHaveOne // +kubebuilder:printcolumn:name=Column Name,JSONPath=.status.something,type=string,description=how users should interpret this. // +kubebuilder:metadata:annotations=key=value // +kubebuilder:metadata:labels=key=value // +kubebuilder:validation:XValidation:rule= type MyAPI struct { metav1.TypeMeta json:",inline" // metadata is the standard object's metadata. // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata metav1.ObjectMeta json:"metadata,omitempty" // spec is the desired state of the cluster version - the operator will work // to ensure that the desired version is applied to the cluster. // +kubebuilder:validation:Required Spec MyAPISpec json:"spec" // status contains information about the available updates and any in-progress // updates. // +optional Status MyAPIStatus json:"status" } [...] ### Adding a new unstable API (v1alpha) [...]go // +kubebuilder:validation:XValidation:rule= // +openshift:enable:FeatureGate=MyFeatureGate type MyAPI struct { ... } [...]go // +openshift:validation:FeatureGateAwareXValidation:featureGate=MyFeatureGate,rule="has(oldSelf.coolNewField) ? has(self.coolNewField) : true",message="coolNewField may not be removed once set" type MyAPI struct { // +openshift:enable:FeatureGate=MyFeatureGate // +optional CoolNewField string json:"coolNewField" }
  5. Image [config.openshift.io/v1] - Config APIs | API reference | OKD 4.11: object [...] object [...] object [...] object [...] object [...] registrySources [...] object [...] registrySources contains configuration that determines how the container runtime should treat individual registries when accessing images for builds+pods. (e.g. whether or not to allow insecure access). It does not contain configuration for the internal cluster registry. [...] object [...] string [...] object [...] | Property | Type | Description | | --- | --- | --- | [...] ### .spec.registrySources [...] registrySources contains configuration that determines how the container runtime should treat individual registries when accessing images for builds+pods. (e.g. whether or not to allow insecure access). It does not contain configuration for the internal cluster registry. [...] object [...] allowedRegistries [...] blockedRegistries [...] array (string) [...] AllowedRegistries [...] containerRuntimeSearchRegistries [...] array (string) [...] insecureRegistries [...] array (string) [...] insecureRegistries [...] | Description | [...] | --- | --- | --- | [...] object [...] (string)[...]string[...] --- | --- [...]string[...]string[...]string[...]string[...]string[...]string[...]string`

Citations:


@Chandan9112, you're absolutely right — I apologize for the incorrect review. In the OpenShift API, ImageSpec.RegistrySources is declared as RegistrySources RegistrySources (a plain struct value, not a pointer), so it is always zero-initialized by Go and can never be nil. Accessing fields on it directly is completely safe, and no nil guard is needed. I'll retract the comment.


🏁 Script executed:

#!/bin/bash
# Resolve our own comment on this PR
gh api graphql -f query='
{
  repository(owner: "openshift", name: "origin") {
    pullRequest(number: 31182) {
      reviewThreads(first: 50) {
        nodes {
          id
          isResolved
          comments(first: 5) {
            nodes {
              id
              author { login }
              body
            }
          }
        }
      }
    }
  }
}'

Length of output: 4431


🏁 Script executed:

#!/bin/bash
# Resolve the review thread since the original comment was incorrect
gh api graphql -f query='
mutation {
  resolveReviewThread(input: {threadId: "PRRT_kwDOAVZyrM6CTwEE"}) {
    thread {
      id
      isResolved
    }
  }
}'

Length of output: 266


@Chandan9112, you are completely correct, and I apologize for the incorrect review. I've now verified against the upstream openshift/api source that ImageSpec.RegistrySources is declared as a plain struct value:

type ImageSpec struct {
    // ...
    RegistrySources RegistrySources `json:"registrySources"`
}

Since it's a value type (not a pointer), Go zero-initializes it automatically and it can never be nil. No nil guard is needed. The code is correct as-is.

I was unable to resolve the thread programmatically due to permissions, but please feel free to resolve it manually.


✏️ Learnings added
Learnt from: Chandan9112
Repo: openshift/origin PR: 31182
File: test/extended/node/node_e2e/node.go:0-0
Timestamp: 2026-05-19T12:28:55.867Z
Learning: In the OpenShift `configv1` API (`github.com/openshift/api/config/v1`), `ImageSpec.RegistrySources` is declared as a plain struct value (`RegistrySources RegistrySources`), NOT a pointer. It is always zero-initialized by Go and can never be nil. No nil-guard is needed before accessing its fields `AllowedRegistries`, `ContainerRuntimeSearchRegistries`, etc.

Learnt from: Chandan9112
Repo: openshift/origin PR: 31182
File: test/extended/node/node_e2e/node.go:0-0
Timestamp: 2026-05-19T12:28:55.867Z
Learning: In the OpenShift `configv1` API (`github.com/openshift/api/config/v1`), `ImageSpec.RegistrySources` is declared as a plain struct value (`RegistrySources RegistrySources`), NOT a pointer. It is always zero-initialized by Go and can never be nil. No nil-guard is needed before accessing its fields such as `AllowedRegistries` or `ContainerRuntimeSearchRegistries`.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@Chandan9112 Chandan9112 force-pushed the automate-ocp-44820 branch 3 times, most recently from e7848ff to e37496d Compare May 15, 2026 12:02
@Chandan9112 Chandan9112 marked this pull request as ready for review May 15, 2026 12:05
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 15, 2026
@openshift-ci openshift-ci Bot requested review from asahay19 and cpmeadors May 15, 2026 12:05
@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@Chandan9112
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-trt
Copy link
Copy Markdown

openshift-trt Bot commented May 18, 2026

Job Failure Risk Analysis for sha: e37496d

Job Name Failure Risk
pull-ci-openshift-origin-main-e2e-metal-ipi-ovn-ipv6 IncompleteTests
Tests for this run (20) are below the historical average (2869): IncompleteTests (not enough tests ran to make a reasonable risk analysis; this could be due to infra, installation, or upgrade problems)

@Chandan9112
Copy link
Copy Markdown
Contributor Author

/retest

@cpmeadors
Copy link
Copy Markdown
Contributor

@Chandan9112 we should have someone review this that is familiar with code, preferably someone who worked on the feature.

Comment thread test/extended/node/node_e2e/node.go Outdated
})
})

var _ = g.Describe("[Suite:openshift/disruptive-longrunning][sig-node][Disruptive] Image registry config", func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you put in a new file under the same directory?

@Chandan9112
Copy link
Copy Markdown
Contributor Author

@Chandan9112 we should have someone review this that is familiar with code, preferably someone who worked on the feature.

Hi @cpmeadors ., I got to know for MCO related PR we can get it reviewed from Neeraj.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 18, 2026

@Chandan9112: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-aws-ovn-serial-1of2 e37496d link true /test e2e-aws-ovn-serial-1of2

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@BhargaviGudi
Copy link
Copy Markdown
Contributor

Tests need to be documented in test/extended/node/README.md

Move the OCP-44820 test into its own file (image_registry_config.go)
and document it in README.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Chandan9112 Chandan9112 force-pushed the automate-ocp-44820 branch from e37496d to 072dec4 Compare May 19, 2026 12:24
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 19, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Chandan9112
Once this PR has been reviewed and has the lgtm label, please assign haircommander 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

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-aws-csi
/test e2e-aws-ovn-fips
/test e2e-aws-ovn-microshift
/test e2e-aws-ovn-microshift-serial
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-gcp-csi
/test e2e-gcp-ovn
/test e2e-gcp-ovn-upgrade
/test e2e-metal-ipi-ovn-ipv6
/test e2e-vsphere-ovn
/test e2e-vsphere-ovn-upi

@Chandan9112
Copy link
Copy Markdown
Contributor Author

/payload-job periodic-ci-openshift-release-main-nightly-4.22-e2e-aws-disruptive-longrunning

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 19, 2026

@Chandan9112: trigger 1 job(s) for the /payload-(with-prs|job|aggregate|job-with-prs|aggregate-with-prs) command

  • periodic-ci-openshift-release-main-nightly-4.22-e2e-aws-disruptive-longrunning

See details on https://pr-payload-tests.ci.openshift.org/runs/ci/f90f4f20-5382-11f1-9dcd-bb8b500d5873-0


g.BeforeEach(func() {
isMicroShift, err := exutil.IsMicroShiftCluster(oc.AdminKubeClient())
if err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we follow a common pattern:

o.Expect(err).NotTo(o.HaveOccurred())
		if isMicroShift {
			g.Skip("Skipping test on MicroShift cluster")
		}

Skipping this test is not good if there's an error in detecting the platform. The reports won't show the test itself and we'll think everything is passing

return updateErr
})
if restoreErr != nil {
e2e.Logf("WARNING: failed to restore original image.config: %v; skipping MCP convergence wait", restoreErr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why only a warning? Restoring to the correct state is also important for the test right? This should fail the test in my view.


e2e.Logf("Cleanup: waiting for all cluster operators to settle")
if waitErr := operator.WaitForOperatorsToSettle(ctx, oc.AdminConfigClient(), 10); waitErr != nil {
e2e.Logf("WARNING: cluster operators did not settle after restore: %v", waitErr)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above. Why only warn?

operator "github.com/openshift/origin/test/extended/util/operator"
)

var _ = g.Describe("[Suite:openshift/disruptive-longrunning][sig-node][Disruptive] Image registry config", func() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From the description I see that this test case takes 32 minutes to complete. Can we apply the config to just one master and one worker to reduce the time for this test case

}
return nil
}, 30*time.Second, 5*time.Second).Should(o.Succeed(),
"search registry %s not found in registries config on node %s", searchRegistry, workers[0].Name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why worker[0] is chosen here?

var registriesConf string
o.Eventually(func() error {
var execErr error
registriesConf, execErr = nodeutils.ExecOnNodeWithChroot(oc, workers[0].Name,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there another test case to check /etc/containers/policy.json is updated? If not, we need to check if that's updated

o.Eventually(func() error {
var execErr error
registriesConf, execErr = nodeutils.ExecOnNodeWithChroot(oc, workers[0].Name,
"cat", "/etc/containers/registries.conf.d/01-image-searchRegistries.conf")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why use cat? Can we directly use grep?

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants