Skip to content

Commit

Permalink
Merge branch 'stackhpc/2023.1' into logs_in_grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
technowhizz authored Apr 18, 2024
2 parents cd2c2f4 + f00221e commit b0979ab
Show file tree
Hide file tree
Showing 65 changed files with 1,064 additions and 284 deletions.
278 changes: 187 additions & 91 deletions .github/workflows/overcloud-host-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,39 @@ on:

env:
ANSIBLE_FORCE_COLOR: True
KAYOBE_ENVIRONMENT: ci-builder
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
jobs:
overcloud-host-image-build:
name: Build overcloud host images
if: github.repository == 'stackhpc/stackhpc-kayobe-config'
runs-on: [self-hosted, stackhpc-kayobe-config-kolla-builder-rl9]
runs-on: arc-skc-host-image-builder-runner
permissions: {}
steps:
- uses: actions/checkout@v4
- name: Install Package
uses: ConorMacBride/install-package@main
with:
apt: git unzip nodejs python3-pip python3-venv openssh-server openssh-client jq

- name: Start the SSH service
run: |
sudo /etc/init.d/ssh start
- name: Checkout
uses: actions/checkout@v4
with:
path: src/kayobe-config

- name: Output image tag of the builder
id: builder_image_tag
run: |
echo image_tag=$(grep stackhpc_rocky_9_overcloud_host_image_version: etc/kayobe/pulp-host-image-versions.yml | awk '{print $2}') >> $GITHUB_OUTPUT
- name: Determine OpenStack release
id: openstack_release
run: |
BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' src/kayobe-config/.gitreview)
echo "openstack_release=${BRANCH}" | sed "s|stable/||" >> $GITHUB_OUTPUT
echo "openstack_release=${BRANCH}" | sed -E "s,(stable|unmaintained)/,," >> $GITHUB_OUTPUT
# Generate a tag to apply to all built overcloud host images.
- name: Generate overcloud host image tag
Expand All @@ -50,36 +67,13 @@ jobs:
run: |
echo "${{ steps.host_image_tag.outputs.host_image_tag }}"
- name: Clean any previous build artifact
run: |
rm -f /tmp/updated_images.txt
- name: Clone StackHPC Kayobe repository
uses: actions/checkout@v4
with:
repository: stackhpc/kayobe
ref: refs/heads/stackhpc/${{ steps.openstack_release.outputs.openstack_release }}
path: src/kayobe

- name: Install dependencies
run: |
sudo dnf -y install zstd debootstrap
- name: Setup networking
run: |
if ! ip l show breth1 >/dev/null 2>&1; then
sudo ip l add breth1 type bridge
fi
sudo ip l set breth1 up
if ! ip a show breth1 | grep 192.168.33.3/24; then
sudo ip a add 192.168.33.3/24 dev breth1
fi
if ! ip l show dummy1 >/dev/null 2>&1; then
sudo ip l add dummy1 type dummy
fi
sudo ip l set dummy1 up
sudo ip l set dummy1 master breth1
- name: Install Kayobe
run: |
mkdir -p venvs &&
Expand All @@ -89,36 +83,132 @@ jobs:
pip install -U pip &&
pip install ../src/kayobe
- name: Install terraform
uses: hashicorp/setup-terraform@v2

- name: Initialise terraform
run: terraform init
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio

- name: Generate SSH keypair
run: ssh-keygen -f id_rsa -N ''
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio

- name: Generate clouds.yaml
run: |
cat << EOF > clouds.yaml
${{ secrets.CLOUDS_YAML }}
EOF
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio

- name: Generate terraform.tfvars
run: |
cat << EOF > terraform.tfvars
ssh_public_key = "id_rsa.pub"
ssh_username = "rocky"
aio_vm_name = "skc-host-image-builder"
# Must be a Rocky Linux 9 host to successfully build all images
# This MUST NOT be an LVM image. It can cause confusing conficts with the built image.
aio_vm_image = "Rocky-9-GenericCloud-Base-9.3-20231113.0.x86_64.qcow2"
aio_vm_flavor = "en1.medium"
aio_vm_network = "stackhpc-ci"
aio_vm_subnet = "stackhpc-ci"
aio_vm_interface = "eth0"
EOF
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio

- name: Terraform Plan
run: terraform plan
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
env:
OS_CLOUD: "openstack"
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}

- name: Terraform Apply
run: |
for attempt in $(seq 5); do
if terraform apply -auto-approve; then
echo "Created infrastructure on attempt $attempt"
exit 0
fi
echo "Failed to create infrastructure on attempt $attempt"
sleep 10
terraform destroy -auto-approve
sleep 60
done
echo "Failed to create infrastructure after $attempt attempts"
exit 1
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
env:
OS_CLOUD: "openstack"
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}

- name: Get Terraform outputs
id: tf_outputs
run: |
terraform output -json
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio

