diff --git a/tools/cloud-build/daily-tests/ansible_playbooks/base-integration-test.yml b/tools/cloud-build/daily-tests/ansible_playbooks/base-integration-test.yml index 3b7649187a..b5131a4ac4 100644 --- a/tools/cloud-build/daily-tests/ansible_playbooks/base-integration-test.yml +++ b/tools/cloud-build/daily-tests/ansible_playbooks/base-integration-test.yml @@ -143,7 +143,7 @@ ansible.builtin.add_host: hostname: "{{ remote_ip }}" groups: [remote_host] - when: remote_ip | ansible.utils.ipaddr + when: (remote_ip | default('')) | ansible.utils.ipaddr != false - name: Wait for host tasks ansible.builtin.include_tasks: tasks/wait-for-host.yml diff --git a/tools/cloud-build/daily-tests/ansible_playbooks/htcondor-integration-test.yml b/tools/cloud-build/daily-tests/ansible_playbooks/htcondor-integration-test.yml index fb28ceb58b..4a71e601d5 100644 --- a/tools/cloud-build/daily-tests/ansible_playbooks/htcondor-integration-test.yml +++ b/tools/cloud-build/daily-tests/ansible_playbooks/htcondor-integration-test.yml @@ -70,7 +70,7 @@ ansible.builtin.add_host: hostname: "{{ access_ip.stdout }}" groups: [remote_host] - when: access_ip.stdout | ansible.utils.ipaddr + when: (access_ip.stdout | default('')) | ansible.utils.ipaddr != false ## Setup firewall for cloud build - name: Create firewall rule register: fw_result diff --git a/tools/cloud-build/daily-tests/ansible_playbooks/slurm-integration-test.yml b/tools/cloud-build/daily-tests/ansible_playbooks/slurm-integration-test.yml index 24abd4b0f6..d30f844417 100644 --- a/tools/cloud-build/daily-tests/ansible_playbooks/slurm-integration-test.yml +++ b/tools/cloud-build/daily-tests/ansible_playbooks/slurm-integration-test.yml @@ -173,7 +173,7 @@ ansible.builtin.add_host: hostname: "{{ login_ip }}" groups: [remote_host] - when: login_ip | ansible.utils.ipaddr + when: (login_ip | default('')) | ansible.utils.ipaddr != false - name: Wait for host tasks ansible.builtin.include_tasks: tasks/wait-for-host.yml diff --git a/tools/cloud-build/daily-tests/ansible_playbooks/tasks/get_instance_ids.yml b/tools/cloud-build/daily-tests/ansible_playbooks/tasks/get_instance_ids.yml index b06d12e8f7..5d36fdcfb3 100644 --- a/tools/cloud-build/daily-tests/ansible_playbooks/tasks/get_instance_ids.yml +++ b/tools/cloud-build/daily-tests/ansible_playbooks/tasks/get_instance_ids.yml @@ -15,7 +15,7 @@ --- - name: Gather instance information delegate_to: localhost - when: deployment_name is defined and deployment_name | string + when: deployment_name is defined and deployment_name | length > 0 changed_when: false register: instances until: instances.rc == 0 @@ -30,7 +30,7 @@ ansible.builtin.debug: var: instances.stdout - name: Print Cloud Logging command - when: instances is defined and instances.stdout | list + when: instances is defined and (instances.stdout | from_json | length > 0) ansible.builtin.debug: msg: gcloud logging --project {{ project }} read 'logName="projects/{{ project }}/logs/google_metadata_script_runner" AND resource.labels.instance_id="{{ item.id }}"' --format="table(timestamp, jsonPayload.message)" --freshness 24h | tac - loop: "{{ instances.stdout }}" + loop: "{{ instances.stdout | from_json | default([]) }}" diff --git a/tools/cloud-build/images/test-runner/Dockerfile b/tools/cloud-build/images/test-runner/Dockerfile index a9d1639dff..19824a3fc7 100644 --- a/tools/cloud-build/images/test-runner/Dockerfile +++ b/tools/cloud-build/images/test-runner/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM golang:bullseye +FROM golang:1.26.1-trixie ENV GOCACHE=/ghpc_go_cache @@ -20,35 +20,38 @@ ENV GOCACHE=/ghpc_go_cache # use `/workspace` to match path in cache for future builds COPY ./ /workspace -RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - && \ - apt-get -y update && apt-get -y install \ - # `software-properties-common` providers `add-apt-repository` - software-properties-common \ +RUN apt-get -y update && apt-get -y install \ + gnupg \ keychain \ # `dnsutils` provides `dig` used by integration tests dnsutils && \ # install terraform and packer - apt-add-repository "deb [arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com bullseye main" && \ + curl -fsSL https://apt.releases.hashicorp.com/gpg | gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg && \ + echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg arch=$(dpkg --print-architecture)] https://apt.releases.hashicorp.com trixie main" | tee /etc/apt/sources.list.d/hashicorp.list && \ apt-get -y update && \ # Pin Terraform version to 1.12.2 - apt-get install -y unzip python3-pip python3-netaddr terraform=1.12.2-1 packer jq && \ + apt-get install -y unzip python3-pip python3-venv terraform=1.12.2-1 packer jq && \ # install gcloud + curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg && \ echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" \ | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \ - curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \ - | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && \ apt-get -y update && apt-get -y install google-cloud-sdk && \ apt-get -y install kubectl && \ # following is required to execute kubectl commands apt-get -y install google-cloud-cli-gke-gcloud-auth-plugin && \ apt-get clean && rm -rf /var/lib/apt/lists/* && \ + # create virtual environment + python3 -m venv /opt/venv && \ # install ansible and python dependencies - pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r https://raw.githubusercontent.com/GoogleCloudPlatform/slurm-gcp/master/scripts/requirements.txt && \ - pip install --no-cache-dir ansible && \ - pip install --no-cache-dir paramiko && \ + /opt/venv/bin/pip install --no-cache-dir --upgrade pip && \ + /opt/venv/bin/pip install --no-cache-dir -r https://raw.githubusercontent.com/GoogleCloudPlatform/slurm-gcp/master/scripts/requirements.txt && \ + /opt/venv/bin/pip install --no-cache-dir ansible && \ + /opt/venv/bin/pip install --no-cache-dir paramiko && \ + /opt/venv/bin/pip install --no-cache-dir netaddr && \ rm -rf ~/.cache/pip/* && \ # compile the binary to warm up `/ghpc_go_cache` cd /workspace && make gcluster && \ # remove /workspace to reduce image size rm -rf /workspace + +ENV PATH="/opt/venv/bin:$PATH"