From f378ce0670a6b31d8373ecf48d85a6017d5c3b69 Mon Sep 17 00:00:00 2001 From: Giles Hutton Date: Wed, 31 Jul 2024 14:48:08 +0100 Subject: [PATCH 1/4] Simplify GCP VM creation Remove collection method (unused) Remove collector- prefix (it's implied) Truncate family name to max 16 characters --- ansible/ci/group_vars/all.yml | 2 +- ansible/dev/group_vars/all.yml | 2 +- ansible/roles/create-all-vms/tasks/by-family.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ansible/ci/group_vars/all.yml b/ansible/ci/group_vars/all.yml index 5be40f3348..02bb350a7c 100644 --- a/ansible/ci/group_vars/all.yml +++ b/ansible/ci/group_vars/all.yml @@ -3,7 +3,7 @@ gcp_project: "acs-san-stackroxci" gcp_auth_kind: "serviceaccount" gcp_service_account_file: /tmp/secret/stackrox-collector-e2e-tests/GOOGLE_CREDENTIALS_COLLECTOR_SVC_ACCT -gcp_instance_prefix: collector-ci +gcp_instance_prefix: ci gcp_available_zones: - us-central1-a - us-central1-b diff --git a/ansible/dev/group_vars/all.yml b/ansible/dev/group_vars/all.yml index ede663dac7..0f9f8b960d 100644 --- a/ansible/dev/group_vars/all.yml +++ b/ansible/dev/group_vars/all.yml @@ -4,7 +4,7 @@ gcp_project: "acs-team-sandbox" gcp_auth_kind: "application" gcp_service_account_file: null -gcp_instance_prefix: collector-dev +gcp_instance_prefix: dev gcp_available_zones: - us-central1-a - us-central1-b diff --git a/ansible/roles/create-all-vms/tasks/by-family.yml b/ansible/roles/create-all-vms/tasks/by-family.yml index e42fa3c412..f6a140e557 100644 --- a/ansible/roles/create-all-vms/tasks/by-family.yml +++ b/ansible/roles/create-all-vms/tasks/by-family.yml @@ -20,7 +20,7 @@ apply: environment: "{{ ibm_env | default({}) }}" vars: - vm_name: "{{ gcp_instance_prefix }}-{{ normalized_collection_method }}-{{ item.1 }}-{{ job_id }}" + vm_name: "{{ gcp_instance_prefix }}-{{ item.1 | truncate(16, True, '') }}-{{ job_id }}" vm_project: "{{ item.0.value.project }}" vm_family: "{{ item.1 }}" vm_platform: "{{ item.0.key }}" From e85f3e06c2378ee9a89cbc411db06ea449810162 Mon Sep 17 00:00:00 2001 From: Giles Hutton Date: Wed, 31 Jul 2024 15:39:08 +0100 Subject: [PATCH 2/4] Fix name match in gcp dynamic inventory --- ansible/ci/inventory_gcp.yml | 2 +- ansible/dev/inventory_gcp.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/ci/inventory_gcp.yml b/ansible/ci/inventory_gcp.yml index 7781ea24e7..979b37a976 100644 --- a/ansible/ci/inventory_gcp.yml +++ b/ansible/ci/inventory_gcp.yml @@ -4,7 +4,7 @@ plugin: gcp_compute projects: - acs-san-stackroxci filters: - - name = collector-ci-* + - name = ci-* keyed_groups: # This will group the VMs by their labels, which means that on # creation, we can use a unique identifier to group VMs diff --git a/ansible/dev/inventory_gcp.yml b/ansible/dev/inventory_gcp.yml index 183b3fb42c..e09bc1afaa 100644 --- a/ansible/dev/inventory_gcp.yml +++ b/ansible/dev/inventory_gcp.yml @@ -4,7 +4,7 @@ plugin: gcp_compute projects: - acs-team-sandbox filters: - - name = collector-dev-* + - name = dev-* keyed_groups: # This will group the VMs by their labels, which means that on # creation, we can use a unique identifier to group VMs From 39f5c66645cd61417baa97067e06b9be24477499 Mon Sep 17 00:00:00 2001 From: Giles Hutton Date: Wed, 31 Jul 2024 15:56:52 +0100 Subject: [PATCH 3/4] Hash job ID to keep it constant length --- ansible/roles/create-all-vms/tasks/by-family.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ansible/roles/create-all-vms/tasks/by-family.yml b/ansible/roles/create-all-vms/tasks/by-family.yml index f6a140e557..692835e495 100644 --- a/ansible/roles/create-all-vms/tasks/by-family.yml +++ b/ansible/roles/create-all-vms/tasks/by-family.yml @@ -5,6 +5,7 @@ - set_fact: arch: "{{ item.0.value.arch | default('amd64') }}" + hashed_job_id: "{{ job_id | hash('md5') | truncate(16, True, '') }}" - set_fact: ibm_env: "{{ s390x.env }}" @@ -20,7 +21,7 @@ apply: environment: "{{ ibm_env | default({}) }}" vars: - vm_name: "{{ gcp_instance_prefix }}-{{ item.1 | truncate(16, True, '') }}-{{ job_id }}" + vm_name: "{{ gcp_instance_prefix }}-{{ item.1 | truncate(16, True, '') }}-{{ hashed_job_id }}" vm_project: "{{ item.0.value.project }}" vm_family: "{{ item.1 }}" vm_platform: "{{ item.0.key }}" From 767864b7d524eab6bd9b51729c397812ee05e720 Mon Sep 17 00:00:00 2001 From: Giles Hutton Date: Wed, 31 Jul 2024 16:26:47 +0100 Subject: [PATCH 4/4] Remove unused var and remove family truncation --- ansible/roles/create-all-vms/tasks/by-family.yml | 2 +- ansible/roles/create-all-vms/tasks/main.yml | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ansible/roles/create-all-vms/tasks/by-family.yml b/ansible/roles/create-all-vms/tasks/by-family.yml index 692835e495..51b750c70c 100644 --- a/ansible/roles/create-all-vms/tasks/by-family.yml +++ b/ansible/roles/create-all-vms/tasks/by-family.yml @@ -21,7 +21,7 @@ apply: environment: "{{ ibm_env | default({}) }}" vars: - vm_name: "{{ gcp_instance_prefix }}-{{ item.1 | truncate(16, True, '') }}-{{ hashed_job_id }}" + vm_name: "{{ gcp_instance_prefix }}-{{ item.1 }}-{{ hashed_job_id }}" vm_project: "{{ item.0.value.project }}" vm_family: "{{ item.1 }}" vm_platform: "{{ item.0.key }}" diff --git a/ansible/roles/create-all-vms/tasks/main.yml b/ansible/roles/create-all-vms/tasks/main.yml index 20e0bfd289..ad1ecec854 100644 --- a/ansible/roles/create-all-vms/tasks/main.yml +++ b/ansible/roles/create-all-vms/tasks/main.yml @@ -1,8 +1,5 @@ --- -- set_fact: - normalized_collection_method: "{{ collection_method | default('any') | replace('core_bpf', 'core') }}" - - name: Create VMs From Family include_tasks: by-family.yml #