FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: handle transient errors and IsServerTimeout in TLS profile resolution by ugiordan · Pull Request #160 · opendatahub-io/feast · GitHub

fix: handle transient errors and IsServerTimeout in TLS profile resolution - #160

Closed
ugiordan wants to merge 1 commit into
opendatahub-io:masterfrom
ugiordan:feat/tls-intermediate-fallback
Closed

fix: handle transient errors and IsServerTimeout in TLS profile resolution#160
ugiordan wants to merge 1 commit into
opendatahub-io:masterfrom
ugiordan:feat/tls-intermediate-fallback

Conversation

ugiordan commented Jul 16, 2026
edited by coderabbitai Bot
Loading

Copy link
Copy Markdown
Member

Description

Cherry-pick from upstream feast-dev/feast#6567 plus IsServerTimeout fix.

The current TLS integration calls os.Exit(1) on all API errors except IsNoMatchError and IsNotFound. This means transient errors (API server unavailable, timeout, throttling) during startup prevent the operator from starting instead of falling back to Intermediate TLS defaults.

Changes

  1. Handle transient API errors (IsServiceUnavailable, IsTimeout, IsTooManyRequests, DeadlineExceeded) by falling back to Intermediate defaults and still registering the SecurityProfileWatcher for self-healing
  2. Add apierrors.IsServerTimeout (StatusReasonServerTimeout is distinct from StatusReasonTimeout)

Summary by CodeRabbit

  • Bug Fixes
    • Improved operator startup resilience by using intermediate TLS defaults when the API server TLS profile is missing or when transient API errors occur (with retries).
    • Prevents startup failures from TLS adherence policy lookup errors; adherence is only applied after a successful fetch while monitoring remains ready for later reloads.
    • Updated permission listing HTTP transport to explicitly negotiate supported protocols (h2, http/1.1) alongside insecure TLS behavior.

openshift-ci Bot commented Jul 16, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

ugiordan force-pushed the feat/tls-intermediate-fallback branch from 4591db8 to da15060 Compare July 16, 2026 15:03

coderabbitai Bot commented Jul 16, 2026
edited
Loading

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The operator now bounds APIServer TLS profile and adherence requests with 10-second timeout contexts. Transient TLS profile errors use Intermediate defaults and enable watcher-based reloads. TLS adherence errors no longer prevent startup; they are logged for watcher retries. TLS option storage is pre-sized, error comparisons use the standard errors package, and registry permissions requests advertise HTTP/2 and HTTP/1.1.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 8 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is relevant but does not follow the required template and omits the issue, checks, testing strategy, and misc sections. Rewrite the PR description using the repository template, including What this PR does, Which issue(s) it fixes, Checks, Testing Strategy, and Misc.
No Sensitive Data In Logs ⚠️ Warning client.go logs the full registry response body at V(1), which can expose customer data; this is CWE-532/CWE-200. Remove the raw body log or replace it with redacted metadata (e.g., counts, status) only.
✅ Passed checks (8 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, conventional, and matches the main TLS transient-error and server-timeout handling change.
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.
Contribution Quality And Spam Detection ✅ Passed Single-file ALPN tweak in a runtime client; no second independent signal of templated spam or security theater (no CWE/CVE pattern).
No Hardcoded Secrets ✅ Passed PASS: added literals are log strings and ALPN names; no new hardcoded secrets, base64 creds, or embedded credentials (CWE-798).
No Weak Cryptography ✅ Passed No banned primitives or secret comparisons were added; touched code uses HMAC-SHA256 and TLS NextProtos only, not CWE-327 weak crypto.
No Injection Vectors ✅ Passed Changed Go files only adjust TLS fallback and HTTP client config; no SQL/shell/eval/pickle/yaml/dangerous-HTML injection sinks or tainted execution paths.
No Privileged Containers ✅ Passed PASS: The PR touches only Go source files; no Kubernetes/OpenShift manifests, Helm templates, or Dockerfiles were changed, so no privileged-container settings were introduced.

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

coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actionable comments posted: 2

🤖 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 `@infra/feast-operator/cmd/main.go`:
- Around line 142-144: Update the bootstrap API call flow around bootstrapCtx so
FetchAPIServerTLSProfile and FetchAPIServerTLSAdherencePolicy each receive their
own independent 10-second context, rather than sharing a single timeout. Create
and cancel each context per call while preserving the existing timeout and
cancellation behavior.
- Around line 174-178: Update the TLS adherence fetch flow around
FetchAPIServerTLSAdherencePolicy so tlsAdherenceFetched is true only when the
fetch succeeds; leave it false on error, matching the existing tlsProfileFetched
behavior. Ensure watcher.InitialTLSAdherencePolicy is not wired from the
zero-value tlsAdherence when the policy fetch failed.
🪄 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: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 6319f14e-a132-4db8-8c99-857b968b24de

📥 Commits

Reviewing files that changed from the base of the PR and between c1e64e2 and da15060.

📒 Files selected for processing (1)
  • infra/feast-operator/cmd/main.go

Comment thread infra/feast-operator/cmd/main.go Outdated
Comment thread infra/feast-operator/cmd/main.go Outdated
ugiordan force-pushed the feat/tls-intermediate-fallback branch from da15060 to c7b9f67 Compare July 17, 2026 13:33

Copy link
Copy Markdown
Member Author

/retest

coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actionable comments posted: 1

🤖 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 `@infra/feast-operator/internal/controller/registry/client.go`:
- Around line 82-85: Remove InsecureSkipVerify from the TLSClientConfig used by
the registry client, and configure RootCAs with the trusted registry CA so
certificate and hostname validation remain enabled for all HTTPS requests.
Preserve the existing NextProtos settings.
🪄 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: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: c52be753-115b-4b3b-bf3d-34b4406c36b6

📥 Commits

Reviewing files that changed from the base of the PR and between c7b9f67 and 1a7c340.

📒 Files selected for processing (1)
  • infra/feast-operator/internal/controller/registry/client.go

Comment on lines +82 to +85
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
NextProtos: []string{"h2", "http/1.1"},
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🔒 Security & Privacy | 🔴 Critical | ⚡ Quick win

Remove InsecureSkipVerify (CWE-295).

Every registry HTTPS request bypasses certificate and hostname validation, allowing a man-in-the-middle attacker to intercept the bearer token and permission responses. Configure the registry’s trusted CA through RootCAs instead.

Proposed fix
 TLSClientConfig: &tls.Config{
-    InsecureSkipVerify: true,
-    NextProtos:         []string{"h2", "http/1.1"},
+    RootCAs:    trustedRegistryCAs,
+    NextProtos: []string{"h2", "http/1.1"},
 },
🧰 Tools 🪛 ast-grep (0.44.1)

[warning] 80-85: This http.Transport is configured with a tls.Config that sets InsecureSkipVerify: true, which disables TLS certificate verification for every request made through the resulting http.Client. The server's certificate chain and host name are not validated, exposing the connection to man-in-the-middle attacks. Remove InsecureSkipVerify (or set it to false) and supply a proper RootCAs pool if you need to trust custom certificates.
Context: http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
NextProtos: []string{"h2", "http/1.1"},
},
}
Note: [CWE-295] Improper Certificate Validation.

