Conversation
Wait for a lightweight Ansible command to succeed after SSH startup before reading DUT uptime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0d08e59d-63c7-4189-9be9-29045dd91d20 Signed-off-by: Lin Jin <linjin@microsoft.com>
|
/azp run |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Improves the robustness of the test_link_status_on_host_reboot workflow by adding a bounded post-reboot readiness check to ensure the DUT can successfully execute an Ansible command (including privilege escalation) before reading uptime, reducing flakiness where SSH is up but Ansible/become isn’t fully ready yet.
Changes:
- Import
wait_untiland introduce await_for_dut_ready()helper that polls a lightweight Ansiblecommand(true) until it succeeds. - Add bounded timeout/interval constants for the new post-reboot readiness polling.
- Invoke the readiness check immediately after
wait_for_startup()and beforedut.get_up_time().
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
This PR has backport request label(s) for branch(es): 202605, but is missing required test information. Please make sure you tick the tested branch(es) in the Tested branch section and provide test evidence (e.g., 202605: <test result>) in the Test result section as well in your PR description. ---Powered by SONiC BuildBot
|
| return duts_and_ports | ||
|
|
||
|
|
||
| def wait_for_dut_ready(dut): |
There was a problem hiding this comment.
should we use an existing library function for this? eg. "wait_critical_process" ?
the reboot tests (eg. test_reboot.py / reboot_utils/py / process_utils.py) should already have infrastructure for this. We shouldnt reinvent the wheel in this test
There was a problem hiding this comment.
wait_critical_processes() waits for full SONiC process readiness, which is more than needed here. This check only verifies that the Ansible/become command path is ready before calling get_up_time() . I could not find an existing lightweight helper for this purpose.
There was a problem hiding this comment.
wait for startup should do this - is it not sufficient? That function is used for many tests for ssh readyness - it should be robust
There was a problem hiding this comment.
I would opt to fix that function instead if its not doing what it should be.
There was a problem hiding this comment.
Thanks for the suggestion. I'll update the code accordingly.
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
The Tested branch section has been ticked and Test result is provided for branch(es): 202605. Added label(s): Tested for 202605 Branch. ---Powered by SONiC BuildBot
|
Signed-off-by: Lin Jin <linjin@microsoft.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
tests/common/reboot.py:251
- The Ansible-readiness wait currently uses a fixed
ANSIBLE_READY_TIMEOUTregardless of how much oftimeoutwas already spent waiting for SSH. Iftimeoutis meant as the overall startup budget, compute anansible_timeoutfrom the remaining time to avoid waiting longer than intended.
logger.info('waiting for Ansible commands to become ready on {}'.format(hostname))
def is_ansible_ready():
result = duthost.command("true", module_ignore_errors=True)
return result.is_successful
pytest_assert(
wait_until(ANSIBLE_READY_TIMEOUT, ANSIBLE_READY_INTERVAL, 0, is_ansible_ready),
"DUT {} did not become ready for Ansible commands after SSH startup".format(hostname),
)
tests/common/reboot.py:212
- To keep
timeoutacting as an end-to-end bound forwait_for_startup(), it helps to record a function-level start timestamp before the SSH polling begins so the subsequent Ansible-readiness wait can consume only the remaining budget.
This issue also appears on line 242 of the same file.
def wait_for_startup(duthost, localhost, delay, timeout, port=SONIC_SSH_PORT,
wait_for_ansible=True):
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
|
@StormLiangMS could you please help review/merge |
|
@LinJin23 — ❌ I found one blocking cleanup issue in the current head ( In Please either raise a normal The shared-helper placement and |
Signed-off-by: Lin Jin <linjin@microsoft.com>
4591ce8
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
| duthost.meta("clear_facts") | ||
|
|
||
| if not wait_for_ansible: | ||
| return |
| if not wait_for_ansible: | ||
| return | ||
|
|
||
| logger.info('waiting for Ansible commands to become ready on {}'.format(hostname)) |
| return | ||
|
|
||
| logger.info('waiting for Ansible commands to become ready on {}'.format(hostname)) | ||
|
|
| logger.info('waiting for Ansible commands to become ready on {}'.format(hostname)) | ||
|
|
||
| def is_ansible_ready(): | ||
| result = duthost.command("true", module_ignore_errors=True) |
Signed-off-by: Lin Jin <linjin@microsoft.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Signed-off-by: Lin Jin <linjin@microsoft.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Description of PR
Summary:
Wait for the DUT to successfully execute an Ansible command after post-reboot SSH startup before reading its uptime.
Fixes #
Type of change
Back port request
Tracking issue/work item for backport/cherry-pick request (GitHub issue or Microsoft ADO): N/A
Failure type: Flaky post-reboot readiness issue
Tested branch
Test result
test_link_downpassed 10 out of 10 runs across three physical Arista T0 testbeds: https://elastictest.org/scheduler/testplan/6a718773eb2c1b23503d3013Approach
What is the motivation for this PR?
SSH can become available before the DUT is ready to execute Ansible commands through privilege escalation, causing a flaky
uptime -sfailure after reboot.How did you do it?
Added a bounded readiness check that waits for a lightweight Ansible command to succeed before reading the DUT uptime.
How did you verify/test it?
Ran the targeted pre-commit checks for
tests/platform_tests/test_link_down.py. The test also passed 10 out of 10 runs across three physical Arista T0 testbeds using SONiC.20260510.08.Any platform specific information?
No.
Supported testbed topology if it's a new test case?
Not applicable.
Documentation
Not applicable.