diff --git a/.gitlab-ci/packet.yml b/.gitlab-ci/packet.yml index 1d909da83..d7b3a34e9 100644 --- a/.gitlab-ci/packet.yml +++ b/.gitlab-ci/packet.yml @@ -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 diff --git a/tests/Makefile b/tests/Makefile index f052978b1..18e87a2dd 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -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 diff --git a/tests/cloud_playbooks/cleanup-packet.yml b/tests/cloud_playbooks/cleanup-packet.yml deleted file mode 100644 index 2ba5e3021..000000000 --- a/tests/cloud_playbooks/cleanup-packet.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- - -- name: Cleanup packet vms - hosts: localhost - gather_facts: false - become: true - roles: - - { role: cleanup-packet-ci } diff --git a/tests/cloud_playbooks/delete-packet.yml b/tests/cloud_playbooks/delete-packet.yml deleted file mode 100644 index 7320da622..000000000 --- a/tests/cloud_playbooks/delete-packet.yml +++ /dev/null @@ -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 } diff --git a/tests/cloud_playbooks/roles/cleanup-packet-ci/tasks/main.yml b/tests/cloud_playbooks/roles/cleanup-packet-ci/tasks/main.yml deleted file mode 100644 index 9256b2d54..000000000 --- a/tests/cloud_playbooks/roles/cleanup-packet-ci/tasks/main.yml +++ /dev/null @@ -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 diff --git a/tests/cloud_playbooks/roles/packet-ci/tasks/cleanup-old-vms.yml b/tests/cloud_playbooks/roles/packet-ci/tasks/cleanup-old-vms.yml deleted file mode 100644 index 052a44fd1..000000000 --- a/tests/cloud_playbooks/roles/packet-ci/tasks/cleanup-old-vms.yml +++ /dev/null @@ -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) diff --git a/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml b/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml index 2a73b674d..28ef298ab 100644 --- a/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml +++ b/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml @@ -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 }}" diff --git a/tests/cloud_playbooks/roles/packet-ci/tasks/delete-vms.yml b/tests/cloud_playbooks/roles/packet-ci/tasks/delete-vms.yml deleted file mode 100644 index 75156584a..000000000 --- a/tests/cloud_playbooks/roles/packet-ci/tasks/delete-vms.yml +++ /dev/null @@ -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 diff --git a/tests/cloud_playbooks/roles/packet-ci/tasks/main.yml b/tests/cloud_playbooks/roles/packet-ci/tasks/main.yml index f2dea7f6b..3ab879742 100644 --- a/tests/cloud_playbooks/roles/packet-ci/tasks/main.yml +++ b/tests/cloud_playbooks/roles/packet-ci/tasks/main.yml @@ -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)