Skip to content

Improve BMC connection reliability and error logging#758

Draft
xkonni wants to merge 1 commit intomainfrom
bug/bmc_http_connection
Draft

Improve BMC connection reliability and error logging#758
xkonni wants to merge 1 commit intomainfrom
bug/bmc_http_connection

Conversation

@xkonni
Copy link
Copy Markdown
Contributor

@xkonni xkonni commented Mar 27, 2026

Proposed Changes

  • Use explicit HTTP/2 transport for Redfish connections instead of relying on gofish defaults
  • Add structured logging on connection failures with error type and URL error op fields to aid debugging

Fixes #759

EDIT: opened an upstream PR instead: stmcginnis/gofish#518

Use explicit HTTP/2 transport for Redfish connections instead of relying
on gofish defaults, and add structured logging on connection failures with
error type and URL error op fields to aid debugging.

fixes issues with one bmc

```
ERROR   Reconciler error        {"controller": "bmc", "controllerGroup": "metal.ironcore.dev", "controllerKind": "BMC", "BMC": {"name":"nodexx"}, "namespace": "", "name": "nodexx", "reconcileID": "", "error": "Get \"https://1.2.3.4:443/redfish/v1/\": net/http: HTTP/1.x transport connection broken: malformed HTTP status code \"bad\""}
```
@xkonni xkonni requested a review from a team as a code owner March 27, 2026 14:56
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

Walkthrough

Modified Redfish BMC client initialization to use explicit HTTP transport configuration with TLS insecure skip verification and HTTP/2 support. Updated ClientConfig to include explicit HTTPClient and NoModifyTransport flag. Added low-verbosity error logging for connection failures.

Changes

Cohort / File(s) Summary
Redfish BMC Client Transport Configuration
bmc/redfish.go
Updated newRedfishBaseBMCClient to construct custom http.Transport with InsecureSkipVerify: true and HTTP/2 enabled via http2.ConfigureTransport. Changed gofish.ClientConfig to use explicit HTTPClient with NoModifyTransport: true instead of Insecure: true. Added low-verbosity logging for connection errors with special handling for *url.Error types.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

bug, area/metal-automation

Suggested reviewers

  • asergeant01
  • afritzler
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main changes: improving BMC connection reliability and adding error logging for debugging.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The PR description includes all required sections: proposed changes (with 2 bullet points), a fix reference (#759), and an additional note about an upstream PR.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bug/bmc_http_connection

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.

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (1)
bmc/redfish.go (1)

89-94: Consider setting MinVersion in TLS configuration.

The static analysis flagged that MinVersion is not set. While InsecureSkipVerify is intentionally used for BMC connections with self-signed certificates, setting a minimum TLS version improves security posture. TLS 1.2 is a reasonable minimum for BMC compatibility.

🔒 Proposed fix
 transport := &http.Transport{
-	TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec
+	TLSClientConfig: &tls.Config{
+		InsecureSkipVerify: true,  //nolint:gosec
+		MinVersion:         tls.VersionTLS12,
+	},
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bmc/redfish.go` around lines 89 - 94, The TLS config for the HTTP transport
lacks a minimum protocol version; update the TLSClientConfig used when creating
transport in bmc (the transport variable/TLSClientConfig) to set MinVersion to
tls.VersionTLS12 while keeping InsecureSkipVerify for self-signed BMC certs, so
replace the current &tls.Config{InsecureSkipVerify: true} with
&tls.Config{InsecureSkipVerify: true, MinVersion: tls.VersionTLS12}; leave the
http2.ConfigureTransport(transport) call unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@bmc/redfish.go`:
- Around line 89-94: The TLS config for the HTTP transport lacks a minimum
protocol version; update the TLSClientConfig used when creating transport in bmc
(the transport variable/TLSClientConfig) to set MinVersion to tls.VersionTLS12
while keeping InsecureSkipVerify for self-signed BMC certs, so replace the
current &tls.Config{InsecureSkipVerify: true} with
&tls.Config{InsecureSkipVerify: true, MinVersion: tls.VersionTLS12}; leave the
http2.ConfigureTransport(transport) call unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed2ea9f3-a6b5-4277-bb8a-cb80c0608c9a

📥 Commits

Reviewing files that changed from the base of the PR and between 52d7860 and 2e8c950.

📒 Files selected for processing (1)
  • bmc/redfish.go

// newRedfishBaseBMCClient creates a new RedfishBaseBMC with the given connection details (internal use only).
func newRedfishBaseBMCClient(ctx context.Context, options Options) (*RedfishBaseBMC, error) {
transport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we should make this configurable.

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.

@xkonni xkonni marked this pull request as draft March 30, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

BMC connection fails with HTTP/2 protocol error on some hardware

4 participants