-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add capi rosa hcp upgrade job (#54658)
* add capi update job * update target version
- Loading branch information
Showing
20 changed files
with
587 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
ci-operator/step-registry/cucushift/hypershift-extended/capi/dump/OWNERS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
approvers: | ||
- LiangquanLi930 | ||
- heliubj18 | ||
- fxierh | ||
reviewers: | ||
- LiangquanLi930 | ||
- heliubj18 | ||
- fxierh |
59 changes: 59 additions & 0 deletions
59
...cushift/hypershift-extended/capi/dump/cucushift-hypershift-extended-capi-dump-commands.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
function set_proxy () { | ||
if test -s "${SHARED_DIR}/proxy-conf.sh" ; then | ||
echo "setting the proxy" | ||
# cat "${SHARED_DIR}/proxy-conf.sh" | ||
echo "source ${SHARED_DIR}/proxy-conf.sh" | ||
source "${SHARED_DIR}/proxy-conf.sh" | ||
else | ||
echo "no proxy setting." | ||
fi | ||
} | ||
|
||
function rosa_login() { | ||
# ROSA_VERSION=$(rosa version) | ||
ROSA_TOKEN=$(cat "${CLUSTER_PROFILE_DIR}/ocm-token") | ||
|
||
if [[ ! -z "${ROSA_TOKEN}" ]]; then | ||
echo "Logging into ${OCM_LOGIN_ENV} with offline token using rosa cli" | ||
rosa login --env "${OCM_LOGIN_ENV}" --token "${ROSA_TOKEN}" | ||
ocm login --url "${OCM_LOGIN_ENV}" --token "${ROSA_TOKEN}" | ||
else | ||
echo "Cannot login! You need to specify the offline token ROSA_TOKEN!" | ||
exit 1 | ||
fi | ||
} | ||
|
||
set_proxy | ||
rosa_login | ||
|
||
export KUBECONFIG="${SHARED_DIR}/kubeconfig" | ||
if [[ -f "${SHARED_DIR}/mgmt_kubeconfig" ]]; then | ||
export KUBECONFIG="${SHARED_DIR}/mgmt_kubeconfig" | ||
fi | ||
|
||
export AWS_SHARED_CREDENTIALS_FILE="${CLUSTER_PROFILE_DIR}/.awscred" | ||
export AWS_REGION=${REGION} | ||
export AWS_PAGER="" | ||
|
||
# get cluster namesapce | ||
CLUSTER_NAME=$(cat "${SHARED_DIR}/cluster-name") | ||
if [[ -z "${CLUSTER_NAME}" ]] ; then | ||
echo "Error: cluster name not found" | ||
exit 1 | ||
fi | ||
|
||
echo "dump rosa cluster info: ${CLUSTER_NAME}" | ||
rosa describe cluster -c ${CLUSTER_NAME} > ${ARTIFACT_DIR}/${CLUSTER_NAME}.yaml | ||
echo "dump capa logs" | ||
capa_controller=$(oc get pod -n capa-system -lcontrol-plane=capa-controller-manager -ojsonpath='{.items[*].metadata.name}') | ||
if [[ -n "${capa_controller}" ]] ; then | ||
oc logs -n capa-system ${capa_controller} > ${ARTIFACT_DIR}/${capa_controller}.logs | ||
fi | ||
|
||
echo "dump nodepool" | ||
nodepool_name=$(cat "${SHARED_DIR}/rosa_nodepool") | ||
rosa describe machinepool -c ${CLUSTER_NAME} --machinepool "${nodepool_name}" > ${ARTIFACT_DIR}/${nodepool_name}.yaml |
15 changes: 15 additions & 0 deletions
15
...t/hypershift-extended/capi/dump/cucushift-hypershift-extended-capi-dump-ref.metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"path": "cucushift/hypershift-extended/capi/dump/cucushift-hypershift-extended-capi-dump-ref.yaml", | ||
"owners": { | ||
"approvers": [ | ||
"LiangquanLi930", | ||
"heliubj18", | ||
"fxierh" | ||
], | ||
"reviewers": [ | ||
"LiangquanLi930", | ||
"heliubj18", | ||
"fxierh" | ||
] | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../cucushift/hypershift-extended/capi/dump/cucushift-hypershift-extended-capi-dump-ref.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
ref: | ||
as: cucushift-hypershift-extended-capi-dump | ||
from: rosa-aws-cli | ||
grace_period: 5m | ||
cli: latest | ||
commands: cucushift-hypershift-extended-capi-dump-commands.sh | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 100Mi | ||
env: | ||
- name: OCM_LOGIN_ENV | ||
default: "staging" | ||
documentation: The environment for rosa login. The supported values are [production, staging, integration]. | ||
- name: REGION | ||
default: "us-east-1" | ||
documentation: "The AWS region of the cluster." | ||
documentation: |- | ||
dump capi information for debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
ci-operator/step-registry/cucushift/hypershift-extended/capi/upgrade-cp/OWNERS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
approvers: | ||
- LiangquanLi930 | ||
- heliubj18 | ||
- fxierh | ||
reviewers: | ||
- LiangquanLi930 | ||
- heliubj18 | ||
- fxierh |
105 changes: 105 additions & 0 deletions
105
...rshift-extended/capi/upgrade-cp/cucushift-hypershift-extended-capi-upgrade-cp-commands.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
function set_proxy () { | ||
if test -s "${SHARED_DIR}/proxy-conf.sh" ; then | ||
echo "setting the proxy" | ||
# cat "${SHARED_DIR}/proxy-conf.sh" | ||
echo "source ${SHARED_DIR}/proxy-conf.sh" | ||
source "${SHARED_DIR}/proxy-conf.sh" | ||
else | ||
echo "no proxy setting." | ||
fi | ||
} | ||
|
||
function rosa_login() { | ||
# ROSA_VERSION=$(rosa version) | ||
ROSA_TOKEN=$(cat "${CLUSTER_PROFILE_DIR}/ocm-token") | ||
|
||
if [[ ! -z "${ROSA_TOKEN}" ]]; then | ||
echo "Logging into ${OCM_LOGIN_ENV} with offline token using rosa cli" | ||
rosa login --env "${OCM_LOGIN_ENV}" --token "${ROSA_TOKEN}" | ||
ocm login --url "${OCM_LOGIN_ENV}" --token "${ROSA_TOKEN}" | ||
else | ||
echo "Cannot login! You need to specify the offline token ROSA_TOKEN!" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function find_openshift_version() { | ||
# Get the openshift version | ||
CHANNEL_GROUP=stable | ||
version_cmd="rosa list versions --hosted-cp --channel-group ${CHANNEL_GROUP} -o json" | ||
version_cmd="$version_cmd | jq -r '.[].raw_id'" | ||
|
||
versionList=$(eval $version_cmd) | ||
echo -e "Available cluster versions:\n${versionList}" | ||
|
||
if [[ -z "$UPGRADED_TO_VERSION" ]]; then | ||
UPGRADED_TO_VERSION=$(echo "$versionList" | head -1) | ||
elif [[ $UPGRADED_TO_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then | ||
UPGRADED_TO_VERSION=$(echo "$versionList" | grep -E "^${UPGRADED_TO_VERSION}" | head -1 || true) | ||
else | ||
# Match the whole line | ||
UPGRADED_TO_VERSION=$(echo "$versionList" | grep -x "${UPGRADED_TO_VERSION}" || true) | ||
fi | ||
|
||
if [[ -z "$UPGRADED_TO_VERSION" ]]; then | ||
echo "Requested cluster version not available!" | ||
exit 1 | ||
fi | ||
} | ||
|
||
set_proxy | ||
rosa_login | ||
find_openshift_version | ||
|
||
export KUBECONFIG="${SHARED_DIR}/kubeconfig" | ||
if [[ -f "${SHARED_DIR}/mgmt_kubeconfig" ]]; then | ||
export KUBECONFIG="${SHARED_DIR}/mgmt_kubeconfig" | ||
fi | ||
|
||
export AWS_SHARED_CREDENTIALS_FILE="${CLUSTER_PROFILE_DIR}/.awscred" | ||
export AWS_REGION=${REGION} | ||
export AWS_PAGER="" | ||
|
||
# get cluster namesapce | ||
CLUSTER_NAME=$(cat "${SHARED_DIR}/cluster-name") | ||
if [[ -z "${CLUSTER_NAME}" ]] ; then | ||
echo "Error: cluster name not found" | ||
exit 1 | ||
fi | ||
|
||
read -r namespace _ _ <<< "$(oc get cluster -A | grep ${CLUSTER_NAME})" | ||
if [[ -z "${namespace}" ]]; then | ||
echo "capi cluster name not found error, ${CLUSTER_NAME}" | ||
exit 1 | ||
fi | ||
|
||
echo "upgrade rosacontrolplane" | ||
rosacontrolplane_name=$(oc get cluster "${CLUSTER_NAME}" -n "${namespace}" -ojsonpath='{.spec.controlPlaneRef.name}') | ||
version=$(oc get rosacontrolplane ${rosacontrolplane_name} -n ${namespace} -ojsonpath='{.spec.version}') | ||
echo "rosa controlplane version is $version now, begin to upgrade to $UPGRADED_TO_VERSION" | ||
oc patch -n "${namespace}" --type=merge --patch='{"spec":{"version":"'"${UPGRADED_TO_VERSION}"'"}}' rosacontrolplane/${rosacontrolplane_name} | ||
new_version=$(oc get rosacontrolplane ${rosacontrolplane_name} -n ${namespace} -ojsonpath='{.spec.version}') | ||
echo "now rosacontrolplane version is ${new_version}" | ||
|
||
CLUSTER_ID=$(cat $SHARED_DIR/cluster-id) | ||
start_time=$(date +"%s") | ||
while true; do | ||
sleep 150 | ||
rosa_hcp_version=$(rosa describe cluster -c "${CLUSTER_ID}" -o json | jq -r '.openshift_version') | ||
echo "rosa hcp version: ${rosa_hcp_version}" | ||
if [[ "${rosa_hcp_version}" == "${new_version}" ]]; then | ||
break | ||
fi | ||
if (( $(date +"%s") - $start_time >= $CLUSTER_TIMEOUT )); then | ||
echo "error: Timed out while waiting for cluster cp upgrade ${rosa_hcp_version}" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "rosa hcp cp upgrade done" | ||
|
||
|
Oops, something went wrong.