-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11530 from VannTen/ci/cleanup_with_k8s_gc
[CI] Use Kubernetes GC to clean kubevirt VMs (packet-* jobs)
- Loading branch information
Showing
18 changed files
with
152 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
tests/cloud_playbooks/roles/cleanup-packet-ci/tasks/main.yml
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
tests/cloud_playbooks/roles/packet-ci/tasks/cleanup-old-vms.yml
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
tests/cloud_playbooks/roles/packet-ci/tasks/delete-vms.yml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,52 @@ | ||
--- | ||
|
||
- name: "Include custom vars for ci job: {{ ci_job_name }}" | ||
- name: Include custom vars for ci job | ||
include_vars: "../files/{{ ci_job_name }}.yml" | ||
|
||
- name: Cleamup old VMs | ||
import_tasks: cleanup-old-vms.yml | ||
- name: Start vms for CI job | ||
vars: | ||
# Workaround for compatibility when testing upgrades with old == before e9d406ed088d4291ef1d9018c170a4deed2bf928 | ||
# TODO: drop after 2.27.0 | ||
legacy_groups: "{{ (['kube_control_plane', 'kube_node', 'calico_rr'] | intersect(item) | length > 0) | ternary(['k8s_cluster'], []) }}" | ||
tvars: | ||
kubespray_groups: "{{ item + legacy_groups }}" | ||
kubernetes.core.k8s: | ||
definition: "{{ lookup('template', 'vm.yml.j2', template_vars=tvars) }}" | ||
loop: "{{ scenarios[mode | d('default')] }}" | ||
|
||
- name: Wait for vms to have IP addresses | ||
kubernetes.core.k8s_info: | ||
api_version: kubevirt.io/v1 | ||
kind: VirtualMachineInstance | ||
label_selectors: | ||
- "ci_job_id={{ ci_job_id }}" | ||
namespace: "{{ pod_namespace }}" | ||
register: vmis | ||
until: vmis.resources | ||
| map(attribute='status.interfaces.0') | ||
| rejectattr('ipAddress', 'defined') == [] | ||
retries: 30 | ||
delay: 10 | ||
|
||
- name: Create VMs | ||
import_tasks: create-vms.yml | ||
when: | ||
- not vm_cleanup | ||
- name: Massage VirtualMachineInstance data into an Ansible inventory structure | ||
vars: | ||
ips: "{{ vmis.resources | map(attribute='status.interfaces.0.ipAddress') }}" | ||
names: "{{ vmis.resources | map(attribute='metadata.name') }}" | ||
_groups: "{{ vmis.resources | map(attribute='metadata.annotations.ansible_groups') | map('split', ',') }}" | ||
hosts: "{{ ips | zip(_groups, names) | ||
| map('zip', ['ansible_host', 'ansible_groups', 'k8s_vmi_name']) | ||
| map('map', 'reverse') | map('community.general.dict') }}" | ||
loop: "{{ hosts | map(attribute='ansible_groups') | flatten | unique }}" | ||
set_fact: | ||
ci_inventory: "{{ ci_inventory|d({}) | combine({ | ||
item: { | ||
'hosts': hosts | selectattr('ansible_groups', 'contains', item) | ||
| rekey_on_member('k8s_vmi_name') | ||
} | ||
}) | ||
}}" | ||
|
||
- name: Delete VMs | ||
import_tasks: delete-vms.yml | ||
when: | ||
- vm_cleanup | default(false) | ||
- name: Create inventory for CI tests | ||
copy: | ||
content: "{{ ci_inventory | to_yaml }}" | ||
dest: "{{ inventory_path }}/ci_inventory.yml" | ||
mode: "0644" |
98 changes: 0 additions & 98 deletions
98
tests/cloud_playbooks/roles/packet-ci/templates/inventory.j2
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.