[BMC] Wait for Redfish readiness after BMC firmware update#707
Conversation
…pdate After a BMC firmware update the BMC restarts; ping/L3 recovers before the Redfish management plane, so a firmware status read during that window logs errors. Gate completion on Redfish readiness instead of ping: - redfish_client: add wait_until_redfish_ready() that polls a quiet login() until the service accepts it or a timeout elapses; add a keyword-only log_errors flag on login() so the poll's expected failures log at notice. The poll drops any cached session first (invalidate_session, a local-only call) so a cached token cannot falsely report ready, sleeps min(interval, remaining) so it never overshoots the deadline, and fails fast only on a local permanent error (AUTH_FAILURE is treated as transient during boot). - bmc_base: add a thin wait_until_redfish_ready() delegator (not session managed, so it does not try to log in while the BMC is still rebooting). - bmc_fw_update: drop the ping wait loop; settle briefly, then wait for Redfish readiness. Signed-off-by: William Tsai <willtsai@nvidia.com>
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Reviewed via interactive multi-model review — the design is sound and I'd be comfortable with this going in; leaving a couple of non-blocking nits rather than a formal state. Nice change: replacing the fixed Non-blocking nits:
Neither is required for merge. AI-assisted review, reviewed by Ying Xie (@yxieca). |
judyjoseph
left a comment
There was a problem hiding this comment.
LGTM @william8545 can you confirm that these changes are applicable if we use the redfish from switch-host --> BMC
|
Cherry-pick PR to msft-202608: Azure/sonic-platform-common.msft#118 |
Description
After a BMC firmware update the BMC is restarted to activate the new image. Ping/L3 connectivity returns noticeably earlier than the BMC's Redfish/HTTPS management plane, so the post-reset wait now gates completion on Redfish being usable rather than on ping.
The readiness logic is encapsulated so callers don't reach into
RedfishClientdirectly:RedfishClient.wait_until_redfish_ready(timeout, interval)— polls a quietlogin()until the Redfish service accepts it or the timeout elapses, returning aRedfishClientreturn code (ERR_CODE_OKwhen ready). It drops any cached session first viainvalidate_session()(a local-only call that cannot emit an error log), so a cached token can't report a false "ready"; it sleepsmin(interval, remaining)so it never overshoots the deadline; and it fails fast only on a local, clearly permanent error.BMCBase.wait_until_redfish_ready(...)— a thin delegator toself.rf_client, deliberately not decorated with@with_session_management(that decorator would try to log in while the BMC is still rebooting and defeat the wait).bmc_fw_update.py— after the reset, waits a short settle interval (so a not-yet-rebooted BMC isn't mistaken for ready) and then callsbmc.wait_until_redfish_ready(). The previous ping-based wait loop is removed: a successful Redfish login implies L3 is back, so ping is redundant.RedfishClient.login()gains a keyword-onlylog_errorsflag (defaultTrue). WhenFalse, login failures are logged at notice instead of error, so the readiness poll's expected failures during the reboot window don't add error-level entries to the log. The default keeps behaviour unchanged for all existing callers.Motivation and Context
When a BMC firmware update triggers a BMC restart, L3/ping recovers before the BMC's Redfish management plane. The previous post-reset wait only checked ping, so the update could report completion while the Redfish version-read API was still unavailable. Follow-on tooling that reads the BMC firmware version (for example
fwutil show status) would then race the restart and log transient Redfish login errors during that window. Gating completion on a successful quiet Redfish login closes that window for callers serialized after the update, and the quiet-login flag keeps the readiness probe itself from adding error-level entries.AUTH_FAILURE(HTTP 401 on the login POST) is treated as transient, since during BMC boot the web server can come up before the auth backend; the poll only fails fast on a local, unrecoverable error. The readiness wait is bounded by a timeout; if Redfish does not become ready within the bound, the update path logs an error and exits non-zero instead of hanging.How Has This Been Tested?
Unit tests in
tests/redfish_client_test.py,tests/bmc_base_test.py, andtests/bmc_fw_update_test.pycoverwait_until_redfish_ready(first-try ready; ready after N retries; timeout returns the last non-OK code; fail-fast on a local permanent error; a transient auth failure keeps polling; sleep capped to the remaining budget; and a cached session not short-circuiting the probe), theBMCBasedelegation, the quiet-vs-errorlogin()logging, and thebmc_fw_updateflow (settle + readiness call, success, and failure exit).Additional Information (Optional)
log_errors=Truepreserves existing logging behaviour, so currentRedfishClient.login()callers are unaffected.