-
Notifications
You must be signed in to change notification settings - Fork 215
OCPEDGE-2934: feat: add macAddress as alternative identifier for fencing credentials #1916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -412,6 +412,14 @@ if [[ -z ${AGENT_E2E_TEST_SCENARIO:-} ]] && [[ ${NUM_ARBITERS} -eq 0 ]] && [[ ${ | |
| export ENABLE_TWO_NODE_FENCING="true" | ||
| fi | ||
|
|
||
| # Controls whether fencing credentials use "hostname" or "macAddress" to identify nodes | ||
| export FENCING_CREDENTIAL_IDENTIFIER=${FENCING_CREDENTIAL_IDENTIFIER:-hostname} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Any value other than the exact string The |
||
|
|
||
| if [[ "${FENCING_CREDENTIAL_IDENTIFIER}" != "hostname" ]] && [[ "${FENCING_CREDENTIAL_IDENTIFIER}" != "macAddress" ]]; then | ||
| printf "FENCING_CREDENTIAL_IDENTIFIER must be 'hostname' or 'macAddress', got '%s'\n" "${FENCING_CREDENTIAL_IDENTIFIER}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Only redfish BMC driver is supported for two node fencing | ||
| if [[ "${BMC_DRIVER}" != "redfish" ]] && [[ "${ENABLE_TWO_NODE_FENCING:-}" == "true" ]]; then | ||
| printf "Only redfish BMC driver is supported for Two Node Fencing deployments: BMC_DRIVER=%s, ENABLE_TWO_NODE_FENCING=%s" "${BMC_DRIVER}" "${ENABLE_TWO_NODE_FENCING}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -468,19 +468,29 @@ function node_map_to_install_config_fencing_credentials() { | |
| credentials: | ||
| EOF | ||
| for ((idx=0; idx < NUM_MASTERS ; idx++)); do | ||
| # shellcheck disable=SC2059 | ||
| hostname="$(printf "$MASTER_HOSTNAME_FORMAT" ${idx})" | ||
| # IP V6 and DualStack will force FQDN hostname for the VMs, we need to update | ||
| # this here to correctly set the hostname for the fencing credentials. | ||
| if [[ $IP_STACK != 'v4' ]]; then | ||
| hostname="${hostname}.${CLUSTER_DOMAIN}" | ||
| fi | ||
| username=$(node_val ${idx} "driver_info.username") | ||
| password=$(node_val ${idx} "driver_info.password") | ||
| address=$(node_val ${idx} "driver_info.address") | ||
|
|
||
| if [[ "${FENCING_CREDENTIAL_IDENTIFIER}" == "macAddress" ]]; then | ||
| identifier_key="macAddress" | ||
| identifier_value=$(node_val ${idx} "ports[0].address") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Consider adding a guard: Also — the original code had a helpful comment explaining why the FQDN append is needed for IPv6/DualStack. That "why" was lost in the refactor. Worth restoring above the |
||
| if [[ "${identifier_value}" == "null" || -z "${identifier_value}" ]]; then | ||
| printf "ports[0].address not found for node %d in %s\n" "${idx}" "${NODES_FILE}" >&2 | ||
| exit 1 | ||
| fi | ||
| else | ||
| # shellcheck disable=SC2059 | ||
| identifier_value="$(printf "$MASTER_HOSTNAME_FORMAT" ${idx})" | ||
| # IPv6 and DualStack force FQDN hostnames for VMs | ||
| if [[ $IP_STACK != 'v4' ]]; then | ||
| identifier_value="${identifier_value}.${CLUSTER_DOMAIN}" | ||
| fi | ||
| identifier_key="hostname" | ||
| fi | ||
|
|
||
| cat <<EOF | ||
| - hostname: ${hostname} | ||
| - ${identifier_key}: ${identifier_value} | ||
| address: ${address} | ||
| username: ${username} | ||
| password: ${password} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
AGENT_MASTER_MACSis populated here inconfigure_node()(called byget_static_ips_and_macs()), but the alternative code path —get_baremetal_ips_and_macs()— never declares or populates this array.Since
generate_cluster_manifests()unconditionally serializes it ("${AGENT_MASTER_MACS[@]}"), and the script runs withset -euxo pipefail, this will crash withunbound variableon everyNODES_PLATFORM=baremetaldeployment — even with the defaulthostnamemode.Suggested fix — mirror the
AGENT_MASTER_HOSTNAMESpattern inget_baremetal_ips_and_macs():AGENT_MASTER_MACS=()to the initialization blockAGENT_MASTER_MACS+=("$mac")inside theif (( i < NUM_MASTERS ))blockAlso worth adding
AGENT_MASTER_MACS=()to the init block inget_static_ips_and_macs()to match the established pattern.