Step: gather-gcp-console

The pre-deprovision artifacts step collects console logs from GCP instances. It gathers console logs for all nodes and machines with a provider ID, as well as any instance IDs listed in ${SHARED_DIR}/gcp-instance-ids.txt. gcp-instance-ids.txt entries should have a single provider ID per line. Duplicate entries are ok; the step deduplicates before gathering.

Container image used for this step: ocp/4.5:upi-installer

ocp/4.5:upi-installer resolves to an image imported from the specified imagestream tag on the build farm (documentation).

Environment

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

Variable Name Type Variable Content
TMPDIR Parameter[?] A pathname of a directory made available for programs that need a place to create temporary files. (default: /tmp)

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
#!/bin/bash

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

trap 'CHILDREN=$(jobs -p); if test -n "${CHILDREN}"; then kill ${CHILDREN} && wait; fi' TERM

export GOOGLE_CLOUD_KEYFILE_JSON="${CLUSTER_PROFILE_DIR}/gce.json"
gcloud auth activate-service-account --key-file="${GOOGLE_CLOUD_KEYFILE_JSON}"

if test ! -f "${SHARED_DIR}/metadata.json"
then
	echo "No metadata.json, so unknown GCP project, so unable to gathering console logs."
	exit 0
fi

gcloud config set project "$(jq -r .gcp.projectID "${SHARED_DIR}/metadata.json")"

if test -f "${KUBECONFIG}"
then
	oc --request-timeout=5s get nodes -o jsonpath --template '{range .items[*]}{.spec.providerID}{"\n"}{end}' | sed 's|.*/||' > "${TMPDIR}/node-provider-IDs.txt" &
	wait "$!"

	oc --request-timeout=5s -n openshift-machine-api get machines -o jsonpath --template '{range .items[*]}{.spec.providerID}{"\n"}{end}' | sed 's|.*/||' >> "${TMPDIR}/node-provider-IDs.txt" &
	wait "$!"
else
	echo "No kubeconfig; skipping providerID extraction."
fi

if test -f "${SHARED_DIR}/gcp-instance-ids.txt"
then
	cat "${SHARED_DIR}/gcp-instance-ids.txt" >> "${TMPDIR}/node-provider-IDs.txt"
fi

cat "${TMPDIR}/node-provider-IDs.txt" | sort | grep . | uniq | while read -r INSTANCE_ID
do
	echo "Finding the zone for ${INSTANCE_ID}"
	ZONE="$(
		gcloud --format json compute instances list "--filter=name=(${INSTANCE_ID})" | jq -r '.[].zone' &
		wait "$!"
	)"
	if test -z "${ZONE}"
	then
		echo "No zone found for ${INSTANCE_ID}, so not attempting to gather console logs"
		continue
	fi
	echo "Gathering console logs for ${INSTANCE_ID} from ${ZONE}"
	gcloud --format json compute instances get-serial-port-output --zone "${ZONE}" "${INSTANCE_ID}" > "${ARTIFACT_DIR}/${INSTANCE_ID}.json" &
	wait "$!"
done

Properties

Property Value Description
Termination grace period[?] 10m0s Period of time until SIGKILL signal is sent to the test pod (after SIGTERM signal is sent).
Resource requests (cpu) 300m Used in .resources.requests of the pod running this step.
Resource requests (memory) 300Mi Used in .resources.requests of the pod running this step.
Optional on success[?] true Allows the step to be skipped if all steps in pre and test phases succeeded.

GitHub Link:

https://github.com/openshift/release/blob/master/ci-operator/step-registry/gather/gcp-console/gather-gcp-console-ref.yaml

Owners:

Approvers:

Source code for this page located on GitHub