Project

Profile

Help

Task #7727

Robust machine cleaning

Added by Mark Zaslavskiy over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
High
Assignee:
Timofey Turenko
Category:
mdbci features
Sprint/Milestone:
Start date:
03.11.2016
Due date:
% Done:

100%

Estimated time:
3:00 h
Target branch:
Test scenario:

https://github.com/OSLL/mdbci/tree/7727_robust_machine_cleaning
https://github.com/OSLL/mdbci/pull/322

!! For remove only first match - use flag "-o" as second argument of script and specify provider, if need remove at one provider. Otherwise remove firsts at all providers.

Tests cases:
1) Libvirt snapshot's delete:
# Up config, create snapshots, run script.

./mdbci --template confs/libvirt_lite.json generate SOME_DIR

./mdbci up SOME_DIR/node0

./mdbci snapshot take --path-to-nodes SOME_DIR --node-name node0 --snapshot-name SNAP_NAME

# As result, script will delete all snapshots:
./scripts/clean_vms.sh SOME_DIR_node0

2) Destroy only first match config of ALL PROVIDERS:

# Up several configs,take snapshot, run script.
./mdbci --template confs/libvirt_lite.json generate SOME_DIR
./mdbci --template confs/docker_lite.json generate SOME_DIR2

./mdbci up SOME_DIR/node0
./mdbci up SOME_DIR2/node0

./mdbci snapshot take --path-to-nodes SOME_DIR --node-name node0 --snapshot-name SNAP_NAME

./mdbci snapshot take --path-to-nodes SOME_DIR2 --node-name node0 --snapshot-name SNAP_NAME

# As result, script will delete first match config of ALL PROVIDERS:
./scripts/clean_vms.sh SOME_DIR -o

3) Destroy only first match config of specified provider:

# Up several configs,take snapshot, run script.
./mdbci --template confs/libvirt_lite.json generate SOME_DIR
./mdbci --template confs/docker_lite.json generate SOME_DIR2

./mdbci up SOME_DIR/node0
./mdbci up SOME_DIR2/node0

./mdbci snapshot take --path-to-nodes SOME_DIR --node-name node0 --snapshot-name SNAP_NAME

./mdbci snapshot take --path-to-nodes SOME_DIR2 --node-name node0 --snapshot-name SNAP_NAME

# As result, script will delete first match config of Libvirt provider:
./scripts/clean_vms.sh SOME_DIR -o libvirt

# SOME_DIR2_node0 will still alive.


Description

- Modify clean_vms to remove properly configurations that contains snapshots (for Docker/Libvirt)
- Add ability to destroy only one config in clean_vms (using command line flag of clean_vms.sh)

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

12:48] 
timofey.turenko нам нужно сделать надежную очистку машин. Тпм похоже в случае со снагшотами не всегда destroy страбатывет. В идеале сделать mdbci destroy, который делает vagrant destroy, а потом если не удалось, то через virsh

[12:48] 
но можно и просто в clean_vms добавить очистку машин со снапшотами

[12:50] 
и еще хорошо бы к vlean_vms добавать опцию удалать только машину с точным именем, а не все машины, имена которых начинаются с заданной строки

History

#1 Updated by Mark Zaslavskiy over 4 years ago

  • Assignee changed from Alexander Kaluzhny to Ilfat Kinyaev

#2 Updated by Mark Zaslavskiy over 4 years ago

  • Description updated (diff)

#3 Updated by Ilfat Kinyaev over 4 years ago

  • Status changed from New to Active / In progress

#4 Updated by Ilfat Kinyaev over 4 years ago

1. Create snapshot:
./mdbci snapshot take
Delete:
./mdbci snapshot delete
( https://github.com/OSLL/mdbci#commands )

2. libvirt/ docker (not aws).

Main problem - when configuration is down, lost vagrant files and need delete is with virsh

#5 Updated by Mark Zaslavskiy over 4 years ago

  • Description updated (diff)

#6 Updated by Ilfat Kinyaev over 4 years ago

  • Estimated time set to 3:00 h

#7 Updated by Ilfat Kinyaev over 4 years ago

NOTE: For libvirt only!

Problem (from https://github.com/OSLL/mdbci/blob/integration/scripts/clean_vms.sh):
- up libvirt config and take snapshot;
- remove\replace Vagrantfile (not matters, just for future problems)
- try to (DOMAIN - name from virsh list --name --all ):

      virsh shutdown DOMAIN
      virsh destroy DOMAIN
      virsh undefine DOMAIN

- take error when undefine, because snapshot

Solution 1:
- delete snapshot manually (SNAPSHOT - early specified snapshot name):

virsh snapshot-delete DOMAIN SNAPSHOT

- and undefine successfully

Did not see for docker yet

#8 Updated by Ilfat Kinyaev over 4 years ago

NOTE: ./mdbci snapshot delete NOT WORKS!

vagranttest@maxscale-jenkins:~/mdbci_kinyaev/mdbci$ ./mdbci snapshot list --path-to-nodes SOME_DIR4 --node-name node0
 INFO:  MariaDb CI CLI
 INFO:  mdbci called with: ["snapshot", "list"]
 INFO:  Checking this machine configuration requirments
 INFO:  .....NOT IMPLEMENTED YET
 INFO:  Load Boxes from ./BOXES
 INFO:  Loaded boxes: 51
 INFO:  Load AWS config from aws-config.yml
 INFO:  Load Repos from ./repo.d
 INFO:  Looking up for repos ./repo.d
 INFO:  Loaded repos: 752
mdbci_snapshot_test_SOME_DIR4_node0
vagranttest@maxscale-jenkins:~/mdbci_kinyaev/mdbci$ ./mdbci snapshot delete --path-to-nodes SOME_DIR4 --node-name node0 --snapshot-name mdbci_snapshot_test_SOME_DIR4_node0
 INFO:  MariaDb CI CLI
 INFO:  mdbci called with: ["snapshot", "delete"]
 INFO:  Checking this machine configuration requirments
 INFO:  .....NOT IMPLEMENTED YET
 INFO:  Load Boxes from ./BOXES
 INFO:  Loaded boxes: 51
 INFO:  Load AWS config from aws-config.yml
 INFO:  Load Repos from ./repo.d
 INFO:  Looking up for repos ./repo.d
 INFO:  Loaded repos: 752
vagranttest@maxscale-jenkins:~/mdbci_kinyaev/mdbci$ echo $?
0
vagranttest@maxscale-jenkins:~/mdbci_kinyaev/mdbci$ virsh undefine SOME_DIR4_node0
error: Failed to undefine domain SOME_DIR4_node0
error: Requested operation is not valid: cannot delete inactive domain with 1 snapshots

vagranttest@maxscale-jenkins:~/mdbci_kinyaev/mdbci$ ./mdbci snapshot list --path-to-nodes SOME_DIR4 --node-name node0 INFO:  MariaDb CI CLI
 INFO:  mdbci called with: ["snapshot", "list"]
 INFO:  Checking this machine configuration requirments
 INFO:  .....NOT IMPLEMENTED YET
 INFO:  Load Boxes from ./BOXES
 INFO:  Loaded boxes: 51
 INFO:  Load AWS config from aws-config.yml
 INFO:  Load Repos from ./repo.d
 INFO:  Looking up for repos ./repo.d
 INFO:  Loaded repos: 752
mdbci_snapshot_test_SOME_DIR4_node0

#10 Updated by Ilfat Kinyaev over 4 years ago

  • % Done changed from 0 to 70
  • Test scenario updated (diff)

#11 Updated by Ilfat Kinyaev over 4 years ago

  • Test scenario updated (diff)

#12 Updated by Ilfat Kinyaev over 4 years ago

  • Status changed from Active / In progress to Review
  • Assignee changed from Ilfat Kinyaev to Mark Zaslavskiy
  • % Done changed from 70 to 100
  • Test scenario updated (diff)

#13 Updated by Ilfat Kinyaev over 4 years ago

  • Test scenario updated (diff)

#14 Updated by Mark Zaslavskiy over 4 years ago

  • Status changed from Review to Testing
  • Assignee changed from Mark Zaslavskiy to Timofey Turenko

#15 Updated by Timofey Turenko over 4 years ago

  • Status changed from Testing to Closed

Also available in: Atom PDF