Skip to content

Capture ETag from PATCH responses in httpBasedUpdateBMCAttributes #916

@atd9876

Description

@atd9876

Description

After issuing a PATCH to apply BMC attributes, capture the ETag from the response (or a follow-up GET) and return it as part of ApplyResult. This is the "write side" of ETag-based drift detection — we record what the BMC told us after a successful write so we can cheaply detect drift later.

Changes

  1. httpBasedUpdateBMCAttributes — after a successful PATCH, read the ETag response header. If absent, perform a follow-up GET to obtain the current ETag. Return map[string]ApplyResult keyed by attribute name.

  2. fetchAndCaptureETag(client, uri) — helper that GETs a resource and returns its URI + ETag. Used as fallback when the PATCH response doesn't include an ETag header.

  3. ComputeValueHash(value string) — SHA-256 hash of the effective value at apply time. Stored alongside the ETag so that desired-state changes (Secret/ConfigMap rotation) can be detected without relying on spec.generation.

  4. redfish_local.go — same ETag capture pattern for the local/mock BMC implementation (GET current ETag → PatchWithHeaders using If-Match → capture new ETag from response).

Tests

  • TestComputeValueHash — deterministic hash, empty input
  • TestFetchAndCaptureETag — mock HTTP server returning ETag header

Files

  • bmc/oem_helpers.go (PATCH return path + helpers)
  • bmc/redfish_local.go (ETag capture in local implementation)
  • bmc/oem_helpers_test.go (tests for this PR's scope)

Acceptance Criteria

  • httpBasedUpdateBMCAttributes returns (map[string]ApplyResult, error)
  • ETag is captured from PATCH response header or follow-up GET
  • ComputeValueHash is deterministic and tested
  • make test green

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Backlog
    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions