-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: cleanup stale packet namespace after 2 hours
This ensure that we don't have any packet namespace remaining for more than 2 hours. All the jobs complete usually within 30min-1hour so 2 hours is enough to detect a stale namespace. Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch>
- Loading branch information
1 parent
8047626
commit 0d6840c
Showing
4 changed files
with
34 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
|
||
- hosts: localhost | ||
gather_facts: no | ||
become: true | ||
roles: | ||
- { role: cleanup-packet-ci } |
15 changes: 15 additions & 0 deletions
15
tests/cloud_playbooks/roles/cleanup-packet-ci/tasks/main.yml
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
|
||
- 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 }}" | ||
loop: "{{ namespaces.resources }}" | ||
when: | ||
- (now() - (item.metadata.creationTimestamp | to_datetime("%Y-%m-%dT%H:%M:%SZ"))).total_seconds() >= 7200 |