Skip to content

Backport: Add optional Redfish session token caching to reduce BMC audit log spam - #1151

Open
stefanhipfel wants to merge 6 commits into
release-v0.7from
backport-session-v07
Open

Backport: Add optional Redfish session token caching to reduce BMC audit log spam#1151
stefanhipfel wants to merge 6 commits into
release-v0.7from
backport-session-v07

Conversation

@stefanhipfel

Copy link
Copy Markdown
Contributor

Summary

Backport notes

Cherry-picked commits from main:

  • cf50d99b — Add optional Redfish session token caching
  • e5dcf216 — Fix gofmt formatting
  • 74b63b92 — Fix session cache: reject non-positive TTL, shutdown DELETE timeout/TLS
  • 0078ff67 — Address review feedback: error return, 403 retry, options asymmetry, orphan note

Conflict resolution in cmd/main.go: removed migration-related code (not present in v0.7). Also adapted bmcuser_controller.go and suite_test.go for v0.7-specific controllers that used BasicAuth: true in bmc.Options (replaced with SessionCache == nil check / removed the field).

Test plan

  • go build ./... passes
  • make test passes (all 193 specs, one known-flaky BMCVersionSet timeout)
  • Default behavior unchanged: basic auth without --bmc-auth-mode=session-cache
  • Session cache enabled with --bmc-auth-mode=session-cache --bmc-session-cache-ttl=25m

Introduce a process-level SessionCache that reuses Redfish X-Auth-Token
across reconcile loops, capping the effective TTL against the BMC-advertised
SessionTimeout, with automatic invalidation and retry on 401. Enable via
--bmc-auth-mode=session-cache and tune with --bmc-session-cache-ttl.

Signed-off-by: Stefan Hipfel <stefan.hipfel@sap.com>
Signed-off-by: Stefan Hipfel <stefan.hipfel@sap.com>
…meout and TLS config

- NewSessionCache panics on non-positive TTL; cmd/main.go validates with <= 0
- sessionCacheEntry stores insecureTLS so Close() can build a matching TLS config
- Close() uses a 10s per-request timeout to avoid blocking manager shutdown

Signed-off-by: Stefan Hipfel <stefan.hipfel@sap.com>
…orphan note

- NewSessionCache returns (cache, error) instead of panicking
- IsSessionExpiredError now also matches HTTP 403 (Forbidden)
- bmcBaseOptions includes polling fields so all three reconcilers share one source
- --bmc-session-cache-ttl help text notes orphaned sessions on unclean exit

Signed-off-by: Stefan Hipfel <stefan.hipfel@sap.com>
The suite_test.go on release-v0.7 had additional BMCOptions with
BasicAuth: true for controllers added in v0.7 that were not present
on main when the session cache feature was developed.

Signed-off-by: Stefan Hipfel <stefan.hipfel@sap.com>
@stefanhipfel
stefanhipfel requested a review from a team as a code owner September 3, 2026 08:20
The helper always received the same 10-minute value, triggering the
unparam linter. Inline the constant and drop the parameter.

Signed-off-by: Stefan Hipfel <stefan.hipfel@sap.com>
@afritzler afritzler changed the title Backport: Add optional Redfish session token caching to reduce BMC audit log spam (v0.7) Backport: Add optional Redfish session token caching to reduce BMC audit log spam Sep 3, 2026
@afritzler

Copy link
Copy Markdown
Member

We should probably wait with the backport until we merge this feature into main.

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.

3 participants