Skip to content

Commit e36dad7

Browse files
authored
Merge branch 'main' into ci/nightly-builds
2 parents 92e6d1c + 17a2432 commit e36dad7

File tree

7 files changed

+159
-19
lines changed

7 files changed

+159
-19
lines changed

.github/workflows/fatimage.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
name: Build fat image
33
on:
44
workflow_dispatch:
5+
inputs:
6+
ci_cloud:
7+
description: 'Select the CI_CLOUD'
8+
required: true
9+
type: choice
10+
options:
11+
- LEAFCLOUD
12+
- SMS
13+
- ARCUS
514
schedule:
615
- cron: '0 0 * * *' # Run at midnight
716

@@ -27,15 +36,19 @@ jobs:
2736
env:
2837
ANSIBLE_FORCE_COLOR: True
2938
OS_CLOUD: openstack
30-
CI_CLOUD: ${{ vars.CI_CLOUD }}
39+
CI_CLOUD: ${{ github.event.inputs.ci_cloud }}
3140
steps:
3241
- uses: actions/checkout@v2
3342

43+
- name: Record settings for CI cloud
44+
run: |
45+
echo CI_CLOUD: ${{ env.CI_CLOUD }}
46+
3447
- name: Setup ssh
3548
run: |
3649
set -x
3750
mkdir ~/.ssh
38-
echo "${{ secrets[format('{0}_SSH_KEY', vars.CI_CLOUD)] }}" > ~/.ssh/id_rsa
51+
echo "${{ secrets[format('{0}_SSH_KEY', env.CI_CLOUD)] }}" > ~/.ssh/id_rsa
3952
chmod 0600 ~/.ssh/id_rsa
4053
shell: bash
4154

@@ -49,7 +62,7 @@ jobs:
4962
- name: Write clouds.yaml
5063
run: |
5164
mkdir -p ~/.config/openstack/
52-
echo "${{ secrets[format('{0}_CLOUDS_YAML', vars.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
65+
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
5366
shell: bash
5467

5568
- name: Setup environment

.github/workflows/stackhpc.yml

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,21 @@ on:
55
push:
66
branches:
77
- main
8+
paths:
9+
- '**'
10+
- '!dev/**'
11+
- 'dev/setup-env.sh'
12+
- '!docs/**'
13+
- '!README.md'
14+
- '!.gitignore'
815
pull_request:
16+
paths:
17+
- '**'
18+
- '!dev/**'
19+
- 'dev/setup-env.sh'
20+
- '!docs/**'
21+
- '!README.md'
22+
- '!.gitignore'
923
jobs:
1024
openstack:
1125
name: openstack-ci
@@ -23,43 +37,57 @@ jobs:
2337
ANSIBLE_FORCE_COLOR: True
2438
OS_CLOUD: openstack
2539
TF_VAR_cluster_name: slurmci-${{ matrix.os_version }}-${{ github.run_number }}
26-
CI_CLOUD: ${{ vars.CI_CLOUD }}
40+
CI_CLOUD: ${{ vars.CI_CLOUD }} # default from repo settings
2741
TF_VAR_os_version: ${{ matrix.os_version }}
2842
steps:
2943
- uses: actions/checkout@v2
3044

