Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/packet-ci: sanitize branch name for kubernetes labels #10315

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/cloud_playbooks/roles/packet-ci/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ vm_cpu_sockets: 1
vm_cpu_threads: 2
vm_memory: 2048Mi

# Replace invalid characters so that we can use the branch name in kubernetes labels
branch_name_sane: "{{ branch | regex_replace('/', '-') }}"

# Request/Limit allocation settings

cpu_allocation_ratio: 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
kind: Namespace
label_selectors:
- cijobs = true
- branch = {{ branch }}
- branch = {{ branch_name_sane }}
register: namespaces

- name: Delete older namespaces
Expand Down
2 changes: 1 addition & 1 deletion tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- name: "Create CI namespace {{ test_name }} for test vms"
shell: |-
kubectl create namespace {{ test_name }} &&
kubectl label namespace {{ test_name }} cijobs=true branch="{{ branch }}" pipeline_id="{{ pipeline_id }}"
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"
Expand Down