Skip to content

OCPBUGS-97919: fix: use typed credentials key to support MAC-based fencing in ABI flow - #10477

Merged
openshift-merge-bot[bot] merged 4 commits into
openshift:masterfrom
fracappa:fca/mac-based-fencing-credentials-key-type
Jul 30, 2026
Merged

OCPBUGS-97919: fix: use typed credentials key to support MAC-based fencing in ABI flow#10477
openshift-merge-bot[bot] merged 4 commits into
openshift:masterfrom
fracappa:fca/mac-based-fencing-credentials-key-type

Conversation

@fracappa

@fracappa fracappa commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

MAC-only fencing credentials were broken in the ABI path because loadFencingCredentials keyed all entries as plain strings, causing LoadHostConfigs to create hostname-based configs with MAC addresses as hostnames. Introduce credentialKey struct to distinguish hostname from MAC keys, skip hostname-config creation for MAC entries, and
add fencingConfigDir so MAC-matched configs find the credentials file in the parent directory.

This is a follow-up for PR #10385

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Summary by CodeRabbit

  • New Features
    • Added support for an optional mac_address field in fencing credential parameters (including Swagger schema updates).
  • Bug Fixes
    • Tightened fencing credential parsing and matching to consistently select the correct identifier (preferring hostname, otherwise MAC), skip empty entries, and apply credentials from the correct source.
    • MAC-only fencing credentials are no longer converted into hostname-based host configurations.
    • Updated logging to clearly indicate whether credentials were applied via hostname or MAC match.
  • Tests
    • Expanded parsing and install-config coverage for MAC-based fencing credentials, including MAC-only scenarios and related assertions.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 18, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@fracappa: This pull request explicitly references no jira issue.

Details

In response to this:

MAC-only fencing credentials were broken in the ABI path because loadFencingCredentials keyed all entries as plain strings, causing LoadHostConfigs to create hostname-based configs with MAC addresses as hostnames. Introduce credentialKey struct to distinguish hostname from MAC keys, skip hostname-config creation for MAC entries, and
add fencingConfigDir so MAC-matched configs find the credentials file in the parent directory.

This is a follow-up for PR #10385

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Fencing credential parsing now prefers hostname keys and falls back to MAC keys, while skipping entries without either. Host configuration generation, credential lookup, model serialization, and install-config generation support MAC-based credentials.

Changes

Fencing credential keying and host matching

Layer / File(s) Summary
Credential parsing and host matching
cmd/agentbasedinstaller/host_config.go, cmd/agentbasedinstaller/host_config_test.go
Credentials use hostname or fallback macaddress keys; hostname configurations use direct lookup, while MAC configurations match inventory addresses. Tests cover MAC-only loading and application.
Credential model and install-config propagation
models/fencing_credentials_params.go, swagger.yaml, internal/installcfg/installcfg.go, internal/installcfg/builder/...
Fencing credential payloads accept optional MAC addresses, omit empty hostname or MAC fields from JSON, and builder output preserves MAC-based credentials and certificate verification.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant LoadHostConfigs
  participant loadFencingCredentials
  participant hostConfig
  participant InstallConfigBuilder
  participant InstallConfig
  LoadHostConfigs->>loadFencingCredentials: Load hostname or MAC keyed credentials
  loadFencingCredentials-->>LoadHostConfigs: Return credential map
  LoadHostConfigs->>hostConfig: Create hostname or MAC configuration
  hostConfig->>hostConfig: Select hostname key or matching inventory MAC
  hostConfig-->>InstallConfigBuilder: Return fencing credentials
  InstallConfigBuilder->>InstallConfig: Emit Hostname or MacAddress credential