- name: Write Terraform outputs
run: |
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml
${{ steps.tf_outputs.outputs.stdout }}
EOF
- name: Write Terraform network config
run: |
cat << EOF > src/kayobe-config/etc/kayobe/environments/ci-builder/tf-network-allocation.yml
---
aio_ips:
builder: "{{ access_ip_v4.value }}"
EOF
- name: Write Terraform network interface config
run: |
mkdir -p src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed
rm -f src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
cat << EOF > src/kayobe-config/etc/kayobe/environments/$KAYOBE_ENVIRONMENT/inventory/group_vars/seed/network-interfaces
admin_interface: "{{ access_interface.value }}"
aio_interface: "{{ access_interface.value }}"
EOF
- name: Manage SSH keys
run: |
mkdir -p ~/.ssh
touch ~/.ssh/authorized_keys
cat src/kayobe-config/terraform/aio/id_rsa.pub >> ~/.ssh/authorized_keys
cp src/kayobe-config/terraform/aio/id_rsa* ~/.ssh/
- name: Bootstrap the control host
run: |
source venvs/kayobe/bin/activate &&
source src/kayobe-config/kayobe-env --environment ci-builder &&
kayobe control host bootstrap
- name: Configure the seed host
- name: Configure the seed host (Builder VM)
run: |
source venvs/kayobe/bin/activate &&
source src/kayobe-config/kayobe-env --environment ci-builder &&
kayobe seed host configure -e seed_bootstrap_user=rocky --skip-tags network
- name: Install dependencies
run: |
source venvs/kayobe/bin/activate &&
source src/kayobe-config/kayobe-env --environment ci-builder &&
kayobe seed host configure
kayobe seed host command run \
--command "sudo dnf config-manager --set-enabled crb && sudo dnf -y install epel-release && sudo dnf -y install zstd debootstrap kpartx cloud-init" --show-output
env:
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}

- name: Create bifrost_httpboot Docker volume
run: |
if [[ $(sudo docker volume ls -f Name=bifrost_httpboot -q | wc -l) = 0 ]]; then
sudo docker volume create bifrost_httpboot
fi
- name: Generate clouds.yaml
run: |
cat << EOF > clouds.yaml
${{ secrets.CLOUDS_YAML }}
EOF
- name: Install OpenStack client
run: |
source venvs/kayobe/bin/activate &&
pip install python-openstackclient -c https://releases.openstack.org/constraints/upper/${{ steps.openstack_release.outputs.openstack_release }}
source src/kayobe-config/kayobe-env --environment ci-builder &&
kayobe seed host command run --command "sudo mkdir -p /var/lib/docker/volumes/bifrost_httpboot/_data" --show-output
env:
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}

- name: Build a Rocky Linux 9 overcloud host image
id: build_rocky_9
Expand All @@ -134,6 +224,16 @@ jobs:
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
if: inputs.rocky9

- name: Show last error logs
continue-on-error: true
run: |
source venvs/kayobe/bin/activate &&
source src/kayobe-config/kayobe-env --environment ci-builder &&
kayobe seed host command run --command "tail -200 /opt/kayobe/images/overcloud-rocky-9/overcloud-rocky-9.stdout" --show-output
env:
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
if: steps.build_rocky_9.outcome == 'failure'

- name: Upload Rocky Linux 9 overcloud host image to Ark
run: |
source venvs/kayobe/bin/activate &&
Expand All @@ -147,19 +247,17 @@ jobs:
env:
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
if: inputs.rocky9 && steps.build_rocky_9.outcome == 'success'
- name: Upload Rocky Linux 9 overcloud host image to SMS

- name: Upload Rocky Linux 9 overcloud host image to Dev Cloud
run: |
source venvs/kayobe/bin/activate &&
openstack image create \
overcloud-rocky-9-${{ steps.host_image_tag.outputs.host_image_tag }} \
--container-format bare \
--disk-format qcow2 \
--file /opt/kayobe/images/overcloud-rocky-9/overcloud-rocky-9.qcow2 \
--private \
--os-cloud sms-lab-release \
--progress
source src/kayobe-config/kayobe-env --environment ci-builder &&
kayobe playbook run \
src/kayobe-config/etc/kayobe/ansible/openstack-host-image-upload.yml \
-e local_image_path="/opt/kayobe/images/overcloud-rocky-9/overcloud-rocky-9.qcow2" \
-e image_name=overcloud-rocky-9-${{ steps.host_image_tag.outputs.host_image_tag }}
env:
CLOUDS_YAML: ${{ secrets.CLOUDS_YAML }}
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
if: inputs.rocky9 && steps.build_rocky_9.outcome == 'success'
Expand All @@ -178,6 +276,16 @@ jobs:
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
if: inputs.ubuntu-jammy

- name: Show last error logs
continue-on-error: true
run: |
source venvs/kayobe/bin/activate &&
source src/kayobe-config/kayobe-env --environment ci-builder &&
kayobe seed host command run --command "tail -200 /opt/kayobe/images/overcloud-ubuntu-jammy/overcloud-ubuntu-jammy.stdout" --show-output
env:
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
if: steps.build_ubuntu_jammy.outcome == 'failure'

