Step: baremetalds-assisted-setup

Checkout and execute assisted-test-infra on a packet server

Container image used for this step: assisted-test-infra

assisted-test-infra 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
ASSISTED_SERVICE_IMAGE Dependency[?] Pull specification for assisted-service image
ASSISTED_INSTALLER_IMAGE Dependency[?] Pull specification for assisted-installer image
ASSISTED_AGENT_IMAGE Dependency[?] Pull specification for assisted-installer-agent image
ASSISTED_CONTROLLER_IMAGE Dependency[?] Pull specification for assisted-installer-controller image
ASSISTED_CONFIG Parameter[?] Additional assisted configuration, appended to the one defined by the step command. See https://github.com/openshift/assisted-test-infra/blob/master/README.md for more details about supported values.
POST_INSTALL_COMMANDS Parameter[?] List of commands to run once the installation has finished.
ENVIRONMENT Parameter[?] Choose environment to run the test over. Current options are "local" (the default) and "production". (default: local)

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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash

set -o nounset
set -o errexit
set -o pipefail

echo "************ baremetalds assisted setup command ************"

# Fetch packet basic configuration
# shellcheck source=/dev/null
source "${SHARED_DIR}/packet-conf.sh"

export CI_CREDENTIALS_DIR=/var/run/assisted-installer-bot

# Copy assisted source from current directory to the remote server
tar -czf - . | ssh "${SSHOPTS[@]}" "root@${IP}" "cat > /root/assisted.tar.gz"

# Prepare configuration and run
scp "${SSHOPTS[@]}" "${CLUSTER_PROFILE_DIR}/pull-secret" "root@${IP}:pull-secret"

if [ "${ENVIRONMENT}" != "local" ]; then

  if [ "${ENVIRONMENT}" = "production" ]; then
    remote_service_url="https://api.openshift.com"
    pull_secret_file="${CI_CREDENTIALS_DIR}/prod-pull-secret"
  else
    echo "Unknown environment ${ENVIRONMENT}"
    exit 1
  fi

  scp "${SSHOPTS[@]}" "${CI_CREDENTIALS_DIR}/offline-token" "root@${IP}:offline-token"
  scp "${SSHOPTS[@]}" "${pull_secret_file}" "root@${IP}:pull-secret"

  echo "export REMOTE_SERVICE_URL=${remote_service_url}" >> "${SHARED_DIR}/assisted-additional-config"
  echo "export NO_MINIKUBE=true" >> "${SHARED_DIR}/assisted-additional-config"
  echo "export MAKEFILE_TARGET='create_full_environment test_parallel'" >> "${SHARED_DIR}/assisted-additional-config"

  WORKER_DISK_SIZE=$(echo 120G | numfmt --from=iec)
  echo "export WORKER_DISK=${WORKER_DISK_SIZE}" >> "${SHARED_DIR}/assisted-additional-config"
fi

# Additional mechanism to inject assisted additional variables directly
# from a multistage step configuration.
# Backward compatible with the previous approach based on creating the
# assisted-additional-config file from a multistage step command
if [[ -n "${ASSISTED_CONFIG:-}" ]]; then
  readarray -t config <<< "${ASSISTED_CONFIG}"
  for var in "${config[@]}"; do
    if [[ ! -z "${var}" ]]; then
      echo "export ${var}" >> "${SHARED_DIR}/assisted-additional-config"
    fi
  done
fi

if [[ -e "${SHARED_DIR}/assisted-additional-config" ]]
then
  scp "${SSHOPTS[@]}" "${SHARED_DIR}/assisted-additional-config" "root@${IP}:assisted-additional-config"
fi

timeout -s 9 175m ssh "${SSHOPTS[@]}" "root@${IP}" bash - << EOF |& sed -e 's/.*auths\{0,1\}".*/*** PULL_SECRET ***/g'

set -xeuo pipefail

yum install -y git sysstat sos jq
systemctl start sysstat

mkdir -p /tmp/artifacts

# NVMe makes it faster
NVME_DEVICE="/dev/nvme0n1"
REPO_DIR="/home/assisted"
if [ -e "\$NVME_DEVICE" ];
then
  mkfs.xfs -f "\${NVME_DEVICE}"
  mkdir -p "\${REPO_DIR}"
  mount "\${NVME_DEVICE}" "\${REPO_DIR}"
fi

tar -xzvf assisted.tar.gz -C "\${REPO_DIR}"
chown -R root:root "\${REPO_DIR}"

cd "\${REPO_DIR}"