Loading

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error New info/warn logs print hostnames and MAC addresses (loaded credentials, matching hostnames, missing-agent logs), exposing internal identifiers. Redact or remove hostname/MAC values from logs, or limit them to debug with hashing/partial masking; keep only generic status messages.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Test Structure And Quality ⚠️ Warning The new Ginkgo tests still use many bare Expect(...).NotTo(HaveOccurred())/ShouldNot(HaveOccurred()) checks, so failures won’t be diagnosed well. Add descriptive failure messages to the new file-ops/load/match/apply assertions, and keep each It centered on a single outcome.
✅ Passed checks (12 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the bug fix and the MAC-based fencing change in the ABI flow.
Description check ✅ Passed The description follows the template with summary, issue type, impact, testing, and checklist sections, and includes motivation/context.
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.
Stable And Deterministic Test Names ✅ Passed The added/changed Ginkgo titles are static and descriptive; none contain dynamic names, dates, UUIDs, IPs, or generated suffixes.
Microshift Test Compatibility ✅ Passed PASS: The new Ginkgo tests are unit tests and don’t reference MicroShift-unsupported OpenShift APIs/features or namespaces; no MicroShift guard is needed.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The added Ginkgo specs are unit tests, not e2e cluster tests, and they only use temp dirs and mocked models; no SNO-sensitive scheduling assumptions were added.
Topology-Aware Scheduling Compatibility ✅ Passed Only fencing-credential parsing/serialization and tests changed; no manifests/controllers, node selectors, affinities, PDBs, or topology-based replica logic were added.
Ote Binary Stdout Contract ✅ Passed No process-level stdout writes were introduced; touched code uses error/logrus paths only, and the sole RunSpecs entrypoint has no stdout printing.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PASS: The added Ginkgo tests are unit/local-file tests; they don't call network services or assume IPv4 connectivity. IPv4 literals are inert fixture data.
No-Weak-Crypto ✅ Passed Exact weak-crypto search in all changed files returned 0 hits; patch only adjusts fencing-credential handling, tags, and tests.
Container-Privileges ✅ Passed HEAD changes are Go/swagger/model files only; no changed file contains privileged, hostPID/network/IPC, SYS_ADMIN, or allowPrivilegeEscalation settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@openshift-ci openshift-ci Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 18, 2026
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.68421% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.52%. Comparing base (cf655c1) to head (d882c85).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
restapi/embedded_spec.go 0.00% 10 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10477      +/-   ##
==========================================
+ Coverage   44.47%   44.52%   +0.04%     
==========================================
  Files         423      423              
  Lines       73355    73437      +82     
==========================================
+ Hits        32628    32701      +73     
- Misses      37809    37819      +10     
+ Partials     2918     2917       -1     
Files with missing lines Coverage Δ
cmd/agentbasedinstaller/host_config.go 48.23% <100.00%> (+0.77%) ⬆️
internal/installcfg/builder/builder.go 79.82% <100.00%> (+0.35%) ⬆️
internal/installcfg/installcfg.go 0.00% <ø> (ø)
restapi/embedded_spec.go 0.00% <0.00%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@fonta-rh fonta-rh left a comment

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.

Review: PR #10477 — Typed credentials key for MAC-based fencing in ABI flow

Reviewed the bug report, the fix, cross-repo compatibility (installer contract, CEO impact), and test coverage. The PR is correct — all three bugs from PR #10385 are real and properly fixed:

  1. Untyped string keys → Fixed by credentialKey struct with explicit keyType discriminator. The old map[string] approach was the root cause — LoadHostConfigs couldn't distinguish hostname keys from MAC keys.
  2. Bogus hostname configs from MAC keys → Fixed by skipping MAC-keyed entries in the hostname-config creation loop (line 361). Old behavior created phantom hostConfig{hostname: "aa:bb:cc:dd:ee:01"} entries that triggered misleading warnings and missingHost failures.
  3. Wrong directory for fencing file → Fixed by fencingConfigDir field. MAC-based configs correctly resolve to the parent directory containing fencing-credentials.yaml instead of the per-host subdirectory.

The integration test (LoadHostConfigs with MAC-only fencing credentials) is the key addition — it covers the full pipeline that #10385 missed, and would have caught all three bugs.

Cross-repo compatibility verified: installer's yaml:"macaddress,omitempty" matches assisted-service's yaml:"macaddress". Both sides normalize MACs to lowercase. No CEO impact (ABI-only path).

One minor issue

host_config.go:284log.Infof("Adding fencing credentials for hostname %s", config.hostname) will log an empty hostname for MAC-based configs. Pre-fix, this line was unreachable for MAC configs (credentials returned nil). Post-fix, MAC configs correctly return credentials, making this line reachable with config.hostname == "".

Suggested fix:

if config.hostname != "" {
    log.Infof("Adding fencing credentials for hostname %s", config.hostname)
} else {
    log.Infof("Adding fencing credentials via MAC address match")
}

Not blocking — the fix is correct as-is. This is a log clarity improvement for operators debugging fencing credential application.

@fracappa
fracappa force-pushed the fca/mac-based-fencing-credentials-key-type branch from e072531 to ce5d969 Compare June 18, 2026 08:47
@fracappa

Copy link
Copy Markdown
Contributor Author

/retest

Comment thread cmd/agentbasedinstaller/host_config.go Outdated
if config.hostname != "" {
log.Infof("Adding fencing credentials for hostname %s", config.hostname)
} else {
log.Infof("Adding fencing credentials via MAC address match")

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.

nit

Suggested change
log.Infof("Adding fencing credentials via MAC address match")
log.Info("Adding fencing credentials via MAC address match")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pastequo thanks! Addressed

@fracappa
fracappa force-pushed the fca/mac-based-fencing-credentials-key-type branch from 91aec49 to ff9d121 Compare June 25, 2026 14:39
@fracappa

Copy link
Copy Markdown
Contributor Author

/retest-required

@andfasano andfasano left a comment

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.

Please create an OCPBUGS jira card to properly track this issue

Comment thread cmd/agentbasedinstaller/host_config.go Outdated
// fencingConfigDir is the parent directory containing fencing-credentials.yaml.
// Set on MAC-based configs so FencingCredentials() can find the file,
// since configDir points to the per-host subdirectory.
fencingConfigDir string

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.

Can you please elaborate better the requirements for this change? It's not clear its relationship with the main issue described (credentials key), and why it didn't work as per the previous implementation. The other changes look good, but this one looks a little bit strange, given that as per the above comments configDir contains the fencing-credentials.yaml

@fracappa fracappa Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@andfasano the requirements for this change come from introducing the possibility of keying the fencing-credentials by MAC address as a fallback when the user doesn't know any host-name at installation time yet.

Think of the directory layout, as something like this:

/etc/assisted/hostconfig/             
├── fencing-credentials.yaml           
├── host-0/                            
│   ├── mac_addresses
│   ├── role
│   └── root-device-hints.yaml
└── host-1/
    ├── mac_addresses
    ├── role
    └── root-device-hints.yaml

For hostname-based configs, configDir is set to the parent dir (/hostconfig/), so FencingCredentials() can directly do filepath.Join(configDir, "fencing-credentials.yaml") and find the file.

For MAC-based configs, configDir is set to the per-host subdirectory (/hostconfig/host-X/) because that's where role and root-device-hints.yaml live. But fencing-credentials.yaml doesn't live there, it's one level up in the parent dir.

Without fencingConfigDir, when a MAC-based config tried to load fencing credentials, it would look for /hostconfig/host-0/fencing-credentials.yaml, which doesn't exist. The file is at /hostconfig/fencing-credentials.yaml.

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.

(wrote a long reply but lost thanks to gh, rewriting it from scratch... :/)

Thanks @fracappa I wasn't aware that github.com/openshift/installer/pull/10513 was already landed.

Previously we agreed with @fonta-rh to extend the current logic to support a host-config by hostname (limited to FC case, but preparing the ground for future improvements).
The agent-installer-controller 2-steps pattern (load & apply) was extended in a way that:

  1. In the first step the file system is explored looking for any host config artefact (LoadHostConfigs). They per-host config is keyed by:
  • by mac - in this case it's assumed a specific folder containing a mac_addressess file is present, to match it.
  • by hostname - right now only the presence of the single fencing-credentials.yaml is considered. To properly handle the single file definition layout, the path stored here is the parent one.

In both the cases, a new hostConfig struct was added to the list, to be processed (and filtered) later in the second step, ApplyHostConfigs.

  1. In the second step the outer loop is given by the list of hosts currently registered in AS, and we're looking for those hostConfig in our local list matching the AS host (by mac or by hostname). So they are filtered in findHostConfigs.
    Then every applyXXX method has its own logic to load the host config bit and apply it.

The previous patch #10385 seems to have somehow broken the first step assumption, trying to force a per-mac loading in a portion of code dedicated to handle hostnames only. Here the hostname may contain now a mac-address, which is clearly not in sync with agreed logic (and also meaning of the field).

So rather than patching the original #10385, I think it could be worth reviewing the whole approach in a way that is more in line with the original logic. I'd be happy to setup an offline discussion to explore the details, but at first glance I think that for those cases where the fencing credentials are defined by mac then it would be a lot simpler to modify the installer code and generate a small hostXXX-fencing-credentials.yaml file per host stored in the host specific folder (as for role and rdh), leaving the generic (parent-level) fencing-credentials.yaml to store just those ones defined by hostname (and probably the FencingCredentials() apply should be adapted to consider both the cases).

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.

Hello @andfasano
This late confusion on me, although I didn't review assisted-service#10385 I should've flagged the deviation on openshift/installer#10513, which I did review. Sorry about that.

So now I'll work with @fracappa to create a pair of PRs that moves this to the originally intended shape: fencing creds created in the installer directly in the mac-based location (host config dir).

How does this look?

/etc/assisted/hostconfig/
├── fencing-credentials.yaml ← hostname-keyed credentials only
├── host-0/
│ ├── mac_addresses
│ ├── role
│ ├── root-device-hints.yaml
│ └── fencing-credentials.yaml ← this host's MAC-keyed credential
└── host-1/
├── mac_addresses
├── role
├── root-device-hints.yaml
└── fencing-credentials.yaml ← this host's MAC-keyed credential

Each per-host file uses the same credentials array format from PR #9946, with a single entry:

credentials:

MAC configs read from their configDir (host-N/). Hostname configs read from their configDir (parent). The configDir invariant from assisted-service#8457 holds for both.

We keep the precedence rule (from installer #10513): when a credential has both hostname and macaddress, hostname wins — it goes in the shared file only.


Now for this very PR on assisted-service, we can simplify the code to something like this:

loadFencingCredentials goes back to returning map[string]*models.FencingCredentialsParams (plain string keys). It still needs to parse the macaddress YAML field (new since #8457), but the key is just whichever identifier is present — hostname or MAC address — as a plain string. No typed key needed because hostname-keyed and MAC-keyed entries never coexist in the same file anymore. So like you said, we change FencingCredentials() to handle both cases:

func (hc hostConfig) FencingCredentials() (*models.FencingCredentialsParams, error) {
if hc.hostname == "" && len(hc.macAddresses) == 0 {
return nil, nil
}

  creds, err := loadFencingCredentials(filepath.Join(hc.configDir, "fencing-credentials.yaml"))
  if err != nil {
      return nil, err
  }
  if creds == nil {
      return nil, nil
  }

  if hc.hostname != "" {
  creds, err := loadFencingCredentials(filepath.Join(hc.configDir, "fencing-credentials.yaml"))
  if err != nil {
      return nil, err
  }
  if creds == nil {
      return nil, nil
  }

  if hc.hostname != "" {
      return creds[hc.hostname], nil
  }
  for _, mac := range hc.macAddresses {
      if c, ok := creds[mac]; ok {
          return c, nil
      }
  }
  return nil, nil

}

What do you think @fracappa @andfasano ?

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.

In line of principle the approach sounds fine, feel free to ping me when you'll need another round of review. Personally I'd consider a configuration bug when the FC are defined for the same host for both the hostname/mac - it seems something that could easily verified in the installer statically (remember that when you reach this point is pretty late in the chain, the user already created and distributed the ISO).

@fracappa fracappa changed the title NO-JIRA: fix: use typed credentials key to support MAC-based fencing in ABI flow OCPBUGS-97919: fix: use typed credentials key to support MAC-based fencing in ABI flow Jul 7, 2026
@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Jul 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@fracappa: This pull request references Jira Issue OCPBUGS-97919, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

MAC-only fencing credentials were broken in the ABI path because loadFencingCredentials keyed all entries as plain strings, causing LoadHostConfigs to create hostname-based configs with MAC addresses as hostnames. Introduce credentialKey struct to distinguish hostname from MAC keys, skip hostname-config creation for MAC entries, and
add fencingConfigDir so MAC-matched configs find the credentials file in the parent directory.

This is a follow-up for PR #10385

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Summary by CodeRabbit

  • Bug Fixes

  • Improved fencing credential handling to correctly distinguish hostname-based versus MAC-based credentials.

  • MAC-only credentials are no longer converted into hostname configurations, and the correct credential source is used for MAC matches.

  • Updated credential application behavior to respect the correct precedence when both hostname and MAC fields are present.

  • Enhanced log messages to clarify whether credentials were applied via hostname or MAC match.

  • Tests

  • Expanded coverage for parsing, skipping invalid entries, precedence rules, and MAC-only application scenarios.

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 openshift-eng/jira-lifecycle-plugin repository.

@fracappa

fracappa commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

/jira refresh

@openshift-ci-robot

Copy link
Copy Markdown

@fracappa: This pull request references Jira Issue OCPBUGS-97919, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

@fracappa

fracappa commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Jul 7, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@fracappa: This pull request references Jira Issue OCPBUGS-97919, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

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 openshift-eng/jira-lifecycle-plugin repository.

@fracappa
fracappa force-pushed the fca/mac-based-fencing-credentials-key-type branch 2 times, most recently from 003e490 to a38d871 Compare July 13, 2026 14:36
@openshift-ci-robot

Copy link
Copy Markdown

@fracappa: This pull request references Jira Issue OCPBUGS-97919, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

MAC-only fencing credentials were broken in the ABI path because loadFencingCredentials keyed all entries as plain strings, causing LoadHostConfigs to create hostname-based configs with MAC addresses as hostnames. Introduce credentialKey struct to distinguish hostname from MAC keys, skip hostname-config creation for MAC entries, and
add fencingConfigDir so MAC-matched configs find the credentials file in the parent directory.

This is a follow-up for PR #10385

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Summary by CodeRabbit

  • Bug Fixes

  • Improved fencing credential parsing to prefer hostname entries and fall back to MAC-address entries, while skipping invalid/empty records.

  • MAC-only fencing credentials are no longer converted into hostname configurations.

  • Credential application now uses the correct source when both hostname and MAC are present.

  • Updated logs to clearly indicate whether credentials were applied via hostname or MAC match.

  • Tests

  • Expanded coverage for parsing/ignoring invalid entries and for MAC-only fencing credential scenarios, including successful MAC-based application.

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 openshift-eng/jira-lifecycle-plugin repository.

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

🧹 Nitpick comments (1)
cmd/agentbasedinstaller/host_config.go (1)

346-351: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

MAC-keyed entries in parent-level fencing-credentials.yaml are not filtered or tested. The code and tests both rely on the convention that the parent file only contains hostname-keyed entries, without enforcing or testing this assumption.

  • cmd/agentbasedinstaller/host_config.go#L346-L351: The loop creates hostConfig entries with hostname set to every key in fencingCreds, including MAC address keys. If the parent file contains MAC-keyed entries, this produces semantically incorrect configs with hostname set to a MAC string. Filter MAC-keyed entries (e.g., by tracking key origin in loadFencingCredentials) or document the convention that the parent file must only contain hostname-keyed entries.
  • cmd/agentbasedinstaller/host_config_test.go#L781-L806: The test writes fencing-credentials.yaml to the per-host directory (hostDir), but LoadHostConfigs reads from the parent directory (tempDir). The test passes because the parent file is missing, not because MAC keys are filtered. Add a test that writes MAC-keyed entries to the parent directory and verifies no hostname-based configs are created.
🤖 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 `@cmd/agentbasedinstaller/host_config.go` around lines 346 - 351, Filter
MAC-keyed entries before the hostConfig creation loop in
loadFencingCredentials/LoadHostConfigs so only hostname-keyed parent credentials
produce hostname-based configs; update
cmd/agentbasedinstaller/host_config.go:346-351 accordingly. In
cmd/agentbasedinstaller/host_config_test.go:781-806, write MAC-keyed credentials
to the parent directory and assert that no hostname-based configs are created.
🤖 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.

Nitpick comments:
In `@cmd/agentbasedinstaller/host_config.go`:
- Around line 346-351: Filter MAC-keyed entries before the hostConfig creation
loop in loadFencingCredentials/LoadHostConfigs so only hostname-keyed parent
credentials produce hostname-based configs; update
cmd/agentbasedinstaller/host_config.go:346-351 accordingly. In
cmd/agentbasedinstaller/host_config_test.go:781-806, write MAC-keyed credentials
to the parent directory and assert that no hostname-based configs are created.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 3ed6c062-e8a1-4dc3-9d5b-49f7d43e1df7

📥 Commits

Reviewing files that changed from the base of the PR and between ce5d969 and a38d871.

📒 Files selected for processing (2)
  • cmd/agentbasedinstaller/host_config.go
  • cmd/agentbasedinstaller/host_config_test.go

@fracappa

Copy link
Copy Markdown
Contributor Author

/retest-required

@fracappa
fracappa force-pushed the fca/mac-based-fencing-credentials-key-type branch from a38d871 to 60438d1 Compare July 14, 2026 16:53
@openshift-ci openshift-ci Bot added the api-review Categorizes an issue or PR as actively needing an API review. label Jul 15, 2026
@fracappa
fracappa force-pushed the fca/mac-based-fencing-credentials-key-type branch from 8b9b8e2 to 5055be9 Compare July 16, 2026 11:07
@fracappa

Copy link
Copy Markdown
Contributor Author

/retest-required

1 similar comment
@fracappa

Copy link
Copy Markdown
Contributor Author

/retest-required

@andfasano

andfasano commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

At least for the part related to ABI, the changes look fine and in line also with the topic and changes discussed in openshift/installer#10684. Tip: not sure if you've already documented (internally) how the FC are currently managed (by hostname / by mac), in case it would be useful to have something for future troubleshooting.

(just noted you'll have to fix the verify-generated-code)

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2026
fracappa added 3 commits July 29, 2026 17:36
…pipeline

Add mac_address field to fencing-credentials-params so MAC-keyed
credentials survive the API→DB→install-config round-trip. When
handleFencing() builds the install-config, it emits macAddress
instead of hostname when the credential carries a MAC, letting the
installer's gatherFencingCredentials() create MAC-hashed secrets.

Simplify host_config.go: remove credentialKey struct and
fencingConfigDir field, since the installer now places MAC-keyed
credentials in per-host subdirectories where configDir already
points.
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2026
@fracappa
fracappa force-pushed the fca/mac-based-fencing-credentials-key-type branch from 26d79a1 to f0bb093 Compare July 29, 2026 15:36
@openshift-ci openshift-ci Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 29, 2026
@CrystalChun

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2026
@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CrystalChun, fracappa

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD cf655c1 and 2 for PR HEAD d882c85 in total

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD bcbbf49 and 1 for PR HEAD d882c85 in total

@gamli75

gamli75 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

/override ci/prow/edge-e2e-ai-operator-disconnected-capi

@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown

@gamli75: Overrode contexts on behalf of gamli75: ci/prow/edge-e2e-ai-operator-disconnected-capi

Details

In response to this:

/override ci/prow/edge-e2e-ai-operator-disconnected-capi

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.

@fracappa

Copy link
Copy Markdown
Contributor Author

/test e2e-agent-compact-ipv4 edge-e2e-metal-assisted-5-0 edge-e2e-ai-operator-ztp

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 317cef9 and 0 for PR HEAD d882c85 in total

@CrystalChun

Copy link
Copy Markdown
Contributor

/override ci/prow/edge-e2e-ai-operator-disconnected-capi

@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown

@CrystalChun: Overrode contexts on behalf of CrystalChun: ci/prow/edge-e2e-ai-operator-disconnected-capi

Details

In response to this:

/override ci/prow/edge-e2e-ai-operator-disconnected-capi

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.

@openshift-ci

openshift-ci Bot commented Jul 30, 2026

Copy link
Copy Markdown

@fracappa: all tests passed!

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.

@openshift-merge-bot
openshift-merge-bot Bot merged commit 9665339 into openshift:master Jul 30, 2026
24 checks passed
@openshift-ci-robot

Copy link
Copy Markdown

@fracappa: Jira Issue OCPBUGS-97919: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-97919 has been moved to the MODIFIED state.

Details

In response to this:

MAC-only fencing credentials were broken in the ABI path because loadFencingCredentials keyed all entries as plain strings, causing LoadHostConfigs to create hostname-based configs with MAC addresses as hostnames. Introduce credentialKey struct to distinguish hostname from MAC keys, skip hostname-config creation for MAC entries, and
add fencingConfigDir so MAC-matched configs find the credentials file in the parent directory.

This is a follow-up for PR #10385

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Summary by CodeRabbit

  • New Features
  • Added support for an optional mac_address field in fencing credential parameters (including Swagger schema updates).
  • Bug Fixes
  • Tightened fencing credential parsing and matching to consistently select the correct identifier (preferring hostname, otherwise MAC), skip empty entries, and apply credentials from the correct source.
  • MAC-only fencing credentials are no longer converted into hostname-based host configurations.
  • Updated logging to clearly indicate whether credentials were applied via hostname or MAC match.
  • Tests
  • Expanded parsing and install-config coverage for MAC-based fencing credentials, including MAC-only scenarios and related assertions.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-robot

Copy link
Copy Markdown

Fix included in release 5.0.0-0.nightly-2026-07-31-015042

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-review Categorizes an issue or PR as actively needing an API review. approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants