Skip to content

Commit fd91d27

Browse files
authored
fix(Rook): Fix Rook 1.12.x upgrade and prep for 1.12.x release (#4714)
* Fix Rook 1.12.x upgrade and prep for 1.12.x release * Add Rook 1.12.0 to step version in clean file
1 parent 2450268 commit fd91d27

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

addons/rook/template/base/install.sh

+14
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ function rook_operator_crds_deploy() {
156156
# replace the CRDs if they already exist otherwise create them
157157
# replace or create rather than apply to avoid the error "metadata.annotations: Too long"
158158
if ! kubectl replace -f "$dst/crds.yaml" 2>/dev/null ; then
159+
160+
if kubectl get ns rook-ceph >/dev/null 2>&1 ; then
161+
# Rook 1.12 introduced a new CRD "cephcosidrivers.ceph.rook.io" which will cause
162+
# `kubectl create` to fail on upgrades. The following logic will extract the new CRD yaml and create it.
163+
semverParse "$ROOK_VERSION"
164+
local rook_major_version="$major"
165+
local rook_minor_version="$minor"
166+
if [ "$rook_major_version" = "1" ] && [ "$rook_minor_version" -ge "12" ]; then
167+
get_yaml_from_multidoc_yaml "$dst/crds.yaml" "cephcosidrivers.ceph.rook.io" | kubectl create -f -
168+
fi
169+
170+
return
171+
fi
172+
159173
kubectl create -f "$dst/crds.yaml"
160174
fi
161175
}

hack/testdata/manifest/clean

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ KURL_BIN_UTILS_FILE=
1111
# STEP_VERSIONS array is generated by the server and injected at runtime based on supported k8s versions
1212
STEP_VERSIONS=(0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 1.16.4 1.17.13 1.18.20 1.19.16 1.20.15 1.21.14 1.22.17 1.23.17 1.24.16 1.25.12 1.26.7 1.27.4)
1313
# ROOK_STEP_VERSIONS array is generated by the server and injected at runtime based on supported rook versions
14-
ROOK_STEP_VERSIONS=(1.0.4-14.2.21 0.0.0 0.0.0 0.0.0 1.4.9 1.5.12 1.6.11 1.7.11 1.8.10 1.9.12 1.10.11 1.11.8)
14+
ROOK_STEP_VERSIONS=(1.0.4-14.2.21 0.0.0 0.0.0 0.0.0 1.4.9 1.5.12 1.6.11 1.7.11 1.8.10 1.9.12 1.10.11 1.11.8 1.12.0)
1515
# CONTAINERD_STEP_VERSIONS array is generated by the server and injected at runtime based on supported containerd versions
1616
CONTAINERD_STEP_VERSIONS=(1.2.13 1.3.9 1.4.13 1.5.11 1.6.21)
1717
INSTALLER_YAML=

scripts/Manifest

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ KURL_BIN_UTILS_FILE=
1111
# STEP_VERSIONS array is generated by the server and injected at runtime based on supported k8s versions
1212
STEP_VERSIONS=(0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 0.0.0 1.16.4 1.17.13 1.18.20 1.19.16 1.20.15 1.21.14 1.22.17 1.23.17 1.24.16 1.25.12 1.26.7 1.27.4)
1313
# ROOK_STEP_VERSIONS array is generated by the server and injected at runtime based on supported rook versions
14-
ROOK_STEP_VERSIONS=(1.0.4-14.2.21 0.0.0 0.0.0 0.0.0 1.4.9 1.5.12 1.6.11 1.7.11 1.8.10 1.9.12 1.10.11 1.11.8)
14+
ROOK_STEP_VERSIONS=(1.0.4-14.2.21 0.0.0 0.0.0 0.0.0 1.4.9 1.5.12 1.6.11 1.7.11 1.8.10 1.9.12 1.10.11 1.11.8 1.12.0)
1515
# CONTAINERD_STEP_VERSIONS array is generated by the server and injected at runtime based on supported containerd versions
1616
CONTAINERD_STEP_VERSIONS=(1.2.13 1.3.9 1.4.13 1.5.11 1.6.21)
1717
INSTALLER_YAML=

scripts/common/yaml.sh

+18
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,21 @@ function yaml_escape_string_quotes() {
242242
function yaml_newline_to_literal() {
243243
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g'
244244
}
245+
246+
# get_yaml_from_multidoc_yaml reads a single file multi-doc yaml and finds a particular embedded yaml doc
247+
# based on the `name:` field and outputs the doc to stdout.
248+
function get_yaml_from_multidoc_yaml() {
249+
local multidoc_yaml="$1"
250+
local resource_name="$2"
251+
252+
# use awk to split the multidoc file using `---`separator
253+
awk -v RS='---\n' -v ORS='---\n' -v RESOURCE_NAME="$resource_name" '
254+
$0 ~ ("name: " RESOURCE_NAME) {
255+
found = 1
256+
print $0
257+
}
258+
END {
259+
exit !found
260+
}
261+
' "$multidoc_yaml"
262+
}

0 commit comments

Comments
 (0)