Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ci-operator/step-registry/gather/gcp-console/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
approvers:
- cgwalters
- enxebre
- jstuever
- patrickdillon
- vrutkovs
- wking
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/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 | 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"
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"path": "gather/gcp-console/gather-gcp-console-ref.yaml",
"owners": {
"approvers": [
"cgwalters",
"enxebre",
"jstuever",
"patrickdillon",
"vrutkovs",
"wking"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ref:
as: gather-gcp-console
optional_on_success: true
from_image:
namespace: ocp
name: "4.5"
tag: upi-installer
commands: gather-gcp-console-commands.sh
env:
- name: TMPDIR
default: /tmp
documentation: A pathname of a directory made available for programs that need a place to create temporary files.
resources:
requests:
cpu: 300m
memory: 300Mi
documentation: |-
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.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
chain:
as: ipi-gcp-post
steps:
- ref: gather-gcp-console
- chain: ipi-deprovision
documentation: |-
The IPI cleanup step contains all steps that deprovision an OpenShift
Expand Down