Skip to content

Commit a26eb31

Browse files
committed
ci-operator/templates/e2e-metal: fix csr approval and bootstrap log gathering
Carries changes from [1] and [2] [1]: openshift#3573 [2]: openshift#3475
1 parent 23d2502 commit a26eb31

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

ci-operator/templates/openshift/installer/cluster-launch-installer-metal-e2e.yaml

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -299,16 +299,23 @@ objects:
299299
echo "Removing bootstrap host from control plane api pool"
300300
(cd /tmp/artifacts/terraform && terraform apply -auto-approve=true -var=bootstrap_dns="false")
301301
302-
echo "Approving any pending CSR requests"
303-
oc get csr -ojson | jq -r '.items[] | select(.status == {} ) | .metadata.name' | xargs oc adm certificate approve
302+
function approve_csrs() {
303+
while [[ ! -f /tmp/exit ]] && [[ ! -f /tmp/setup-success ]]; do
304+
oc get csr -ojson | jq -r '.items[] | select(.status == {} ) | .metadata.name' | xargs --no-run-if-empty oc adm certificate approve
305+
sleep 15
306+
done
307+
}
304308
305-
until oc get configs.imageregistry.operator.openshift.io cluster >/dev/null
306-
do
307-
echo "waiting for configs.imageregistry.operator.openshift.io cluster to exit failed. Retrying in 1 minute..."
308-
sleep 1m
309-
done
309+
function update_image_registry() {
310+
while true; do
311+
sleep 10;
312+
oc get configs.imageregistry.operator.openshift.io/cluster > /dev/null && break
313+
done
314+
oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}}}}'
315+
}
310316
311-
oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}}}}'
317+
approve_csrs &
318+
update_image_registry &
312319
313320
echo "Completing UPI setup"
314321
openshift-install --dir=/tmp/artifacts/installer wait-for install-complete &
@@ -366,14 +373,9 @@ objects:
366373
mkdir -p /tmp/artifacts/pods /tmp/artifacts/nodes /tmp/artifacts/metrics /tmp/artifacts/bootstrap /tmp/artifacts/network
367374
368375
369-
if [ -f /tmp/artifacts/installer/terraform.tfstate ]
376+
if [ -f /tmp/artifacts/terraform/terraform.tfstate ]
370377
then
371-
# we don't have jq, so the python equivalent of
372-
# jq '.modules[].resources."aws_instance.bootstrap".primary.attributes."public_ip" | select(.)'
373-
bootstrap_ip=$(python -c \
374-
'import sys, json; d=reduce(lambda x,y: dict(x.items() + y.items()), map(lambda x: x["resources"], json.load(sys.stdin)["modules"])); k="aws_instance.bootstrap"; print d[k]["primary"]["attributes"]["public_ip"] if k in d else ""' \
375-
< /tmp/artifacts/installer/terraform.tfstate
376-
)
378+
bootstrap_ip=$(terraform output -json | jq -r '.bootstrap_ip.value')
377379
378380
if [ -n "${bootstrap_ip}" ]
379381
then
@@ -388,6 +390,15 @@ objects:
388390
--key /tmp/artifacts/installer/tls/journal-gatewayd.key \
389391
--url "https://${bootstrap_ip}:19531/entries?_SYSTEMD_UNIT=${service}.service"
390392
done
393+
if ! whoami &> /dev/null; then
394+
if [ -w /etc/passwd ]; then
395+
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
396+
fi
397+
fi
398+
eval $(ssh-agent)
399+
ssh-add /etc/openshift-installer/ssh-privatekey
400+
ssh -A -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip} /bin/bash -x /usr/local/bin/installer-gather.sh
401+
scp -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip}:log-bundle.tar.gz /tmp/artifacts/installer/bootstrap-logs.tar.gz
391402
fi
392403
else
393404
echo "No terraform statefile found. Skipping collection of bootstrap logs."

0 commit comments

Comments
 (0)