Skip to content

ci-operator/templates/e2e-metal: fix csr approval and bootstrap log gathering #3587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -299,16 +299,23 @@ objects:
echo "Removing bootstrap host from control plane api pool"
(cd /tmp/artifacts/terraform && terraform apply -auto-approve=true -var=bootstrap_dns="false")

echo "Approving any pending CSR requests"
oc get csr -ojson | jq -r '.items[] | select(.status == {} ) | .metadata.name' | xargs oc adm certificate approve
function approve_csrs() {
while [[ ! -f /tmp/exit ]] && [[ ! -f /tmp/setup-success ]]; do
oc get csr -ojson | jq -r '.items[] | select(.status == {} ) | .metadata.name' | xargs --no-run-if-empty oc adm certificate approve
sleep 15
done
}

until oc get configs.imageregistry.operator.openshift.io cluster >/dev/null
do
echo "waiting for configs.imageregistry.operator.openshift.io cluster to exit failed. Retrying in 1 minute..."
sleep 1m
done
function update_image_registry() {
while true; do
sleep 10;
oc get configs.imageregistry.operator.openshift.io/cluster > /dev/null && break
done
oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}}}}'
}

oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}}}}'
approve_csrs &
update_image_registry &
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the pattern is to echo some progress message before taking action, should we have echo 'Updating image registry storage...' or something similar before this line? I'm also fine just having the script silently do its job, but it feels odd to have this update_image_registry appear to happen under an Approving pending CSRs header.


echo "Completing UPI setup"
openshift-install --dir=/tmp/artifacts/installer wait-for install-complete &
Expand Down Expand Up @@ -366,14 +373,9 @@ objects:
mkdir -p /tmp/artifacts/pods /tmp/artifacts/nodes /tmp/artifacts/metrics /tmp/artifacts/bootstrap /tmp/artifacts/network


if [ -f /tmp/artifacts/installer/terraform.tfstate ]
if [ -f /tmp/artifacts/terraform/terraform.tfstate ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everyone else puts this under the installer directory:

$ git grep -h terraform.tfstate origin/master -- ci-operator/templates/openshift/installer | grep -o '/tmp.*tfstate' | sort | uniq -c
     12 /tmp/artifacts/installer/terraform.tfstate

but I guess that's because they're running Terraform via the installer. So +1 to this, although I was initially confused ;).

then
# we don't have jq, so the python equivalent of
# jq '.modules[].resources."aws_instance.bootstrap".primary.attributes."public_ip" | select(.)'
bootstrap_ip=$(python -c \
'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 ""' \
< /tmp/artifacts/installer/terraform.tfstate
)
bootstrap_ip=$(terraform output -json | jq -r '.bootstrap_ip.value')

if [ -n "${bootstrap_ip}" ]
then
Expand All @@ -388,6 +390,15 @@ objects:
--key /tmp/artifacts/installer/tls/journal-gatewayd.key \
--url "https://${bootstrap_ip}:19531/entries?_SYSTEMD_UNIT=${service}.service"
done
if ! whoami &> /dev/null; then
if [ -w /etc/passwd ]; then
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
fi
fi
eval $(ssh-agent)
ssh-add /etc/openshift-installer/ssh-privatekey
ssh -A -o PreferredAuthentications=publickey -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null core@${bootstrap_ip} /bin/bash -x /usr/local/bin/installer-gather.sh
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
fi
else
echo "No terraform statefile found. Skipping collection of bootstrap logs."
Expand Down