45+
- name: Override CI_CLOUD if PR label is present
46+
if: ${{ github.event_name == 'pull_request' }}
47+
run: |
48+
# Iterate over the labels
49+
labels=$(echo '${{ toJSON(github.event.pull_request.labels) }}' | jq -r '.[].name')
50+
echo $labels
51+
for label in $labels; do
52+
if [[ $label == CI_CLOUD=* ]]; then
53+
# Extract the value after 'CI_CLOUD='
54+
CI_CLOUD_OVERRIDE=${label#CI_CLOUD=}
55+
echo "CI_CLOUD=${CI_CLOUD_OVERRIDE}" >> $GITHUB_ENV
56+
fi
57+
done
58+
3159
- name: Record settings for CI cloud
3260
run: |
33-
echo CI_CLOUD: ${{ vars.CI_CLOUD }}
61+
echo CI_CLOUD: ${{ env.CI_CLOUD }}
3462
3563
- name: Setup ssh
3664
run: |
3765
set -x
3866
mkdir ~/.ssh
39-
echo "${{ secrets[format('{0}_SSH_KEY', vars.CI_CLOUD)] }}" > ~/.ssh/id_rsa
67+
echo "${{ secrets[format('{0}_SSH_KEY', env.CI_CLOUD)] }}" > ~/.ssh/id_rsa
4068
chmod 0600 ~/.ssh/id_rsa
4169
shell: bash
42-
70+
4371
- name: Add bastion's ssh key to known_hosts
4472
run: cat environments/.stackhpc/bastion_fingerprints >> ~/.ssh/known_hosts
4573
shell: bash
46-
74+
4775
- name: Install ansible etc
4876
run: dev/setup-env.sh
4977

5078
- name: Install OpenTofu
5179
uses: opentofu/setup-opentofu@v1
5280
with:
5381
tofu_version: 1.6.2
54-
82+
5583
- name: Initialise terraform
5684
run: terraform init
5785
working-directory: ${{ github.workspace }}/environments/.stackhpc/terraform
58-
86+
5987
- name: Write clouds.yaml
6088
run: |
6189
mkdir -p ~/.config/openstack/
62-
echo "${{ secrets[format('{0}_CLOUDS_YAML', vars.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
90+
echo "${{ secrets[format('{0}_CLOUDS_YAML', env.CI_CLOUD)] }}" > ~/.config/openstack/clouds.yaml
6391
shell: bash
6492

6593
- name: Setup environment-specific inventory/terraform inputs
@@ -77,14 +105,14 @@ jobs:
77105
. venv/bin/activate
78106
. environments/.stackhpc/activate
79107
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
80-
terraform apply -auto-approve -var-file="${{ vars.CI_CLOUD }}.tfvars"
108+
terraform apply -auto-approve -var-file="${{ env.CI_CLOUD }}.tfvars"
81109
82110
- name: Delete infrastructure if provisioning failed
83111
run: |
84112
. venv/bin/activate
85113
. environments/.stackhpc/activate
86114
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
87-
terraform destroy -auto-approve -var-file="${{ vars.CI_CLOUD }}.tfvars"
115+
terraform destroy -auto-approve -var-file="${{ env.CI_CLOUD }}.tfvars"
88116
if: failure() && steps.provision_servers.outcome == 'failure'
89117

90118
- name: Configure cluster
@@ -111,14 +139,14 @@ jobs:
111139
run: |
112140
. venv/bin/activate
113141
. environments/.stackhpc/activate
114-
142+
115143
# load ansible variables into shell:
116144
ansible-playbook ansible/ci/output_vars.yml \
117145
-e output_vars_hosts=openondemand \
118146
-e output_vars_path=$APPLIANCES_ENVIRONMENT_ROOT/vars.txt \
119147
-e output_vars_items=bastion_ip,bastion_user,openondemand_servername
120148
source $APPLIANCES_ENVIRONMENT_ROOT/vars.txt
121-
149+
122150
# setup ssh proxying:
123151
sudo apt-get --yes install proxychains
124152
echo proxychains installed
@@ -155,7 +183,7 @@ jobs:
155183
# ansible login -v -a "sudo scontrol reboot ASAP nextstate=RESUME reason='rebuild image:${{ steps.packer_build.outputs.NEW_COMPUTE_IMAGE_ID }}' ${TF_VAR_cluster_name}-compute-[0-3]"
156184
# ansible compute -m wait_for_connection -a 'delay=60 timeout=600' # delay allows node to go down
157185
# ansible-playbook -v ansible/ci/check_slurm.yml
158-
186+
159187
- name: Test reimage of login and control nodes (via rebuild adhoc)
160188
run: |
161189
. venv/bin/activate
@@ -164,7 +192,7 @@ jobs:
164192
ansible all -m wait_for_connection -a 'delay=60 timeout=600' # delay allows node to go down
165193
ansible-playbook -v ansible/site.yml
166194
ansible-playbook -v ansible/ci/check_slurm.yml
167-
195+
168196
- name: Check sacct state survived reimage
169197
run: |
170198
. venv/bin/activate
@@ -182,7 +210,7 @@ jobs:
182210
. venv/bin/activate
183211
. environments/.stackhpc/activate
184212
cd $APPLIANCES_ENVIRONMENT_ROOT/terraform
185-
terraform destroy -auto-approve -var-file="${{ vars.CI_CLOUD }}.tfvars"
213+
terraform destroy -auto-approve -var-file="${{ env.CI_CLOUD }}.tfvars"
186214
if: ${{ success() || cancelled() }}
187215

188216
# - name: Delete images

dev/extract_logs.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
Process packer build workflow logs into CSV. Useful for timing
5+
dissemination.
6+
7+
Usage:
8+
extract_logs.py <logs.txt>
9+
10+
Where logs.txt is the name of the workflow log downloaded.
11+
It will list task name, against task directory path, against time to complete.
12+
"""
13+
14+
import csv
15+
import re
16+
import os
17+
import sys
18+
19+
def convert_time_to_seconds(time_str):
20+
h, m, s = time_str.split(':')
21+
return int(h) * 3600 + int(m) * 60 + float(s)
22+
23+
def extract_log_info_and_generate_csv(log_file_path, output_csv_path, target_directory):
24+
data = []
25+
26+
unwanted_chars = re.compile(r'(\x1B\[[0-9;]*m)|([^\x00-\x7F])')
27+
28+
with open(log_file_path, 'r') as file:
29+
lines = file.readlines()
30+
31+
previous_task = None
32+
33+
for i in range(len(lines)):
34+
if "TASK [" in lines[i]:
35+
task_name = lines[i].strip().split('TASK [')[1].split(']')[0]
36+
37+
full_task_path = lines[i + 1].strip().split('task path: ')[1]
38+
if target_directory in full_task_path:
39+
start_index = full_task_path.find(target_directory) + len(target_directory)
40+
partial_task_path = full_task_path[start_index:]
41+
else:
42+
partial_task_path = full_task_path
43+
44+
partial_task_path = unwanted_chars.sub('', partial_task_path).strip()
45+
46+
time_to_complete = lines[i + 2].strip().split('(')[1].split(')')[0]
47+
48+
if previous_task:
49+
previous_task[2] = time_to_complete # Shift the time to the previous task
50+
data.append(previous_task)
51+
52+
previous_task = [task_name, partial_task_path, None] # Placeholder for the next time_to_complete
53+
54+
if previous_task:
55+
previous_task[2] = time_to_complete if time_to_complete else 'N/A'
56+
data.append(previous_task)
57+
58+
for row in data:
59+
if row[2] != 'N/A':
60+
row[2] = convert_time_to_seconds(row[2])
61+
62+
data.sort(key=lambda x: x[2], reverse=True)
63+
64+
for row in data:
65+
if isinstance(row[2], float):
66+
row[2] = f'{int(row[2] // 3600):02}:{int((row[2] % 3600) // 60):02}:{row[2] % 60:.3f}'
67+
68+
with open(output_csv_path, 'w', newline='') as csvfile:
69+
csvwriter = csv.writer(csvfile)
70+
csvwriter.writerow(['Task Name', 'Task Path', 'Time to Complete'])
71+
csvwriter.writerows(data)
72+
73+
print(f"Data extracted, sorted, and saved to {output_csv_path}")
74+
75+
if len(sys.argv) != 2:
76+
print("Path to workflow log plain text file should be provided as the only arg to this script")
77+
sys.exit(1)
78+
log_file_path = sys.argv[1] # Input workflow log name
79+
output_csv_path = log_file_path.replace('.txt.', '.csv') # Output CSV name
80+
target_directory = '/ansible/' # Shared directory for task path
81+
82+
extract_log_info_and_generate_csv(log_file_path, output_csv_path, target_directory)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
flavor = "general.v1.small"
2+
networks = ["e2b9e59f-43da-4e1c-b558-dc9da4c0d738"] # stackhpc-ipv4-geneve
3+
ssh_keypair_name = "slurm-app-ci"
4+
ssh_private_key_file = "~/.ssh/id_rsa"
5+
ssh_bastion_username = "slurm-app-ci"
6+
ssh_bastion_host = "185.45.78.150"
7+
ssh_bastion_private_key_file = "~/.ssh/id_rsa"

environments/.stackhpc/bastion_fingerprints

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
|1|whGSPLhKW4xt/7PWOZ1treg3PtA=|F5gwV8j0JYWDzjb6DvHHaqO+sxs= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCpCG881Gt3dr+nuVIC2uGEQkeVwG6WDdS1WcCoxXC7AG+Oi5bfdqtf4IfeLpWmeuEaAaSFH48ODFr76ViygSjU=
33
|1|0V6eQ1FKO5NMKaHZeNFbw62mrJs=|H1vuGTbbtZD2MEgZxQf1PXPk+yU= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEnOtYByM3s2qvRT8SS1sn5z5sbwjzb1alm0B3emPcHJ
44
|1|u3QVAK9R2x7Z3uKNj+0vDEIekl0=|yy09Q0Kw472+J7bjFkmir28x3lE= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINNuXZkH7ppkTGNGKzmGEvAnvlLO2D+YtlJw1m3P16FV
5-
|1|nOHeibGxhsIFnhW0flRwnirJjlg=|IJ8nJB355LGI+1U3Wpvdcgdf0ek= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGG6DieKAdgiTCqRmF2HD0dJi9DuORblPzbridniICsw
5+
|1|nOHeibGxhsIFnhW0flRwnirJjlg=|IJ8nJB355LGI+1U3Wpvdcgdf0ek= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGG6DieKAdgiTCqRmF2HD0dJi9DuORblPzbridniICsw
6+
185.45.78.150 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDkOPL7fQiLFrg+/mDbff+jr+mQkI8pAkS5aBKOaknKuzTGrxILO5XSbyTJxyEwIKzZHBCUH2w99yv3oCqiphYp7iLLdPKl98RRnAXneJ1mo7nJfaTOSj5FGFf/AeHFZFa18B8zZrfFOOTGdEXeQpcik6R2A0/o4ZGE9rUg/dEoLQpFp8z+XRhsbNWgZ4a63oWrt02p+zdXPZ+Plir56j0qyQXoOo/BjEoLHs0aah61jfEOcJAcgpTrev/vdhBqJCgEXkf6AhiKidTnQxw7G/5C/BKtJbtuBWMgWZKcDf/uCzRkXaHNEggcJi1e6jvpUkvPLUfpRnNiBWLzehw3xZL4NicMM6D2TU0TSpB+UfEOLR0jyhCGKRQQN4jnj8ll0h+JBE6a0KnyKG+B5mXrD7THYu848jXUmBnxIaeor/NUItKEnCL0hzvAygOnniBN6uvtszSJHoGe8WbChLYJcoH3mOQTUH0k9RhXSEe90gSlLfRQInU+uzf2/qc6pffcKuc=
7+
185.45.78.150 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCB8R1BElOz4geGfCcb/ObF5n4Par+g9AaXQW5FU1ccgnPA59uJeOEALPeXAgJijVOhwqTdIkIoWYWeGdlud9Wc=
8+
185.45.78.150 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINNuXZkH7ppkTGNGKzmGEvAnvlLO2D+YtlJw1m3P16FV

environments/.stackhpc/inventory/group_vars/all/bastion.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ bastion_config:
66
LEAFCLOUD:
77
user: slurm-app-ci
88
ip: 195.114.30.222
9+
SMS:
10+
user: slurm-app-ci
11+
ip: 185.45.78.150
912
# NB: The bastion_{user,ip} variables are used directly in the CI workflow too
1013
bastion_user: "{{ bastion_config[ci_cloud].user }}"
1114
bastion_ip: "{{ bastion_config[ci_cloud].ip }}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cluster_net = "stackhpc-ipv4-geneve"
2+
cluster_subnet = "stackhpc-ipv4-geneve-subnet"
3+
control_node_flavor = "general.v1.small"
4+
other_node_flavor = "general.v1.small"

0 commit comments

Comments
 (0)