fix: handle null lzBmcHostname in ironic HTTPS certificate validation#544
Conversation
When .lzBmcHostname is not set in the YAML configuration, getValue
returns the literal string "null" (jq's output for missing keys), not
an empty string. This caused the bash ${var:-fallback} substitution
to never trigger, resulting in ironic_cert_name being set to "null"
instead of falling back to lz_bmc_ip.
The fix adds an explicit null check after calling getValue, matching
the pattern already used for ironic_https_cert on line 318. This
ensures the hostname variable is properly empty when unset, allowing
the fallback to lz_bmc_ip to work correctly for self-signed
certificates that only have an IP SAN.
Fixes: gori-project/GoRI#934
Assisted-by: Claude Code <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughIn ChangesBMC Hostname Null Handling Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Summary
Fixes a bug in
validations.shwhere the ironic HTTPS certificate validation fails with "Certificate is not valid for name null" whenlzBmcHostnameis not provided in the configuration (only IP is provided, as with self-signed certificates).Root Cause
When
.lzBmcHostnameis not set in the YAML,getValuereturns the literal string"null"(jq's output for missing keys), not an empty string. The bash${lz_bmc_hostname:-$lz_bmc_ip}fallback only triggers for empty/unset variables, soironic_cert_namewas being set to the literal string"null".Changes
2>/dev/null || echo ""workaround from thegetValuecall[[ "$lz_bmc_hostname" == "null" ]] && lz_bmc_hostname=""to ensure the bash fallback works correctlyThis matches the existing pattern used for
ironic_https_certon line 318.Testing
With this fix,
validations.shshould pass whenironicHTTPSCertificateandironicHTTPSKeyare provided but no hostname is provided (only IP), as in the case of self-signed certificates.Fixes https://github.com/gori-project/GoRI/issues/934
Summary by CodeRabbit