Skip to content

Commit 9dd79c9

Browse files
author
shiftstack-merge-bot
committed
2 parents 23512b6 + 8297241 commit 9dd79c9

File tree

10 files changed

+252
-13
lines changed

10 files changed

+252
-13
lines changed

.github/workflows/release.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: release
2+
3+
on:
4+
push:
5+
# Sequence of patterns matched against refs/tags
6+
tags:
7+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
8+
9+
permissions:
10+
contents: write # Allow to create a release.
11+
12+
jobs:
13+
build:
14+
name: create draft release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Set env
18+
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
19+
- name: checkout code
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
21+
with:
22+
fetch-depth: 0
23+
- name: Calculate go version
24+
run: echo "go_version=$(make go-version)" >> $GITHUB_ENV
25+
- name: Set up Go
26+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # tag=v5.1.0
27+
with:
28+
go-version: ${{ env.go_version }}
29+
- name: generate release artifacts
30+
run: |
31+
make release
32+
- name: generate release notes
33+
# Ignore failures for release-notes generation so they could still get
34+
# generated manually before publishing.
35+
run: |
36+
make generate-release-notes || echo "Failed to generate release notes" >> _releasenotes/${{ env.RELEASE_TAG }}.md
37+
env:
38+
GH_TOKEN: ${{ github.token }}
39+
- name: Release
40+
uses: softprops/action-gh-release@01570a1f39cb168c169c802c3bceb9e93fb10974 # tag=v2.1.0
41+
with:
42+
draft: true
43+
files: out/*
44+
body_path: _releasenotes/${{ env.RELEASE_TAG }}.md

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ cscope.*
7474
*.test
7575
/hack/.test-cmd-auth
7676

77+
# Generated release notes
78+
_releasenotes
79+
7780
# JUnit test output from ginkgo e2e tests
7881
/junit*.xml
7982

Makefile

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export GOTOOLCHAIN=go1.22.8
2525
export GO111MODULE=on
2626
unexport GOPATH
2727

28+
# Go
29+
GO_VERSION ?= 1.22.7
30+
2831
# Directories.
2932
ARTIFACTS ?= $(REPO_ROOT)/_artifacts
3033
TOOLS_DIR := hack/tools
@@ -359,8 +362,25 @@ staging-manifests:
359362
##@ Release
360363
## --------------------------------------
361364

365+
ifneq (,$(findstring -,$(RELEASE_TAG)))
366+
PRE_RELEASE=true
367+
endif
368+
PREVIOUS_TAG ?= $(shell git tag -l | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$$" | sort -V | grep -B1 $(RELEASE_TAG) | head -n 1 2>/dev/null)
369+
## set by Prow, ref name of the base branch, e.g., main
370+
RELEASE_DIR := out
371+
RELEASE_NOTES_DIR := _releasenotes
372+
373+
.PHONY: $(RELEASE_DIR)
362374
$(RELEASE_DIR):
363-
mkdir -p $@
375+
mkdir -p $(RELEASE_DIR)/
376+
377+
.PHONY: $(RELEASE_NOTES_DIR)
378+
$(RELEASE_NOTES_DIR):
379+
mkdir -p $(RELEASE_NOTES_DIR)/
380+
381+
.PHONY: $(BUILD_DIR)
382+
$(BUILD_DIR):
383+
@mkdir -p $(BUILD_DIR)
364384

365385
.PHONY: list-staging-releases
366386
list-staging-releases: ## List staging images for image promotion
@@ -435,9 +455,14 @@ upload-gh-artifacts: $(GH) ## Upload artifacts to Github release
435455
release-alias-tag: # Adds the tag to the last build tag.
436456
gcloud container images add-tag -q $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG)
437457

438-
.PHONY: release-notes
439-
release-notes: $(RELEASE_NOTES) ## Generate release notes
440-
$(RELEASE_NOTES) $(RELEASE_NOTES_ARGS)
458+
.PHONY: generate-release-notes ## Generate release notes
459+
generate-release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES)
460+
# Reset the file
461+
echo -n > $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
462+
if [ -n "${PRE_RELEASE}" ]; then \
463+
echo -e ":rotating_light: This is a RELEASE CANDIDATE. Use it only for testing purposes. If you find any bugs, file an [issue](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/issues/new/choose).\n" >> $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md; \
464+
fi
465+
"$(RELEASE_NOTES)" --from=$(PREVIOUS_TAG) >> $(RELEASE_NOTES_DIR)/$(RELEASE_TAG).md
441466

442467
.PHONY: templates
443468
templates: ## Generate cluster templates
@@ -557,3 +582,12 @@ compile-e2e: ## Test e2e compilation
557582

558583
.PHONY: FORCE
559584
FORCE:
585+
586+
## --------------------------------------
587+
## Helpers
588+
## --------------------------------------
589+
590+
##@ helpers:
591+
592+
go-version: ## Print the go version we use to compile our binaries and images
593+
@echo $(GO_VERSION)

RELEASE.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ The content of the release notes differs depending on the type of release, speci
7070
for review and the promotion of the image.
7171
1. Run `make release` to build artifacts to be attached to the GitHub release.
7272
1. Generate and finalize the release notes and save them for the next step.
73-
- Run `make release-notes RELEASE_NOTES_ARGS="--from <tag>"`.
74-
- Depending on the type of release, substitute `<tag>` with the following:
75-
- Stable releases: tag of the last stable release
76-
- Pre-releases*: tag of the latest pre-release (or last stable release if there isn't one)
73+
- Run `make release-notes`.
7774
- Pay close attention to the `## :question: Sort these by hand` section, as it contains items that need to be manually sorted.
7875
1. Create a draft release in GitHub based on the tag created above
7976
- Name the release `Release [VERSION]` where VERSION is the full version string.

controllers/openstackcluster_controller.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ func (r *OpenStackClusterReconciler) reconcileDelete(ctx context.Context, scope
152152
// A bastion may have been created if cluster initialisation previously reached populating the network status
153153
// We attempt to delete it even if no status was written, just in case
154154
if openStackCluster.Status.Network != nil {
155-
// Attempt to resolve bastion resources before delete. We don't need to worry about starting if the resources have changed on update.
155+
// Attempt to resolve bastion resources before delete.
156+
// Even if we fail, we need to continue with the deletion or risk getting stuck.
157+
// For example, if the image doesn't exist, we do not have a bastion.
156158
if _, err := resolveBastionResources(scope, clusterResourceName, openStackCluster); err != nil {
157-
return reconcile.Result{}, err
159+
scope.Logger().Info("Failed to resolve bastion, continuing.", "error", err)
158160
}
159161

160162
if err := deleteBastion(scope, cluster, openStackCluster); err != nil {

hack/ci/cloud-init/controller.yaml.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@
8989
# query_placement_for_availability_zone is the default from Xena
9090
query_placement_for_availability_zone = True
9191

92+
[workarounds]
93+
# FIXME(stephenfin): This is temporary while we get to the bottom of
94+
# https://bugs.launchpad.net/nova/+bug/2091114 It should not be kept after
95+
# we bump to 2025.1
96+
disable_deep_image_inspection = True
97+
9298
[[post-config|$CINDER_CONF]]
9399
[DEFAULT]
94100
storage_availability_zone = ${PRIMARY_AZ}

hack/ci/cloud-init/worker.yaml.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
[DEFAULT]
4848
cpu_allocation_ratio = 2.0
4949

50+
[workarounds]
51+
# FIXME(stephenfin): This is temporary while we get to the bottom of
52+
# https://bugs.launchpad.net/nova/+bug/2091114 It should not be kept after
53+
# we bump to 2025.1
54+
disable_deep_image_inspection = True
55+
5056
[[post-config|$CINDER_CONF]]
5157
[DEFAULT]
5258
storage_availability_zone = ${SECONDARY_AZ}

hack/ci/create_devstack.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ source "${scriptdir}/${RESOURCE_TYPE}.sh"
3131

3232
CLUSTER_NAME=${CLUSTER_NAME:-"capo-e2e"}
3333

34-
OPENSTACK_RELEASE=${OPENSTACK_RELEASE:-"2023.2"}
34+
OPENSTACK_RELEASE=${OPENSTACK_RELEASE:-"2024.2"}
3535
OPENSTACK_ENABLE_HORIZON=${OPENSTACK_ENABLE_HORIZON:-"false"}
3636

3737
# Devstack will create a provider network using this range
@@ -47,6 +47,9 @@ PRIVATE_NETWORK_CIDR=${PRIVATE_NETWORK_CIDR:-"10.0.3.0/24"}
4747
CONTROLLER_IP=${CONTROLLER_IP:-"10.0.3.15"}
4848
WORKER_IP=${WORKER_IP:-"10.0.3.16"}
4949

50+
SKIP_INIT_INFRA=${SKIP_INIT_INFRA:-}
51+
SKIP_SECONDARY_AZ=${SKIP_SECONDARY_AZ:-}
52+
5053
PRIMARY_AZ=testaz1
5154
SECONDARY_AZ=testaz2
5255

@@ -273,7 +276,11 @@ function main() {
273276
# is available, and wait if it is not.
274277
#
275278
# For efficiency, tests which require multi-AZ SHOULD run as late as possible.
276-
create_worker
279+
if [[ -n "${SKIP_SECONDARY_AZ:-}" ]]; then
280+
echo "Skipping worker creation..."
281+
else
282+
create_worker
283+
fi
277284

278285
public_ip=$(get_public_ip)
279286
cat << EOF > "${REPO_ROOT_ABSOLUTE}/clouds.yaml"

hack/ci/gce-project.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function create_vm {
9595
--zone "$GCP_ZONE" \
9696
--enable-nested-virtualization \
9797
--image-project ubuntu-os-cloud \
98-
--image-family ubuntu-2204-lts \
98+
--image-family ubuntu-2404-lts-amd64 \
9999
--boot-disk-size 200G \
100100
--boot-disk-type pd-ssd \
101101
--can-ip-forward \

hack/ci/libvirt.sh

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2024 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# hack script for preparing libvirt to run cluster-api-provider-openstack e2e
18+
19+
set -x -o errexit -o nounset -o pipefail
20+
21+
# Required environment variables:
22+
# SSH_PUBLIC_KEY_FILE
23+
# SSH_PRIVATE_KEY_FILE
24+
# LIBVIRT_NETWORK_NAME
25+
26+
function cloud_init {
27+
LIBVIRT_NETWORK_NAME=${LIBVIRT_NETWORK_NAME:-${CLUSTER_NAME}-network}
28+
LIBVIRT_IMAGE_NAME=${LIBVIRT_IMAGE_NAME:-ubuntu-2404-lts}
29+
30+
LIBVIRT_MEMORY=${LIBVIRT_MEMORY:-8192}
31+
LIBVIRT_MEMORY_controller=${LIBVIRT_MEMORY_controller:-$LIBVIRT_MEMORY}
32+
LIBVIRT_MEMORY_worker=${LIBVIRT_MEMORY_worker:-$LIBVIRT_MEMORY}
33+
34+
LIBVIRT_VCPU=${LIBVIRT_VCPU:-4}
35+
LIBVIRT_VCPU_controller=${LIBVIRT_VCPU_controller:-$LIBVIRT_VCPU}
36+
LIBVIRT_VCPU_worker=${LIBVIRT_VCPU_worker:-$LIBVIRT_VCPU}
37+
38+
LIBVIRT_MAC_controller="00:60:2f:32:81:00"
39+
LIBVIRT_MAC_worker="00:60:2f:32:81:01"
40+
}
41+
42+
function init_infrastructure() {
43+
if ! virsh net-info "${LIBVIRT_NETWORK_NAME}" &>/dev/null; then
44+
virsh net-define <(cat <<EOF
45+
<network>
46+
<name>${LIBVIRT_NETWORK_NAME}</name>
47+
<forward mode='nat'>
48+
<nat>
49+
<port start='1024' end='65535'/>
50+
</nat>
51+
</forward>
52+
<bridge name="capobr0" stp="on" delay="0"/>
53+
<ip address="${PRIVATE_NETWORK_CIDR%/*}" netmask="255.255.255.0">
54+
<dhcp>
55+
<range start="${PRIVATE_NETWORK_CIDR%.*}.10" end="${PRIVATE_NETWORK_CIDR%.*}.199"/>
56+
<host mac="${LIBVIRT_MAC_controller}" name='controller' ip="${CONTROLLER_IP}"/>
57+
<host mac="${LIBVIRT_MAC_worker}" name='worker' ip="${WORKER_IP}"/>
58+
</dhcp>
59+
</ip>
60+
</network>
61+
EOF
62+
)
63+
virsh net-start "${LIBVIRT_NETWORK_NAME}"
64+
virsh net-autostart "${LIBVIRT_NETWORK_NAME}"
65+
fi
66+
67+
if [ ! -f "/tmp/${LIBVIRT_IMAGE_NAME}.qcow2" ]; then
68+
curl -o "/tmp/${LIBVIRT_IMAGE_NAME}.qcow2" https://cloud-images.ubuntu.com/releases/noble/release/ubuntu-24.04-server-cloudimg-amd64.img
69+
fi
70+
}
71+
72+
function create_vm {
73+
local name=$1 && shift
74+
local ip=$1 && shift
75+
local userdata=$1 && shift
76+
local public=$1 && shift
77+
78+
local memory=LIBVIRT_MEMORY_${name}
79+
memory=${!memory}
80+
local vcpu=LIBVIRT_VCPU_${name}
81+
vcpu=${!vcpu}
82+
local servername="${CLUSTER_NAME}-${name}"
83+
local mac=LIBVIRT_MAC_${name}
84+
mac=${!mac}
85+
86+
# Values which weren't initialised if we skipped init_infrastructure. Use names instead.
87+
networkid=${networkid:-${LIBVIRT_NETWORK_NAME}}
88+
volumeid=${volumeid:-${LIBVIRT_IMAGE_NAME}_${name}.qcow2}
89+
90+
sudo cp "/tmp/${LIBVIRT_IMAGE_NAME}.qcow2" "/var/lib/libvirt/images/${volumeid}"
91+
sudo qemu-img resize "/var/lib/libvirt/images/${volumeid}" +200G
92+
93+
local serverid
94+
local serverid
95+
if ! virsh dominfo "${servername}" &>/dev/null; then
96+
sudo virt-install \
97+
--name "${servername}" \
98+
--memory "${memory}" \
99+
--vcpus "${vcpu}" \
100+
--import \
101+
--disk "/var/lib/libvirt/images/${volumeid},format=qcow2,bus=virtio" \
102+
--network network="${networkid}",mac="${mac}" \
103+
--os-variant=ubuntu22.04 \
104+
--graphics none \
105+
--cloud-init user-data="${userdata}" \
106+
--noautoconsole
107+
fi
108+
}
109+
110+
function get_public_ip {
111+
echo "${CONTROLLER_IP}"
112+
}
113+
114+
function get_mtu {
115+
# Set MTU statically for libvirt
116+
echo 1500
117+
}
118+
119+
function get_ssh_public_key_file {
120+
echo "${SSH_PUBLIC_KEY_FILE}"
121+
}
122+
123+
function get_ssh_private_key_file {
124+
# Allow this to be unbound. This is handled in create_devstack.sh
125+
echo "${SSH_PRIVATE_KEY_FILE:-}"
126+
}
127+
128+
function cloud_cleanup {
129+
for serverid in $(virsh list --all --name | grep -E "${CLUSTER_NAME}-controller|${CLUSTER_NAME}-worker"); do
130+
virsh destroy "${serverid}"
131+
virsh undefine "${serverid}" --remove-all-storage
132+
done
133+
134+
for networkid in $(virsh net-list --name | grep -E "${CLUSTER_NAME}"); do
135+
virsh net-destroy "${networkid}"
136+
virsh net-undefine "${networkid}"
137+
done
138+
139+
true
140+
}

0 commit comments

Comments
 (0)