(http-transport-tls-skip-verify-go)

🪛 OpenGrep (1.25.0)

[ERROR] 82-85: TLS certificate verification is disabled via InsecureSkipVerify. This allows man-in-the-middle attacks. Remove InsecureSkipVerify or set it to false.

(coderabbit.tls.go-insecure-skip-verify)


[ERROR] 82-85: TLS certificate verification is disabled via InsecureSkipVerify. This allows man-in-the-middle attacks. Remove InsecureSkipVerify or set it to false.

(coderabbit.tls.go-insecure-skip-verify)

🤖 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 `@infra/feast-operator/internal/controller/registry/client.go` around lines 82
- 85, Remove InsecureSkipVerify from the TLSClientConfig used by the registry
client, and configure RootCAs with the trusted registry CA so certificate and
hostname validation remain enabled for all HTTPS requests. Preserve the existing
NextProtos settings.

Sources: Path instructions, Linters/SAST tools

Follow-up to feast-dev#6567. Fixes two issues in the TLS profile integration:

1. Else-only pattern: NewTLSConfigFromProfile was only called in the
   success branch of the TLS profile fetch. On any error path
   (non-OpenShift cluster, resource not found), no TLS config was
   applied, leaving the operator running with Go's bare defaults
   (no MinVersion, no cipher restrictions). This PR moves
   NewTLSConfigFromProfile outside the if/else and explicitly falls
   back to Intermediate on all error paths.

2. No transient error handling: The error switch only handled
   IsNotFound and IsNoMatchError. Transient API errors
   (ServiceUnavailable, Timeout, ServerTimeout, TooManyRequests,
   context.DeadlineExceeded) hit the default case and crashed the
   operator with os.Exit(1). This PR adds a dedicated case for these
   errors with a graceful Intermediate fallback. tlsProfileFetched is
   set to true so the SecurityProfileWatcher self-heals when the API
   recovers.

Signed-off-by: Ugo Giordano <ugiordan@redhat.com>
ugiordan force-pushed the feat/tls-intermediate-fallback branch from 1a7c340 to 4636f78 Compare July 24, 2026 12:01

Copy link
Copy Markdown
Member Author

Closing in favor of upstream feast-dev#6587 which contains all the same fixes. Will sync to midstream after upstream merges.

ugiordan closed this Jul 24, 2026

Copy link
Copy Markdown

@ugiordan: The following test has Failed:

OCI Artifact Browser URL

View in Artifact Browser

Inspecting Test Artifacts Manually

To inspect your test artifacts manually, follow these steps:

  1. Install ORAS (see the ORAS installation guide).
  2. Download artifacts with the following commands:
mkdir -p oras-artifacts
cd oras-artifacts
oras pull quay.io/opendatahub/odh-ci-artifacts:feast-group-test-gz6kt

openshift-ci Bot commented Jul 24, 2026

Copy link
Copy Markdown

@ugiordan: 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-in-cluster-presubmit 4636f78 link true /test e2e-in-cluster-presubmit

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL