Skip to content

Commit e9350bb

Browse files
authored
Merge pull request #2305 from k8s-infra-cherrypick-robot/cherry-pick-2262-to-release-0.11
[release-0.11] 🌱 Add libvirt resource type for create_devstack.sh + Run devstack on ubuntu 24.04
2 parents 29cf01a + 4f8784b commit e9350bb

File tree

5 files changed

+162
-3
lines changed

5 files changed

+162
-3
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
# query_placement_for_availability_zone is the default from Xena
8282
query_placement_for_availability_zone = True
8383

84+
[workarounds]
85+
# FIXME(stephenfin): This is temporary while we get to the bottom of
86+
# https://bugs.launchpad.net/nova/+bug/2091114 It should not be kept after
87+
# we bump to 2025.1
88+
disable_deep_image_inspection = True
89+
8490
[[post-config|$CINDER_CONF]]
8591
[DEFAULT]
8692
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:-"2024.1"}
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)