|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -o nounset |
| 4 | +set -o errexit |
| 5 | +set -o pipefail |
| 6 | + |
| 7 | +function info() { |
| 8 | + printf '%s: INFO: %s\n' "$(date --utc +%Y-%m-%dT%H:%M:%SZ)" "$*" |
| 9 | +} |
| 10 | + |
| 11 | +function wait_for_etcd_patch_done() { |
| 12 | + info 'Waiting for patch etcd cluster...' |
| 13 | + for _ in {1..30}; do |
| 14 | + ETCD_CO_AVAILABLE=$(oc get co etcd | grep etcd | awk '{print $3}') |
| 15 | + if [[ "${ETCD_CO_AVAILABLE}" == "True" ]]; then |
| 16 | + echo "Patched successfully!" |
| 17 | + break |
| 18 | + fi |
| 19 | + sleep 15 |
| 20 | + done |
| 21 | + if [[ "${ETCD_CO_AVAILABLE}" != "True" ]]; then |
| 22 | + echo "Etcd patch failed..." |
| 23 | + exit 1 |
| 24 | + fi |
| 25 | + info 'Etcd Patched successfully!' |
| 26 | +} |
| 27 | + |
| 28 | +# For disconnected or otherwise unreachable environments, we want to |
| 29 | +# have steps use an HTTP(S) proxy to reach the API server. This proxy |
| 30 | +# configuration file should export HTTP_PROXY, HTTPS_PROXY, and NO_PROXY |
| 31 | +# environment variables, as well as their lowercase equivalents (note |
| 32 | +# that libcurl doesn't recognize the uppercase variables). |
| 33 | +if test -f "${SHARED_DIR}/proxy-conf.sh" |
| 34 | +then |
| 35 | + # shellcheck disable=SC1090 |
| 36 | + source "${SHARED_DIR}/proxy-conf.sh" |
| 37 | +fi |
| 38 | + |
| 39 | +oc_version=$(oc version -o json | jq -r '.openshiftVersion' | cut -d '.' -f1,2) |
| 40 | + |
| 41 | +# The controlPlaneHardwareSpeed param is only available from 4.16 |
| 42 | +if [[ $(jq -n "$oc_version < 4.16") == "true" ]]; then |
| 43 | + info 'etcd tuning profile are only available from OCP 4.16... Skipping.' |
| 44 | + exit 0 |
| 45 | +fi |
| 46 | + |
| 47 | +# Patch etcd for allowing slower disks |
| 48 | +if [[ "${ETCD_DISK_SPEED}" == "slow" ]]; then |
| 49 | + info 'Patching etcd cluster operator...' |
| 50 | + oc patch etcd cluster --type=merge --patch '{"spec":{"controlPlaneHardwareSpeed":"Slower"}}' |
| 51 | + wait_for_etcd_patch_done |
| 52 | +fi |
0 commit comments