set +x
echo "export PULL_SECRET='\$(cat /root/pull-secret)'" >> /root/config
echo "export OFFLINE_TOKEN='\$(cat /root/offline-token)'" >> /root/config
set -x

# Save Prow variables that might become handy inside the Packet server
echo "export CI=true" >> /root/config
echo "export OPENSHIFT_CI=true" >> /root/config
echo "export REPO_NAME=${REPO_NAME:-}" >> /root/config
echo "export JOB_TYPE=${JOB_TYPE:-}" >> /root/config
echo "export PULL_NUMBER=${PULL_NUMBER:-}" >> /root/config
echo "export RELEASE_IMAGE_LATEST=${RELEASE_IMAGE_LATEST}" >> /root/config

# Override default images
echo "export SERVICE=${ASSISTED_SERVICE_IMAGE}" >> /root/config
echo "export AGENT_DOCKER_IMAGE=${ASSISTED_AGENT_IMAGE}" >> /root/config
echo "export CONTROLLER_IMAGE=${ASSISTED_CONTROLLER_IMAGE}" >> /root/config
echo "export INSTALLER_IMAGE=${ASSISTED_INSTALLER_IMAGE}" >> /root/config

# expr command's return value is 1 in case of a false expression. We don't want to exit in this case.
set +e
IS_REHEARSAL=\$(expr "${REPO_OWNER:-}" = "openshift" "&" "${REPO_NAME:-}" = "release")
set -e

if [ "${JOB_TYPE:-}" = "presubmit" ] && (( ! \${IS_REHEARSAL} )); then
  # We would like to keep running a stable version for PRs
  echo "export OPENSHIFT_VERSION=4.8" >> /root/config

  if [ "${REPO_NAME:-}" = "assisted-service" ]; then
    echo "export SERVICE_BRANCH=${PULL_PULL_SHA:-master}" >> /root/config
  fi
else
  # Periodics run against latest release
  echo "export OPENSHIFT_INSTALL_RELEASE_IMAGE=${RELEASE_IMAGE_LATEST}" >> /root/config
fi

IMAGES=(${ASSISTED_AGENT_IMAGE} ${ASSISTED_CONTROLLER_IMAGE} ${ASSISTED_INSTALLER_IMAGE} ${RELEASE_IMAGE_LATEST})
CI_REGISTRIES=\$(for image in \${IMAGES}; do echo \${image} | cut -d'/' -f1; done | sort -u | paste -sd "," -)

echo "export PUBLIC_CONTAINER_REGISTRIES=quay.io,\${CI_REGISTRIES}" >> /root/config
echo "export ASSISTED_SERVICE_HOST=${IP}" >> /root/config
echo "export CHECK_CLUSTER_VERSION=True" >> /root/config
echo "export NUM_WORKERS=2" >> /root/config
echo "export TEST_TEARDOWN=false" >> /root/config
echo "export TEST_FUNC=test_install" >> /root/config
echo "export INSTALLER_KUBECONFIG=\${REPO_DIR}/build/kubeconfig" >> /root/config

if [[ -e /root/assisted-additional-config ]]; then
  cat /root/assisted-additional-config >> /root/config
fi

source /root/config

make \${MAKEFILE_TARGET:-create_full_environment run test_parallel}

EOF


if [[ -n "${POST_INSTALL_COMMANDS:-}" ]]; then
  echo "${POST_INSTALL_COMMANDS}" > "${SHARED_DIR}/assisted-post-install.sh"
  scp "${SSHOPTS[@]}" "${SHARED_DIR}/assisted-post-install.sh" "root@${IP}:assisted-post-install.sh"
fi

# Post-installation commands
ssh "${SSHOPTS[@]}" "root@${IP}" bash - << EOF |& sed -e 's/.*auths\{0,1\}".*/*** PULL_SECRET ***/g'

set -xeuo pipefail

cd /home/assisted
source /root/config

echo "export KUBECONFIG=/home/assisted/build/kubeconfig" >> /root/.bashrc
export KUBECONFIG=/home/assisted/build/kubeconfig

if [[ -e "/root/assisted-post-install.sh" ]]; then
  source "/root/assisted-post-install.sh"
fi

EOF

Properties

Property Value Description
Step timeout[?] 3h0m0s Limits the execution time of the step.
Resource requests (cpu) 1000m Used in .resources.requests of the pod running this step.
Resource requests (memory) 500Mi Used in .resources.requests of the pod running this step.

GitHub Link:

https://github.com/openshift/release/blob/master/ci-operator/step-registry/baremetalds/assisted/setup/baremetalds-assisted-setup-ref.yaml

Owners:

Approvers:

Source code for this page located on GitHub