Skip to content
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

Implenemt playbook to recover vmhost server automatically #2800

Merged
merged 3 commits into from
Feb 25, 2021

Conversation

bingwang-ms
Copy link
Collaborator

@bingwang-ms bingwang-ms commented Jan 13, 2021

Signed-off-by: bingwang [email protected]

Description of PR

Summary:
Fixes # (issue)
This commit introduced several playbook to recover vmhost server automatically.
It's extremely time consuming to redeploy all testbeds on a host server if the server is down or rebooted. This PR adds a new option in testbed-cli.sh to do a cleanup of host server, and adds a respin of vm that failed to start.

Type of change

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

Approach

What is the motivation for this PR?

This PR is to add new playbooks to support auto testbed recovery.

How did you do it?

  1. Add a respin playbook to respin failed VMs
  2. Add a cleanup playbook to cleanup host servers.

How did you verify/test it?

Verified in starlab.

$ ./recover_server.py --testbed-servers server_16 --testbed testbed.csv --vm-file veos --inventory str2 --passfile password.txt
INFO - LOG PATH: /tmp/recover_server_2021-01-19_07-19-44
INFO - Start running task server_16_cleanup_vmhost
INFO - Finish running task server_16_cleanup_vmhost
INFO - Start running task vms16-dual-t0-7050-2_start_topo_vms
INFO - Finish running task vms16-dual-t0-7050-2_start_topo_vms
INFO - Start running task vms16-dual-t0-7050-2_add_topo
INFO - Finish running task vms16-dual-t0-7050-2_add_topo
INFO - Start running task vms16-dual-t0-7050-2_deloy_mg
INFO - Finish running task vms16-dual-t0-7050-2_deloy_mg

============= server_16 recovery summary =============

Server server_16 recovery result:
server_16             start-topo-vms    add-topo    deploy-mg
--------------------  ----------------  ----------  -----------
vms16-dual-t0-7050-2  passed            passed      passed

======================================================

Any platform specific information?

No.

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

No.

Documentation

This commit introduced several playbook to recover vmhost server
automatically.

Signed-off-by: bingwang <[email protected]>
Signed-off-by: bingwang <[email protected]>
@bingwang-ms bingwang-ms marked this pull request as ready for review January 19, 2021 03:48
@bingwang-ms bingwang-ms requested a review from a team January 19, 2021 03:48
@bingwang-ms bingwang-ms changed the title [draft]Implenemt playbook to recover vmhost server automatically Implenemt playbook to recover vmhost server automatically Jan 19, 2021
src_disk_image: "{{ home_path }}/{{ root_path }}/images/{{ hdd_image_filename }}"
disk_image: "{{ home_path }}/{{ root_path }}/disks/{{ vm_name }}_hdd.vmdk"
cdrom_image: "{{ home_path }}/{{ root_path }}/images/{{ cd_image_filename }}"
when: '"kickstart_code" in kickstart_output and kickstart_output.kickstart_code != 0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since almost all tasks in respin_vm.yml needs escalated privilege, it will be nicer to apply become like:

  - name: Respin failed vm
    include_tasks: respin_vm.yml
    vars:
      src_disk_image: "{{ home_path }}/{{ root_path }}/images/{{ hdd_image_filename }}"
      disk_image: "{{ home_path }}/{{ root_path }}/disks/{{ vm_name }}_hdd.vmdk"
      cdrom_image: "{{ home_path }}/{{ root_path }}/images/{{ cd_image_filename }}"
      apply:
         become: True
    when: '"kickstart_code" in kickstart_output and kickstart_output.kickstart_code != 0'

https://docs.ansible.com/ansible/latest/collections/ansible/builtin/include_tasks_module.html

# This playbook will cleanup a vm_host, including removing all veos, containers and net bridges.

- hosts: servers:&vm_host
gather_facts: no
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above to put become here.

set_fact:
kickstart_failed_vms: "{{ kickstart_failed_vms + [vm_name] }}"
when: '"kickstart_code" in kickstart_output_final and kickstart_output_final.kickstart_code != 0'
when: '"kickstart_code" in kickstart_output and kickstart_output.kickstart_code != 0'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to retry respine if one round of respine still failed? To avoid endless retry, we can add a max retry limitation, like 3 times?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. I'll make this change in next PR.

@bingwang-ms bingwang-ms merged commit 0756f4c into sonic-net:master Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants