mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-20 11:21:49 +00:00
test(e2e): dual-detect ubuntu image version (24.04/26.04) during gold-image transition
After mulga gold image bumped to v6-fastboot (stages ubuntu-26.04 / resolute
instead of ubuntu-24.04 / noble), all consumers that hardcoded 24.04 break on
the new image. Make them detect at runtime so v3 and v6 envs both pass.
- tests/e2e/run-e2e.sh: DescribeImages filter accepts both
ami-ubuntu-{26,24}.04-<arch>, then derives IMAGE_NAME from the match.
- tests/e2e/run-pseudo-multinode-e2e.sh: prefer ~/images/ubuntu-26.04.img,
fall back to ubuntu-24.04.img; pass detected version to spx import.
- tests/e2e/single/image_test.go: walk candidate catalog names (26.04 first,
then 24.04), stop on the first one DescribeImages can resolve.
- .github/workflows/e2e-baremetal.yml: download resolute (26.04) into
BM_ISO_CACHE; update BM_UBUNTU_IMAGE env var path.
- docs/terraform-workbooks/{bastion-private-subnet,s3-webapp,nginx-webserver}:
AMI filter matches `*ubuntu-26.04*` OR `*ubuntu-24.04*` (AWS values=
array is ORed).
Companion changes for mulga (bootstrap scripts, baremetal, iso pipeline)
land in scripts/tofu-cluster/* and scripts/{tofu-iso,baremetal,iso-builder}/*
under bead mulga-siv-114. Drop the 24.04 fallbacks once all envs are on the
v6 gold image and 24.04 entries are removed from spinifex/utils/images.go.
This commit is contained in:
@@ -81,14 +81,14 @@ jobs:
|
||||
|
||||
- name: Cache VM images
|
||||
run: |
|
||||
UBUNTU_IMG="${BM_ISO_CACHE}/ubuntu-24.04-cloudimg-amd64.img"
|
||||
UBUNTU_IMG="${BM_ISO_CACHE}/ubuntu-26.04-cloudimg-amd64.img"
|
||||
if [ ! -f "$UBUNTU_IMG" ]; then
|
||||
echo "Downloading Ubuntu 24.04 cloud image..."
|
||||
echo "Downloading Ubuntu 26.04 cloud image..."
|
||||
sudo curl -fsSL -o "$UBUNTU_IMG" \
|
||||
"https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
|
||||
"https://cloud-images.ubuntu.com/resolute/current/resolute-server-cloudimg-amd64.img"
|
||||
echo " Downloaded $(du -h "$UBUNTU_IMG" | cut -f1)"
|
||||
else
|
||||
echo "Ubuntu 24.04 cloud image cached ($(du -h "$UBUNTU_IMG" | cut -f1))"
|
||||
echo "Ubuntu 26.04 cloud image cached ($(du -h "$UBUNTU_IMG" | cut -f1))"
|
||||
fi
|
||||
|
||||
LB_IMG="${BM_ISO_CACHE}/lb-alpine-3.21.6-x86_64.raw"
|
||||
@@ -106,7 +106,7 @@ jobs:
|
||||
BM_CI_PASSWORD: ${{ secrets.BM_CI_PASSWORD }}
|
||||
BM_SSH_KEY: ${{ runner.temp }}/bm-ci
|
||||
BM_EPDU_ENV: ${{ runner.temp }}/epdu.env
|
||||
BM_UBUNTU_IMAGE: ${{ env.BM_ISO_CACHE }}/ubuntu-24.04-cloudimg-amd64.img
|
||||
BM_UBUNTU_IMAGE: ${{ env.BM_ISO_CACHE }}/ubuntu-26.04-cloudimg-amd64.img
|
||||
BM_LB_ALPINE_IMAGE: ${{ env.BM_ISO_CACHE }}/lb-alpine-3.21.6-x86_64.raw
|
||||
SPX_EXTERNAL_POOL: ${{ env.SPINIFEX_CI_POOL }}
|
||||
run: |
|
||||
|
||||
@@ -96,7 +96,7 @@ data "aws_ami" "ubuntu" {
|
||||
|
||||
filter {
|
||||
name = "name"
|
||||
values = ["*ubuntu-24.04*"]
|
||||
values = ["*ubuntu-26.04*", "*ubuntu-24.04*"]
|
||||
}
|
||||
|
||||
filter {
|
||||
|
||||
@@ -85,7 +85,7 @@ data "aws_ami" "ubuntu" {
|
||||
|
||||
filter {
|
||||
name = "name"
|
||||
values = ["*ubuntu-24.04*"]
|
||||
values = ["*ubuntu-26.04*", "*ubuntu-24.04*"]
|
||||
}
|
||||
|
||||
filter {
|
||||
|
||||
@@ -132,7 +132,7 @@ data "aws_ami" "ubuntu" {
|
||||
|
||||
filter {
|
||||
name = "name"
|
||||
values = ["*ubuntu-24.04*"]
|
||||
values = ["*ubuntu-26.04*", "*ubuntu-24.04*"]
|
||||
}
|
||||
|
||||
filter {
|
||||
|
||||
+13
-8
@@ -232,20 +232,25 @@ fi
|
||||
|
||||
# Phase 4: Image Management
|
||||
echo "Phase 4: Image Management"
|
||||
# Detect correct image name based on architecture
|
||||
# Discover whichever Ubuntu AMI bootstrap-install.sh staged. v6+ gold image
|
||||
# stages 26.04 (resolute); v3 staged 24.04 (noble). Catalog name follows
|
||||
# `ami-ubuntu-<ver>-<arch>`.
|
||||
if [ "$ARCH" = "x86_64" ]; then
|
||||
IMAGE_NAME="ubuntu-24.04-x86_64"
|
||||
ARCH_LABEL="x86_64"
|
||||
else
|
||||
IMAGE_NAME="ubuntu-24.04-arm64"
|
||||
ARCH_LABEL="arm64"
|
||||
fi
|
||||
echo "Looking up Ubuntu AMI for arch=${ARCH_LABEL}..."
|
||||
AMI_ID=$(aws ec2 describe-images \
|
||||
--filters "Name=name,Values=ami-ubuntu-26.04-${ARCH_LABEL},ami-ubuntu-24.04-${ARCH_LABEL}" \
|
||||
--query 'Images[0].ImageId' --output text)
|
||||
IMAGE_NAME=$(aws ec2 describe-images \
|
||||
--filters "Name=name,Values=ami-ubuntu-26.04-${ARCH_LABEL},ami-ubuntu-24.04-${ARCH_LABEL}" \
|
||||
--query 'Images[0].Name' --output text | sed 's/^ami-//')
|
||||
echo "Using image: $IMAGE_NAME"
|
||||
|
||||
# AMI already imported by bootstrap-install.sh — discover the existing AMI
|
||||
echo "Discovering existing AMI (imported by bootstrap)..."
|
||||
AMI_ID=$(aws ec2 describe-images --filters "Name=name,Values=ami-${IMAGE_NAME}" --query 'Images[0].ImageId' --output text)
|
||||
|
||||
if [ -z "$AMI_ID" ] || [ "$AMI_ID" = "None" ]; then
|
||||
echo "Failed to capture AMI ID"
|
||||
echo "Failed to capture AMI ID — bootstrap-install.sh did not stage ubuntu-{24,26}.04-${ARCH_LABEL}"
|
||||
exit 1
|
||||
fi
|
||||
echo "Captured AMI ID: $AMI_ID"
|
||||
|
||||
@@ -274,14 +274,27 @@ $AWS_EC2 authorize-security-group-ingress \
|
||||
--group-id "$MULTINODE_SG" --protocol icmp --port -1 --cidr 0.0.0.0/0 > /dev/null
|
||||
echo " SG created: $MULTINODE_SG (tcp/22 + icmp from 0.0.0.0/0)"
|
||||
|
||||
# Import Ubuntu image (use node1's config and spinifex-dir)
|
||||
# Import Ubuntu image (use node1's config and spinifex-dir). v6+ gold image
|
||||
# stages ubuntu-26.04 (resolute); v3 staged ubuntu-24.04 (noble). Detect
|
||||
# which is present so we can keep running both during the v3→v6 transition.
|
||||
echo ""
|
||||
echo "Importing Ubuntu image..."
|
||||
if [ -f "$HOME/images/ubuntu-26.04.img" ]; then
|
||||
UBUNTU_IMG="$HOME/images/ubuntu-26.04.img"
|
||||
UBUNTU_VER="26.04"
|
||||
elif [ -f "$HOME/images/ubuntu-24.04.img" ]; then
|
||||
UBUNTU_IMG="$HOME/images/ubuntu-24.04.img"
|
||||
UBUNTU_VER="24.04"
|
||||
else
|
||||
echo "ERROR: no ubuntu cloud image at ~/images/ubuntu-{24,26}.04.img" >&2
|
||||
exit 1
|
||||
fi
|
||||
echo " Using: $UBUNTU_IMG (version $UBUNTU_VER)"
|
||||
IMPORT_LOG=$(./bin/spx admin images import \
|
||||
--file ~/images/ubuntu-24.04.img \
|
||||
--file "$UBUNTU_IMG" \
|
||||
--arch "$ARCH" \
|
||||
--distro ubuntu \
|
||||
--version 24.04 \
|
||||
--version "$UBUNTU_VER" \
|
||||
--config "$HOME/node1/config/spinifex.toml" \
|
||||
--spinifex-dir "$HOME/node1/" \
|
||||
--force 2>/dev/null)
|
||||
|
||||
@@ -26,19 +26,36 @@ func phase4_Image(t *testing.T, fix *Fixture) {
|
||||
harness.Phase(t, "Phase 4 — Image Management")
|
||||
require.NotEmpty(t, fix.Arch, "Phase 2 must populate fix.Arch before Phase 4")
|
||||
|
||||
// Bash hard-coded the mapping to ubuntu-24.04-{x86_64,arm64}; keep
|
||||
// parity. fix.Arch comes from DescribeInstanceTypes so it'll be the
|
||||
// canonical AWS arch label.
|
||||
imgName := "ubuntu-24.04-" + fix.Arch
|
||||
harness.Detail(t, "image", imgName, "arch", fix.Arch)
|
||||
|
||||
harness.Step(t, "spx admin images import --name %s", imgName)
|
||||
// wantErr=true: bootstrap-install.sh has already imported this AMI in
|
||||
// most environments, so the import returns non-zero on duplicate. We
|
||||
// don't care about the exit code — we care about either parsing an
|
||||
// AMI ID out of the output or successfully filtering DescribeImages
|
||||
// by the canonical ami-<name> tag afterwards.
|
||||
out := harness.SpxRun(t, true, "admin", "images", "import", "--name", imgName)
|
||||
// Try the current catalog entry (26.04 / resolute) first, fall back to
|
||||
// 24.04 (noble) for clusters still on the v3 gold image. Drop the
|
||||
// fallback once 24.04 is gone from spinifex/utils/images.go.
|
||||
candidates := []string{
|
||||
"ubuntu-26.04-" + fix.Arch,
|
||||
"ubuntu-24.04-" + fix.Arch,
|
||||
}
|
||||
var imgName, out string
|
||||
for _, name := range candidates {
|
||||
harness.Detail(t, "image_candidate", name, "arch", fix.Arch)
|
||||
harness.Step(t, "spx admin images import --name %s", name)
|
||||
// wantErr=true: bootstrap-install.sh has already imported the
|
||||
// AMI in most environments, so the import returns non-zero on
|
||||
// duplicate. We don't care about the exit code — we care about
|
||||
// either parsing an AMI ID or successfully filtering
|
||||
// DescribeImages by the canonical ami-<name> tag afterwards.
|
||||
out = harness.SpxRun(t, true, "admin", "images", "import", "--name", name)
|
||||
imgName = name
|
||||
// If DescribeImages can find this name, stop trying further
|
||||
// candidates — bootstrap staged this version.
|
||||
probe, err := fix.AWS.EC2.DescribeImages(&ec2.DescribeImagesInput{
|
||||
Filters: []*ec2.Filter{
|
||||
{Name: aws.String("name"), Values: []*string{aws.String("ami-" + name)}},
|
||||
},
|
||||
})
|
||||
if err == nil && len(probe.Images) > 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
harness.Detail(t, "image", imgName)
|
||||
|
||||
// Try to parse the AMI ID directly out of the CLI's success line.
|
||||
amiID := amiIDRE.FindString(out)
|
||||
|
||||
Reference in New Issue
Block a user