Skip to content

[ptf] Support alt_password for PTF to DUT SSH connection#2662

Merged
vaibhavhd merged 2 commits intosonic-net:masterfrom
vaibhavhd:ptf-retry-alt-password
Dec 21, 2020
Merged

[ptf] Support alt_password for PTF to DUT SSH connection#2662
vaibhavhd merged 2 commits intosonic-net:masterfrom
vaibhavhd:ptf-retry-alt-password

Conversation

@vaibhavhd
Copy link
Contributor

Description of PR

Summary: In reboot/upgrades, the PTF's SSH key stored inside DUT gets deleted. Use a retry mechanism (alt_password) when default admin password does not work.
Fixes # (issue)

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Approach

What is the motivation for this PR?

For tests running on PTF container, alt password is not supported.
Use case - To enable alt_password for the tests running in PTF where there is a reboot/upgrade leading to deletion of SSH key and known hosts file inside DUT.
Note that the tests running on sonic-mgmt container have SSH retry support for device password and alt_password.

The error seen when key is deleted and default password does not work:

2020-12-15 00:47:24 : --------------------------------------------------
2020-12-15 00:47:24 : --------------------------------------------------
2020-12-15 00:47:24 : Fails:
2020-12-15 00:47:24 : --------------------------------------------------
2020-12-15 00:47:24 : FAILED:dut:Sonic upgrade failed. Target=SONiC-OS-master.586-e010d83f Current=
2020-12-15 00:47:24 : FAILED:dut:Longest downtime period must be less then 30 seconds. It was 0:02:48.229600
2020-12-15 00:47:24 : ==================================================
2020-12-15 00:47:24 : Disabling arp_responder

00:47:20.692  paramiko.transport: INFO    : Connected (version 2.0, client OpenSSH_7.9p1)
00:47:20.775  paramiko.transport: INFO    : Authentication (publickey) failed.
00:47:24.268  paramiko.transport: INFO    : Authentication (password) failed.
00:47:24.293  device_connection: ERROR   : SSH Command failed with message: Authentication failed.
00:47:25.917  root      : INFO    : *** TEST RUN END  : Tue Dec 15 00:47:25 2020
00:47:25.917  dataplane : INFO    : Thread exit

How did you do it?

Added retry mechanism when AuthenticationException is hit when trying the default password.
Fixed the exception catch sequence leading to auth errors being caught by SSHException.

Fixed an import error and typo.

How did you verify/test it?

Tested with the fix:

-------------------------------------------------------------------------------- live log call ---------------------------------------------------------------------------------
03:03:39 INFO test_upgrade_path.py:test_upgrade_path:156: Test upgrade path from https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-vs-image/580/artifact/target/sonic-vs.bin to https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-vs-image/lastSuccessfulBuild/artifact/target/sonic-vs.bin
03:03:39 INFO test_upgrade_path.py:test_upgrade_path:158: Installing https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-vs-image/580/artifact/target/sonic-vs.bin
03:04:53 INFO reboot.py:reboot:121: waiting for ssh to drop
03:04:53 INFO reboot.py:execute_reboot_command:105: rebooting with command "reboot"
03:05:03 INFO reboot.py:reboot:139: waiting for ssh to startup
03:06:09 INFO reboot.py:reboot:150: ssh has started up
03:06:09 INFO reboot.py:reboot:152: waiting for switch to initialize
03:08:09 INFO reboot.py:reboot:180: cold reboot finished
03:08:13 INFO reboot.py:reboot:183: DUT up since 2020-12-15 03:05:38
03:08:14 INFO test_upgrade_path.py:test_upgrade_path:165: Upgrading to https://sonic-jenkins.westus2.cloudapp.azure.com/job/vs/job/buildimage-vs-image/lastSuccessfulBuild/artifact/target/sonic-vs.bin
03:09:29 INFO ssh_utils.py:prepare_testbed_ssh_keys:17: Remove old keys from ptfhost
03:09:33 INFO ssh_utils.py:prepare_testbed_ssh_keys:26: Generate public key for ptf host
PASSED                                                                                                                                                                   [100%]
------------------------------------------------------------------------------ live log teardown ------------------------------------------------------------------------------

From paramiko log, the 2nd attempt at login with alt_password is successful

03:14:28.850  paramiko.transport: INFO    : Connected (version 2.0, client OpenSSH_7.9p1)
03:14:28.927  paramiko.transport: INFO    : Authentication (publickey) failed.
03:14:32.421  paramiko.transport: INFO    : Authentication (password) failed.
03:14:32.447  device_connection: ERROR   : SSH Authentication failure with message: Authentication failed.
03:14:32.576  paramiko.transport: INFO    : Connected (version 2.0, client OpenSSH_7.9p1)
03:14:32.648  paramiko.transport: INFO    : Authentication (publickey) failed.
03:14:32.682  paramiko.transport: INFO    : Authentication (password) successful!

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@vaibhavhd vaibhavhd requested a review from a team December 15, 2020 04:13
@neethajohn neethajohn requested a review from lolyu December 15, 2020 18:36
@vaibhavhd vaibhavhd merged commit 77f6832 into sonic-net:master Dec 21, 2020
@vaibhavhd vaibhavhd deleted the ptf-retry-alt-password branch December 21, 2020 16:19
kazinator-arista pushed a commit to kazinator-arista/sonic-mgmt that referenced this pull request Mar 4, 2026
…onic-net#14169)

swss:
* 2447754 2023-02-23 | Do not allow to add port to .1Q bridge while router port deletion is not completed  (sonic-net#2669) (HEAD -> 202205) [Lior Avramov]
* 641c65c 2023-03-07 | [bfdorch] add default TOS value for BFD session (sonic-net#2689) (HEAD -> 202205) [Baorong Liu]
* 95d3f6d 2023-03-08 | [ACL] Write ACL table/rule creation status into STATE_DB (sonic-net#2662) [bingwang-ms]

swss-common:
* 1fdeb9e 2023-03-03 | Define ACL_TABLE and ACL_RULE table in STATE_DB (sonic-net#748) (HEAD -> 202205, github/202205) [bingwang-ms]

platform-common:
* c441bd7 2023-03-07 | [sonic_ssd] Nokia-7215: Fix "show platform ssdhealth" (sonic-net#337) (HEAD -> 202205) [Pavan-Nokia]

Signed-off-by: Ying Xie <ying.xie@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants