Step: ccm-conf-apply-feature-gate

Apply custom featureGate configuration to cluster to enable CCM functionality

Container image used for this step: cli

cli resolves to an image built or imported by the ci-operator configuration (documentation).

Environment

In addition to the default environment, the step exposes the following:

Variable Name Type Variable Content
MCO_IMAGE_OVERRIDE Parameter[?]
KCMO_IMAGE_OVERRIDE Parameter[?]

Source Code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
set -o nounset
set -o pipefail
set -e

export ARTIFACT_DIR=${ARTIFACT_DIR:-/tmp}

export CCM_NAMESPACE="openshift-cloud-controller-manager"

function applyFeatureGate() {
  echo "$(date -u --rfc-3339=seconds) - Apply external cloud-controller-manager FeatureGate configuration"

  cat <<EOF | oc apply -f -
---
apiVersion: config.openshift.io/v1
kind: FeatureGate
metadata:
  annotations:
    include.release.openshift.io/self-managed-high-availability: "true"
    include.release.openshift.io/single-node-developer: "true"
    release.openshift.io/create-only: "true"
  name: cluster
spec:
  customNoUpgrade:
    enabled:
    - ExternalCloudProvider
    - CSIMigrationAWS
    - CSIMigrationOpenStack
    - CSIMigrationAzureDisk
    - CSIDriverAzureDisk
    - CSIMigrationGCE
    - CSIDriverVSphere
    - CSIMigrationvSphere
  featureSet: CustomNoUpgrade
EOF
}

function waitForKubeletAndKCMRollout() {
  echo "$(date -u --rfc-3339=seconds) - Updated machineconfig should contain --cloud-provider=external flag..."
  waitFor 30m setExternalFlagMCO

  echo "$(date -u --rfc-3339=seconds) - Updated kube-controller-manager pods should contain --cloud-provider=external flag..."
  waitFor 30m setExternalFlagKCMO

  echo "$(date -u --rfc-3339=seconds) - All machineconfigs should be updated after rollout..."
  waitFor 30m oc wait --all --for=condition=Updated=True machineconfigpool

  echo "$(date -u --rfc-3339=seconds) - Wait for the operator to go available..."
  waitFor 10m oc wait --all --for=condition=Available=True clusteroperators.config.openshift.io

  echo "$(date -u --rfc-3339=seconds) - Waits for operators to finish rolling out..."
  waitFor 30m oc wait --all --for=condition=Progressing=False clusteroperators.config.openshift.io
}

function CCMPodsCreated() {
  while [ "$(oc get pods -n ${CCM_NAMESPACE} -o name | wc -l)" == 0 ]; do
    echo "$(date -u --rfc-3339=seconds) - Wait for CCCMO operands creation"
    sleep 5
  done
}
export -f CCMPodsCreated

function setExternalFlagMCO() {
  while [ "$(oc get machineconfig -o yaml | grep 'cloud-provider=external' | wc -l)" == 0 ]; do
    echo "$(date -u --rfc-3339=seconds) - Wait for machineconfig to set external cloud providers..."
    sleep 20
  done
}
export -f setExternalFlagMCO

function setExternalFlagKCMO() {
  KCM_NAMESPACE="openshift-kube-controller-manager"
 
  kcmPodsCount="$(oc get pods -n $KCM_NAMESPACE -l 'kube-controller-manager=true' -o name | wc -l)"
  while [ "$(oc get pods -n $KCM_NAMESPACE -o yaml | grep 'cloud-provider=external' | wc -l)" != "${kcmPodsCount}" ]; do
    echo "$(date -u --rfc-3339=seconds) - Waiting for kube-controller-manager to set external cloud providers..."
    sleep 20
  done
}
export -f setExternalFlagKCMO

function waitForCCMPodsReadiness() {
  echo "$(date -u --rfc-3339=seconds) - Wait for CCCMO operands to be ready"
  waitFor 3m oc wait --all -n "${CCM_NAMESPACE}" --for=condition=ready pods
}

function waitFor() {
  local TIMEOUT="${1}"
  local CMD="${*:2}"

  ret=0
  timeout "${TIMEOUT}" bash -c "execute ${CMD}" || ret="$?"

  # Command timed out
  if [[ ret -eq 124 ]]; then
    echo "$(date -u --rfc-3339=seconds) - Timed out waiting for result of $CMD"
    exit 1
  fi
}

function execute() {
  local CMD="${*}"

  # API server occasionally becomes unavailable, so we repeat command in case of error
  while true; do
    ret=0
    ${CMD} || ret="$?"

    if [[ ret -eq 0 ]]; then
      return
    fi

    echo "$(date -u --rfc-3339=seconds) - Command returned error $ret, retrying..."
  done
}
export -f execute


applyFeatureGate
waitFor 10m CCMPodsCreated
waitForCCMPodsReadiness
waitForKubeletAndKCMRollout

Properties

Property Value Description
Resource requests (cpu) 10m Used in .resources.requests of the pod running this step.
Resource requests (memory) 100Mi Used in .resources.requests of the pod running this step.

GitHub Link:

https://github.com/openshift/release/blob/master/ci-operator/step-registry/ccm/conf/apply-feature-gate/ccm-conf-apply-feature-gate-ref.yaml

Owners:

Approvers:

Reviewers:

Source code for this page located on GitHub