Skip to content

Commit 461cf73

Browse files
Merge pull request #80 from oracle-quickstart/image-short-names-fix
Support image short names for v1.34+
2 parents 175c5f7 + 8efed7c commit 461cf73

File tree

1 file changed

+37
-6
lines changed

1 file changed

+37
-6
lines changed

files/oke-ubuntu-cloud-init.sh

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,33 @@ else
88
exit 1
99
fi
1010

11+
version_ge() {
12+
local v1="$1"
13+
local v2="$2"
14+
15+
[[ -n "$v1" ]] || return 1
16+
[[ "$(printf '%s\n' "$v1" "$v2" | sort -V | tail -n1)" == "$v1" ]]
17+
}
18+
19+
# Fix for CRI-O short name mode not being disabled for Kubernetes versions >= 1.34
20+
configure_crio_defaults() {
21+
local version="$1"
22+
23+
if version_ge "$version" "v1.34"; then
24+
echo "Configuring CRI-O defaults for Kubernetes version $version"
25+
mkdir -p /etc/crio/crio.conf.d
26+
cat >/etc/crio/crio.conf.d/11-default.conf <<'EOF'
27+
[crio.image]
28+
short_name_mode = "disabled"
29+
EOF
30+
fi
31+
}
32+
1133
# Disable nvidia-imex.service for GB200 and GB300 shapes for Dynamic Resource Allocation (DRA) compatibility
12-
SHAPE=$(curl -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/instance/shape)
13-
if [[ "$SHAPE" == BM.GPU.GB200* ]] || [[ "$SHAPE" == BM.GPU.GB300* ]]; then
34+
SHAPE=$(curl -H "Authorization: Bearer Oracle" -L http://169.254.169.254/opc/v2/instance/shape 2>/dev/null) || true
35+
if [[ -z "$SHAPE" ]]; then
36+
echo "Warning: Unable to fetch instance shape from metadata service, skipping nvidia-imex check" >&2
37+
elif [[ "$SHAPE" == BM.GPU.GB200* ]] || [[ "$SHAPE" == BM.GPU.GB300* ]]; then
1438
echo "Disabling nvidia-imex.service for shape: $SHAPE"
1539
if systemctl list-unit-files | grep -q nvidia-imex.service; then
1640
systemctl disable --now nvidia-imex.service && systemctl mask nvidia-imex.service
@@ -23,11 +47,13 @@ case "$ID" in
2347
ubuntu)
2448
echo "Detected Ubuntu"
2549
if command -v oke >/dev/null 2>&1; then
26-
echo "[Ubuntu] oke binary already present → running bootstrap only"
50+
echo "[Ubuntu] oke binary already present, running bootstrap only"
51+
kubernetes_version="${1-}"
52+
configure_crio_defaults "$kubernetes_version"
2753
oke bootstrap
2854
else
29-
echo "[Ubuntu] oke binary not found installing package"
30-
kubernetes_version="$1"
55+
echo "[Ubuntu] oke binary not found, installing package"
56+
kubernetes_version="${1-}"
3157
oke_package_version="${kubernetes_version:1}"
3258
oke_package_repo_version="${oke_package_version:0:4}"
3359
oke_package_name="oci-oke-node-all-$oke_package_version"
@@ -51,13 +77,16 @@ EOF
5177
apt-get -y install "$oke_package_name"
5278

5379
echo "[Ubuntu] Running bootstrap"
80+
configure_crio_defaults "$kubernetes_version"
5481
oke bootstrap
5582
fi
5683
;;
5784
ol)
5885
echo "Detected Oracle Linux"
5986
if command -v oke >/dev/null 2>&1; then
60-
echo "[Oracle Linux] oke binary already present → running bootstrap only"
87+
echo "[Oracle Linux] oke binary already present, running bootstrap only"
88+
kubernetes_version="${1-}"
89+
configure_crio_defaults "$kubernetes_version"
6190
oke bootstrap
6291
else
6392
echo "[Oracle Linux] oke binary not found, fetching init script"
@@ -66,6 +95,8 @@ EOF
6695
| base64 --decode >/var/run/oke-init.sh
6796

6897
echo "[Oracle Linux] Running init script"
98+
kubernetes_version="${1-}"
99+
configure_crio_defaults "$kubernetes_version"
69100
bash /var/run/oke-init.sh
70101
fi
71102
;;

0 commit comments

Comments
 (0)