Fix oc process namespace bug and PRGate LokiStack test flakiness - #4
Merged
IshwarKanse merged 3 commits intoSep 18, 2026
Merged
Conversation
processTemplate() invokes `oc process` server-side against the namespaced Template API. Without an explicit -n, the namespace falls back to the client's ambient kubeconfig context, which in CI resolves to a namespace that doesn't exist on the claimed test cluster, failing with "error processing file: failed to process template with the provided parameters". Add explicit -n to the 6 call sites that were missing it, matching the pattern already used elsewhere in this file (applyFromTemplate, OperatorGroup/Subscription, minio, lokiStack). Verified by reproducing the exact CI failure with a kubeconfig context pointed at a nonexistent namespace, and confirming the fix resolves it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dp1Dxge5p9yinA3yJggfFt
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
IshwarKanse
marked this pull request as draft
September 17, 2026 10:41
…tests While validating the namespace fix on a live cluster, several PRGate LokiStack tests intermittently failed with errors unrelated to that fix: - loki.go: "Reconcile and re-create objects on accidental user deletes" and "Define limits and overrides per tenant" listed pods and configmaps by component/created-by labels only. Since LokiStack tests share the openshift-logging namespace, and configmaps/pods from a deleted LokiStack are reaped asynchronously by garbage collection, these selectors could match resources belonging to a different, concurrently-running LokiStack test. Scoped every affected list/get by app.kubernetes.io/instance=<lokistack-name>, the same convention already used elsewhere in this codebase (loki_utils.go, logging_operators.go, scheduler.go, splunk_util.go). Also switched the configmap-count check from a single point-in-time List to a poll, since the controller can take a few seconds after LokiStack becomes Ready to finish creating all of them. - loki_utils.go: createSecretFromGateway() extracted the service-ca.crt key from a *-gateway-ca-bundle configmap immediately after checking the configmap exists, but the service-ca operator populates that key asynchronously after creating the configmap object. Added a poll for the key itself before extracting. Verified by rerunning the cluster-logging-operator and loki-operator PRGate suites, plus isolated reruns of each previously-failing test, against a live OCP 4.22 cluster with cluster-logging-operator, loki-operator, and opentelemetry-product installed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dp1Dxge5p9yinA3yJggfFt
IshwarKanse
marked this pull request as ready for review
September 17, 2026 11:11
…me prefix kabirbhartiRH pointed out that filtering controller-managed configmaps by strings.HasPrefix(cm.Name, ls.name+"-") could false-positive if two LokiStacks in the same namespace have names where one is a prefix of the other. The loki-operator already sets an exact-match app.kubernetes.io/instance=<stackName> label via commonLabels() on every configmap it manages (confirmed in operator/internal/manifests/var.go and config.go), so add it to the server-side label selector instead of filtering client-side by name. Verified on a live 4.22 cluster: case 48608, which exercises this exact code path, passes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dp1Dxge5p9yinA3yJggfFt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related fixes for PRGate test failures found while validating openshift/release#85177 on a live cluster:
1.
oc processcalls missing explicit namespaceprocessTemplate()invokesoc processserver-side against the namespaced Template API. Without an explicit-n, the namespace falls back to the client's ambient kubeconfig context. In the PRGate CI job (e2e-prgate), that ambient namespace doesn't exist on the claimed test cluster, causing:This was the root cause of the majority of PRGate test failures seen in the rehearsal runs (9/11 in cluster-logging-operator, 3/5 in loki-operator).
-nto the 6 call sites that were missing it:clusterlogforwarder.create(),clusterlogforwarder.update(),logFileMetricExporter.create(),eventRouter.deploy(),SubscriptionObjects.SubscribeOperator()'s namespace-creation branch, and the UIPlugin template processing inlogging_operators.go. Matches the pattern already used elsewhere inutils.go(applyFromTemplate, OperatorGroup/Subscription, minio, lokiStack).-n defaultroutes the call to an existing namespace.2. Cross-test resource collisions and a CA bundle race in LokiStack tests
While validating fix #1 by running the full PRGate suites repeatedly on a live cluster, several LokiStack tests intermittently failed with errors unrelated to the namespace bug:
loki.go— "Reconcile and re-create objects on accidental user deletes" and "Define limits and overrides per tenant" listed pods/configmaps by component or created-by labels only. Since LokiStack tests share theopenshift-loggingnamespace, and a deleted LokiStack's owned resources are garbage-collected asynchronously, these selectors could match resources belonging to a different, concurrently-running LokiStack test — one test even waited for a pod owned by a completely different test to disappear. Scoped every affected list/get byapp.kubernetes.io/instance=<lokistack-name>, the convention already used elsewhere in this codebase. Also switched the configmap-count check from a single point-in-timeListto a poll, since the controller can take a few seconds afterLokiStackbecomes Ready to finish creating them.loki_utils.go—createSecretFromGateway()extracted theservice-ca.crtkey from a*-gateway-ca-bundleconfigmap immediately after it appeared, before the service-ca operator had actually populated that key. Added a poll for the key itself before extracting.Verification
Reproduced and fixed on a live OCP 4.22 cluster with cluster-logging-operator, loki-operator, and opentelemetry-product installed:
default), both pre- and post-fix code pass — confirming this bug only manifests when the ambient namespace doesn't exist, as happens in CI.cluster-logging-operatorandloki-operatorPRGate suites repeatedly, plus isolated reruns of every distinct failure signature. The loki-operator suite went from 1/7 to consistently passing as each real bug was found and fixed; a small number of remaining failures in full-suite runs were confirmed via isolated reruns to be resource-contention artifacts of the small, freshly-provisioned validation cluster (cold image pulls, service-ca lag under load) — not defects, and not touched here per "don't change test intent."An independent code and security review (command injection, secret handling, resource leaks, error handling) found no blocking issues.
Test plan
make buildsucceeds