Skip to content

Commit

Permalink
fix(Rook): Fix Rook 1.12.x upgrade and prep for 1.12.x release (#4714)
Browse files Browse the repository at this point in the history
* Fix Rook 1.12.x upgrade and prep for 1.12.x release

* Add Rook 1.12.0 to step version in clean file
  • Loading branch information
rrpolanco authored Jul 28, 2023
1 parent 2450268 commit fd91d27
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
14 changes: 14 additions & 0 deletions addons/rook/template/base/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,20 @@ function rook_operator_crds_deploy() {
# replace the CRDs if they already exist otherwise create them
# replace or create rather than apply to avoid the error "metadata.annotations: Too long"
if ! kubectl replace -f "$dst/crds.yaml" 2>/dev/null ; then

if kubectl get ns rook-ceph >/dev/null 2>&1 ; then
# Rook 1.12 introduced a new CRD "cephcosidrivers.ceph.rook.io" which will cause
# `kubectl create` to fail on upgrades. The following logic will extract the new CRD yaml and create it.
semverParse "$ROOK_VERSION"
local rook_major_version="$major"
local rook_minor_version="$minor"
if [ "$rook_major_version" = "1" ] && [ "$rook_minor_version" -ge "12" ]; then
get_yaml_from_multidoc_yaml "$dst/crds.yaml" "cephcosidrivers.ceph.rook.io" | kubectl create -f -
fi

return
fi

kubectl create -f "$dst/crds.yaml"
fi
}
Expand Down
2 changes: 1 addition & 1 deletion hack/testdata/manifest/clean
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ KURL_BIN_UTILS_FILE=
# STEP_VERSIONS array is generated by the server and injected at runtime based on supported k8s versions
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)
# ROOK_STEP_VERSIONS array is generated by the server and injected at runtime based on supported rook versions
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)
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)
# CONTAINERD_STEP_VERSIONS array is generated by the server and injected at runtime based on supported containerd versions
CONTAINERD_STEP_VERSIONS=(1.2.13 1.3.9 1.4.13 1.5.11 1.6.21)
INSTALLER_YAML=
2 changes: 1 addition & 1 deletion scripts/Manifest
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ KURL_BIN_UTILS_FILE=
# STEP_VERSIONS array is generated by the server and injected at runtime based on supported k8s versions
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)
# ROOK_STEP_VERSIONS array is generated by the server and injected at runtime based on supported rook versions
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)
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)
# CONTAINERD_STEP_VERSIONS array is generated by the server and injected at runtime based on supported containerd versions
CONTAINERD_STEP_VERSIONS=(1.2.13 1.3.9 1.4.13 1.5.11 1.6.21)
INSTALLER_YAML=
18 changes: 18 additions & 0 deletions scripts/common/yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,21 @@ function yaml_escape_string_quotes() {
function yaml_newline_to_literal() {
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g'
}

# get_yaml_from_multidoc_yaml reads a single file multi-doc yaml and finds a particular embedded yaml doc
# based on the `name:` field and outputs the doc to stdout.
function get_yaml_from_multidoc_yaml() {
local multidoc_yaml="$1"
local resource_name="$2"

# use awk to split the multidoc file using `---`separator
awk -v RS='---\n' -v ORS='---\n' -v RESOURCE_NAME="$resource_name" '
$0 ~ ("name: " RESOURCE_NAME) {
found = 1
print $0
}
END {
exit !found
}
' "$multidoc_yaml"
}

0 comments on commit fd91d27

Please sign in to comment.