CI: remove deletion tasks of 'packet' VMs

Kubevirt VMs deletion will be handled by the Kubernetes GC (see previous
commit), remove all the codes handling that.
pull/11530/head
Max Gautier 2024-09-13 12:02:11 +02:00
parent 65c67c5c51
commit e8ee422808
No known key found for this signature in database
9 changed files with 1 additions and 120 deletions

View File

@ -65,14 +65,6 @@
allow_failure: true
extends: .packet
packet_cleanup_old:
stage: deploy-part1
extends: .packet_periodic
script:
- cd tests
- make cleanup-packet
after_script: []
# The ubuntu20-calico-all-in-one jobs are meant as early stages to prevent running the full CI if something is horribly broken
packet_ubuntu20-calico-all-in-one:
stage: deploy-part1

View File

@ -20,18 +20,7 @@ create-packet: init-packet
-e pipeline_id="$(CI_PIPELINE_ID)" \
-e inventory_path=$(INVENTORY)
delete-packet:
ansible-playbook cloud_playbooks/delete-packet.yml -c local \
$(ANSIBLE_LOG_LEVEL) \
-e @"files/${CI_JOB_NAME}.yml" \
-e test_id=$(TEST_ID) \
-e branch="$(CI_COMMIT_BRANCH)" \
-e pipeline_id="$(CI_PIPELINE_ID)" \
-e inventory_path=$(INVENTORY)
cleanup-packet:
ansible-playbook cloud_playbooks/cleanup-packet.yml -c local \
$(ANSIBLE_LOG_LEVEL)
delete-packet: ;
create-vagrant:
vagrant up

View File

@ -1,8 +0,0 @@
---
- name: Cleanup packet vms
hosts: localhost
gather_facts: false
become: true
roles:
- { role: cleanup-packet-ci }

View File

@ -1,11 +0,0 @@
---
- name: Terminate Packet VMs
hosts: localhost
gather_facts: false
become: true
vars:
ci_job_name: "{{ lookup('env', 'CI_JOB_NAME') }}"
test_name: "{{ test_id | regex_replace('\\.', '-') }}"
roles:
- { role: packet-ci, vm_cleanup: true }

View File

@ -1,16 +0,0 @@
---
- name: Fetch a list of namespaces
kubernetes.core.k8s_info:
api_version: v1
kind: Namespace
label_selectors:
- cijobs = true
register: namespaces
- name: Delete stale namespaces for more than 2 hours
command: "kubectl delete namespace {{ item.metadata.name }}"
failed_when: false
loop: "{{ namespaces.resources }}"
when:
- (now() - (item.metadata.creationTimestamp | to_datetime("%Y-%m-%dT%H:%M:%SZ"))).total_seconds() >= 7200

View File

@ -1,17 +0,0 @@
---
- name: Fetch a list of namespaces
kubernetes.core.k8s_info:
api_version: v1
kind: Namespace
label_selectors:
- cijobs = true
- branch = {{ branch_name_sane }}
register: namespaces
- name: Delete older namespaces
command: "kubectl delete namespace {{ item.metadata.name }}"
failed_when: false
loop: "{{ namespaces.resources }}"
when:
- (item.metadata.labels.pipeline_id | int) < (pipeline_id | int)

View File

@ -1,11 +1,4 @@
---
- name: "Create CI namespace {{ test_name }} for test vms"
shell: |-
kubectl create namespace {{ test_name }} &&
kubectl label namespace {{ test_name }} cijobs=true branch="{{ branch_name_sane }}" pipeline_id="{{ pipeline_id }}"
changed_when: false
- name: "Create temp dir /tmp/{{ test_name }} for CI files"
file:
path: "/tmp/{{ test_name }}"

View File

@ -1,30 +0,0 @@
---
- name: Check if temp directory for {{ test_name }} exists
stat:
path: "/tmp/{{ test_name }}"
get_attributes: false
get_checksum: false
get_mime: false
register: temp_dir_details
- name: "Cleanup temp directory for {{ test_name }}"
file:
path: "/tmp/{{ test_name }}"
state: absent
- name: "Cleanup namespace for {{ test_name }}"
command: "kubectl delete namespace {{ test_name }}"
changed_when: false
- name: Wait for namespace {{ test_name }} to be fully deleted
command: kubectl get ns {{ test_name }}
register: delete_namespace
failed_when:
- delete_namespace.rc == 0
changed_when:
- delete_namespace.rc == 0
retries: 12
delay: 10
until:
- delete_namespace.rc != 0

View File

@ -2,16 +2,5 @@
- name: "Include custom vars for ci job: {{ ci_job_name }}"
include_vars: "../files/{{ ci_job_name }}.yml"
- name: Cleamup old VMs
import_tasks: cleanup-old-vms.yml
- name: Create VMs
import_tasks: create-vms.yml
when:
- not vm_cleanup
- name: Delete VMs
import_tasks: delete-vms.yml
when:
- vm_cleanup | default(false)