- name: Upload Ubuntu Jammy 22.04 overcloud host image to Ark
run: |
source venvs/kayobe/bin/activate &&
Expand All @@ -192,50 +300,27 @@ jobs:
KAYOBE_VAULT_PASSWORD: ${{ secrets.KAYOBE_VAULT_PASSWORD }}
if: inputs.ubuntu-jammy && steps.build_ubuntu_jammy.outcome == 'success'

- name: Upload Ubuntu Jammy 22.04 overcloud host image to SMS
- name: Upload Ubuntu Jammy overcloud host image to Dev Cloud
run: |
source venvs/kayobe/bin/activate &&
openstack image create \
overcloud-ubuntu-jammy-${{ steps.host_image_tag.outputs.host_image_tag }} \
--container-format bare \
--disk-format qcow2 \
--file /opt/kayobe/images/overcloud-ubuntu-jammy/overcloud-ubuntu-jammy.qcow2 \
--private \
--os-cloud sms-lab-release \
--progress
source src/kayobe-config/kayobe-env --environment ci-builder &&
kayobe playbook run \
src/kayobe-config/etc/kayobe/ansible/openstack-host-image-upload.yml \
-e local_image_path="/opt/kayobe/images/overcloud-ubuntu-jammy/overcloud-ubuntu-jammy.qcow2" \
-e image_name=overcloud-ubuntu-jammy-${{ steps.host_image_tag.outputs.host_image_tag }}
env:
CLOUDS_YAML: ${{ secrets.CLOUDS_YAML }}
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
if: inputs.ubuntu-jammy && steps.build_ubuntu_jammy.outcome == 'success'

- name: Upload updated images artifact
uses: actions/upload-artifact@v4
with:
name: Updated images list
path: /tmp/updated_images.txt
retention-days: 7
if: steps.build_rocky_9.outcome == 'success' ||
steps.build_ubuntu_jammy.outcome == 'success'

- name: Upload Rocky 9 build logs if build failed
uses: actions/upload-artifact@v4
with:
name: Rocky 9 build logs
path: |
/opt/kayobe/images/overcloud-rocky-9/overcloud-rocky-9.stdout
/opt/kayobe/images/overcloud-rocky-9/overcloud-rocky-9.stderr
retention-days: 7
if: steps.build_rocky_9.outcome == 'failure'

- name: Upload Ubuntu Jammy 22.04 build logs if build failed
uses: actions/upload-artifact@v4
with:
name: Ubuntu Jammy 22.04 build logs
path: |
/opt/kayobe/images/overcloud-ubuntu-jammy/overcloud-ubuntu-jammy.stdout
/opt/kayobe/images/overcloud-ubuntu-jammy/overcloud-ubuntu-jammy.stderr
retention-days: 7
if: steps.build_ubuntu_jammy.outcome == 'failure'
- name: Copy logs back
continue-on-error: true
run: |
mkdir logs
scp -r rocky@$(jq -r .access_ip_v4.value src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml):/opt/kayobe/images/*/*.std* ./logs/
scp -r rocky@$(jq -r .access_ip_v4.value src/kayobe-config/etc/kayobe/environments/ci-builder/tf-outputs.yml):/tmp/updated_images.txt ./logs/ || true
if: always()

- name: Fail if any overcloud host image builds failed
run: |
Expand All @@ -244,7 +329,18 @@ jobs:
if: steps.build_rocky_9.outcome == 'failure' ||
steps.build_ubuntu_jammy.outcome == 'failure'

- name: Clean up build artifacts
run: |
sudo rm -rf /opt/kayobe/images/
- name: Upload logs artifact
uses: actions/upload-artifact@v4
with:
name: Build logs
path: ./logs
if: always()

- name: Destroy
run: terraform destroy -auto-approve
working-directory: ${{ github.workspace }}/src/kayobe-config/terraform/aio
env:
OS_CLOUD: openstack
OS_APPLICATION_CREDENTIAL_ID: ${{ secrets.OS_APPLICATION_CREDENTIAL_ID }}
OS_APPLICATION_CREDENTIAL_SECRET: ${{ secrets.OS_APPLICATION_CREDENTIAL_SECRET }}
if: always()
2 changes: 1 addition & 1 deletion .github/workflows/overcloud-host-image-promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
id: openstack_release
run: |
BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' .gitreview)
echo "openstack_release=${BRANCH}" | sed "s|stable/||" >> $GITHUB_OUTPUT
echo "openstack_release=${BRANCH}" | sed -E "s,(stable|unmaintained)/,," >> $GITHUB_OUTPUT
working-directory: src/kayobe-config

- name: Clone StackHPC Kayobe repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/overcloud-host-image-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
id: openstack_release
run: |
BRANCH=$(awk -F'=' '/defaultbranch/ {print $2}' src/kayobe-config/.gitreview)
echo "openstack_release=${BRANCH}" | sed "s|stable/||" >> $GITHUB_OUTPUT
echo "openstack_release=${BRANCH}" | sed -E "s,(stable|unmaintained)/,," >> $GITHUB_OUTPUT
- name: Clone StackHPC Kayobe repository
uses: actions/checkout@v4
Expand Down
Loading

0 comments on commit b0979ab

Please sign in to comment.