Skip to content

Commit b7388f5

Browse files
committed
WIP: allow latest build to include branch name
1 parent 1bd2bc4 commit b7388f5

File tree

2 files changed

+45
-82
lines changed

2 files changed

+45
-82
lines changed

.github/workflows/nightlybuild.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,31 @@ jobs:
2222
runs-on: ubuntu-22.04
2323
strategy:
2424
fail-fast: false # allow other matrix jobs to continue even if one fails
25-
matrix: # build RL8, RL9, RL9+CUDA versions
26-
os_version:
27-
- RL8
28-
- RL9
29-
build:
30-
- openstack.rocky-latest
31-
# - openstack.rocky-latest-cuda
25+
matrix:
26+
source_image_name:
27+
- Rocky-8-GenericCloud-Base-8.9-20231119.0.x86_64.qcow2
28+
- Rocky-9-GenericCloud-Base-9.4-20240523.0.x86_64.qcow2
29+
inventory_groups:
30+
- ["update", "ofed"]
31+
- ["update", "ofed", "cuda"]
3232
exclude:
33-
- os_version: RL8
34-
build: openstack.rocky-latest-cuda
35-
33+
- source_image_name: Rocky-8-GenericCloud-Base-8.9-20231119.0.x86_64.qcow2
34+
inventory_groups: ["update", "ofed", "cuda"]
3635
env:
3736
ANSIBLE_FORCE_COLOR: True
3837
OS_CLOUD: openstack
3938
CI_CLOUD: ${{ github.event.inputs.ci_cloud || vars.CI_CLOUD }}
40-
SOURCE_IMAGES_MAP: |
41-
{
42-
"RL8": "Rocky-8-GenericCloud-Base-8.9-20231119.0.x86_64.qcow2",
43-
"RL9": "Rocky-9-GenericCloud-Base-9.4-20240523.0.x86_64.qcow2"
44-
}
39+
# set the image suffix to -latest for cron jobs or a branch name if manually-triggered
40+
IMAGE_NAME_SUFFIX: ${{ github.event_name == 'schedule' && 'latest' || github.ref_name }}
41+
4542

4643
steps:
4744
- uses: actions/checkout@v2
4845

4946
- name: Record settings for CI cloud
5047
run: |
5148
echo CI_CLOUD: ${{ env.CI_CLOUD }}
49+
echo IMAGE_NAME_SUFFIX: ${{ env.IMAGE_NAME_SUFFIX }}
5250
5351
- name: Setup ssh
5452
run: |
@@ -85,16 +83,17 @@ jobs:
8583
cd packer/
8684
packer init .
8785
88-
PACKER_LOG=1 packer build \
86+
packer build \
8987
-on-error=${{ vars.PACKER_ON_ERROR }} \
90-
-only=${{ matrix.build }} \
9188
-var-file=$PKR_VAR_environment_root/${{ env.CI_CLOUD }}.pkrvars.hcl \
92-
-var "source_image_name=${{ env.SOURCE_IMAGE }}" \
89+
-var source_image_name=${{ matrix.source_image_name }} \
90+
-var image_name_prefix=rocky-${{ matrix.os_version }} \
91+
-var image_name_suffix=${{ env.IMAGE_NAME_SUFFIX }} \
92+
-var 'inventory_groups=${{ toJSON(matrix.inventory_groups }}' \
9393
openstack.pkr.hcl
94-
9594
env:
96-
PKR_VAR_os_version: ${{ matrix.os_version }}
97-
SOURCE_IMAGE: ${{ fromJSON(env.SOURCE_IMAGES_MAP)[matrix.os_version] }}
95+
PACKER_LOG: '1'
96+
9897

9998
- name: Get created image names from manifest
10099
id: manifest

packer/openstack.pkr.hcl

Lines changed: 25 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ data "git-commit" "cwd-head" { }
2323
locals {
2424
git_commit = data.git-commit.cwd-head.hash
2525
timestamp = formatdate("YYMMDD-hhmm", timestamp())
26+
image_name_suffix = var.image_name_suffix == "" ? "${local.timestamp}-${substr(local.git_commit, 0, 8)}" : var.image_name_suffix
2627
}
2728

2829
# Path pointing to root of repository - automatically set by environment variable PKR_VAR_repo_root
@@ -39,12 +40,6 @@ variable "networks" {
3940
type = list(string)
4041
}
4142

42-
variable "os_version" {
43-
type = string
44-
description = "'RL8' or 'RL9' with default source_image_* mappings"
45-
default = "RL9"
46-
}
47-
4843
# Must supply either source_image_name or source_image_id
4944
variable "source_image_name" {
5045
type = string
@@ -123,19 +118,13 @@ variable "volume_type" {
123118
}
124119

125120
variable "volume_size" {
126-
type = map(number)
127-
default = {
128-
# fat image builds, GB:
129-
rocky-latest = 15
130-
rocky-latest-cuda = 30
131-
openhpc = 15
132-
openhpc-cuda = 30
133-
}
121+
type = number
122+
default = 15 # same as default non-CUDA build
134123
}
135124

136-
variable "extra_build_volume_size" {
125+
variable "volume_size_cuda" {
137126
type = number
138-
default = 15 # same as default non-CUDA build
127+
default = 30
139128
}
140129

141130
variable "image_disk_format" {
@@ -148,32 +137,32 @@ variable "metadata" {
148137
default = {}
149138
}
150139

151-
variable "groups" {
152-
type = map(list(string))
153-
description = "Additional inventory groups (other than 'builder') to add build VM to, keyed by source name"
154-
default = {
155-
# fat image builds:
156-
rocky-latest = ["update", "ofed"]
157-
rocky-latest-cuda = ["update", "ofed", "cuda"]
158-
openhpc = ["control", "compute", "login"]
159-
openhpc-cuda = ["control", "compute", "login"]
160-
}
161-
}
162-
163-
variable "extra_build_groups" {
140+
variable "inventory_groups" {
164141
type = list(string)
165142
default = []
166143
}
167144

168-
variable "extra_build_image_name" {
145+
# variable "groups" {
146+
# type = map(list(string))
147+
# description = "Additional inventory groups (other than 'builder') to add build VM to, keyed by source name"
148+
# default = {
149+
# fat image builds:
150+
# rocky-latest = ["update", "ofed"]
151+
# rocky-latest-cuda = ["update", "ofed", "cuda"]
152+
# openhpc = ["control", "compute", "login"]
153+
# openhpc-cuda = ["control", "compute", "login"]
154+
# }
155+
# }
156+
157+
variable "image_name_prefix" {
169158
type = string
170-
description = "Infix for 'extra' build image name"
171-
default = "extra"
159+
description = "Prefix for built image names"
160+
default = "openhpc"
172161
}
173162

174163
variable "image_name_suffix" {
175164
type = string
176-
description = "Suffix for all build image names"
165+
description = "Suffix for built image names. If not supplied a timestamp+git commit is used"
177166
default = ""
178167
}
179168

@@ -182,7 +171,7 @@ source "openstack" "openhpc" {
182171
flavor = var.flavor
183172
use_blockstorage_volume = var.use_blockstorage_volume
184173
volume_type = var.volume_type
185-
volume_size = lookup(var.volume_size, source.name, var.extra_build_volume_size)
174+
volume_size = contains(var.inventory_groups, "cuda") ? var.volume_size_cuda : var.volume_size
186175
metadata = var.metadata
187176
instance_metadata = {ansible_init_disable = "true"}
188177
networks = var.networks
@@ -210,39 +199,14 @@ source "openstack" "openhpc" {
210199

211200
build {
212201

213-
# latest nightly image:
214202
source "source.openstack.openhpc" {
215203
name = "rocky-latest"
216-
image_name = "${source.name}-${var.os_version}${var.image_name_suffix}"
217-
}
218-
219-
# latest nightly cuda image:
220-
source "source.openstack.openhpc" {
221-
name = "rocky-latest-cuda"
222-
image_name = "${source.name}-${var.os_version}${var.image_name_suffix}"
223-
}
224-
225-
# OFED fat image:
226-
source "source.openstack.openhpc" {
227-
name = "openhpc"
228-
image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}${var.image_name_suffix}"
229-
}
230-
231-
# CUDA fat image:
232-
source "source.openstack.openhpc" {
233-
name = "openhpc-cuda"
234-
image_name = "${source.name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}${var.image_name_suffix}"
235-
}
236-
237-
# Extended site-specific image, built on fat image:
238-
source "source.openstack.openhpc" {
239-
name = "openhpc-extra"
240-
image_name = "openhpc-${var.extra_build_image_name}-${var.os_version}-${local.timestamp}-${substr(local.git_commit, 0, 8)}${var.image_name_suffix}"
204+
image_name = "${var.image_name_prefix}-${local.image_name_suffix}"
241205
}
242206

243207
provisioner "ansible" {
244208
playbook_file = "${var.repo_root}/ansible/fatimage.yml"
245-
groups = concat(["builder"], lookup(var.groups, source.name, var.extra_build_groups))
209+
groups = concat(["builder"], var.inventory_groups)
246210
keep_inventory_file = true # for debugging
247211
use_proxy = false # see https://www.packer.io/docs/provisioners/ansible#troubleshooting
248212
extra_arguments = [

0 commit comments

Comments
 (0)