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
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ set -o pipefail

echo "************ baremetalds devscripts conf compact command ************"

echo "export NUM_WORKERS=0" >> ${SHARED_DIR}/dev-scripts-additional-config
echo "export NUM_WORKERS=0" >> "${SHARED_DIR}/dev-scripts-additional-config"
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,4 @@ set -o pipefail

echo "************ baremetalds devscripts conf dualstack command ************"

echo "export IP_STACK=v4v6" >> ${SHARED_DIR}/dev-scripts-additional-config







echo "export IP_STACK=v4v6" >> "${SHARED_DIR}/dev-scripts-additional-config"
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ set -o pipefail

echo "************ baremetalds devscripts conf ipv4 command ************"

echo "export IP_STACK=v4" >> ${SHARED_DIR}/dev-scripts-additional-config
echo "export IP_STACK=v4" >> "${SHARED_DIR}/dev-scripts-additional-config"
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@ set -o pipefail
echo "************ baremetalds gather command ************"

# TODO: Remove once OpenShift CI will be upgraded to 4.2 (see https://access.redhat.com/articles/4859371)
${HOME}/fix_uid.sh
~/fix_uid.sh

# Initial check
if [ "${CLUSTER_TYPE}" != "packet" ] ; then
echo >&2 "Unsupported cluster type '${CLUSTER_TYPE}'"
exit 1
fi

if [[ ! -e ${SHARED_DIR}/server-ip ]]
if [[ ! -e "${SHARED_DIR}/server-ip" ]]
then
echo "No server IP found; skipping log gathering."
exit 0
fi

# Fetch packet server IP
IP=$(cat ${SHARED_DIR}/server-ip)
SSHOPTS="-o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=90 -i ${CLUSTER_PROFILE_DIR}/.packet-kni-ssh-privatekey"
IP=$(cat "${SHARED_DIR}/server-ip")
SSHOPTS=(-o 'ConnectTimeout=5' -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null' -o 'ServerAliveInterval=90' -i "${CLUSTER_PROFILE_DIR}/.packet-kni-ssh-privatekey")

function getlogs() {
echo "### Downloading logs..."
scp $SSHOPTS root@$IP:/tmp/artifacts/\*.tar\* ${ARTIFACT_DIR}
scp "${SSHOPTS[@]}" "root@${IP}:/tmp/artifacts/*.tar*" "${ARTIFACT_DIR}"
}

# Gather logs regardless of what happens after this
trap getlogs EXIT

echo "### Gathering logs..."
timeout -s 9 15m ssh $SSHOPTS root@$IP bash - << EOF |& sed -e 's/.*auths.*/*** PULL_SECRET ***/g'
timeout -s 9 15m ssh "${SSHOPTS[@]}" "root@${IP}" bash - << EOF |& sed -e 's/.*auths.*/*** PULL_SECRET ***/g'
cd dev-scripts

# Get install-gather, if there is one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -o pipefail
echo "************ baremetalds devscripts setup command ************"

# TODO: Remove once OpenShift CI will be upgraded to 4.2 (see https://access.redhat.com/articles/4859371)
${HOME}/fix_uid.sh
~/fix_uid.sh

# Initial check
if [ "${CLUSTER_TYPE}" != "packet" ] ; then
Expand All @@ -16,14 +16,14 @@ if [ "${CLUSTER_TYPE}" != "packet" ] ; then
fi

# Fetch packet server IP
IP=$(cat ${SHARED_DIR}/server-ip)
IP=$(cat "${SHARED_DIR}/server-ip")

SSHOPTS="-o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=90 -i ${CLUSTER_PROFILE_DIR}/.packet-kni-ssh-privatekey"
SSHOPTS=(-o 'ConnectTimeout=5' -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null' -o 'ServerAliveInterval=90' -i "${CLUSTER_PROFILE_DIR}/.packet-kni-ssh-privatekey")

# Checkout dev-scripts and make
for x in $(seq 10) ; do
test $x == 10 && exit 1
ssh $SSHOPTS root@$IP hostname && break
test "$x" -eq 10 && exit 1
ssh "${SSHOPTS[@]}" "root@${IP}" hostname && break
sleep 10
done

Expand All @@ -34,23 +34,23 @@ finished()

# Get dev-scripts logs
echo "dev-scripts setup completed, fetching logs"
ssh $SSHOPTS root@$IP tar -czf - /root/dev-scripts/logs | tar -C ${ARTIFACT_DIR} -xzf -
sed -i -e 's/.*auths.*/*** PULL_SECRET ***/g' ${ARTIFACT_DIR}/root/dev-scripts/logs/*
ssh "${SSHOPTS[@]}" "root@${IP}" tar -czf - /root/dev-scripts/logs | tar -C "${ARTIFACT_DIR}" -xzf -
sed -i -e 's/.*auths.*/*** PULL_SECRET ***/g' "${ARTIFACT_DIR}"/root/dev-scripts/logs/*
}
trap finished EXIT TERM

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

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

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

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

set -xeuo pipefail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ if [ "${CLUSTER_TYPE}" != "packet" ] ; then
fi

# Fetch packet server IP
IP=$(cat ${SHARED_DIR}/server-ip)
IP=$(cat "${SHARED_DIR}/server-ip")

SSHOPTS="-o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ServerAliveInterval=90 -i ${CLUSTER_PROFILE_DIR}/.packet-kni-ssh-privatekey"
SSHOPTS=(-o 'ConnectTimeout=5' -o 'StrictHostKeyChecking=no' -o 'UserKnownHostsFile=/dev/null' -o 'ServerAliveInterval=90' -i "${CLUSTER_PROFILE_DIR}/.packet-kni-ssh-privatekey")

# Copy test binaries on packet server
echo "### Copying test binaries"
scp $SSHOPTS /usr/bin/openshift-tests /usr/bin/kubectl root@$IP:/usr/local/bin
scp "${SSHOPTS[@]}" /usr/bin/openshift-tests /usr/bin/kubectl "root@${IP}:/usr/local/bin"

# Tests execution
set +e
echo "### Running tests"
ssh $SSHOPTS root@$IP openshift-tests run "openshift/conformance/parallel" --dry-run \| grep 'Feature:ProjectAPI' \| openshift-tests run -o /tmp/artifacts/e2e.log --junit-dir /tmp/artifacts/junit -f -
ssh "${SSHOPTS[@]}" "root@${IP}" openshift-tests run "openshift/conformance/parallel" --dry-run \| grep 'Feature:ProjectAPI' \| openshift-tests run -o /tmp/artifacts/e2e.log --junit-dir /tmp/artifacts/junit -f -
rv=$?

echo "### Fetching results"
ssh $SSHOPTS root@$IP tar -czf - /tmp/artifacts | tar -C ${ARTIFACT_DIR} -xzf -
ssh "${SSHOPTS[@]}" "root@${IP}" tar -czf - /tmp/artifacts | tar -C "${ARTIFACT_DIR}" -xzf -

set -e
echo "### Done! (${rv})"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ set -o pipefail

set +x

PACKET_PROJECT_ID=$(cat ${CLUSTER_PROFILE_DIR}/.packet-kni-vars|grep packet_project_id|awk '{print $2}')
PACKET_AUTH_TOKEN=$(cat ${CLUSTER_PROFILE_DIR}/.packet-kni-vars|grep packet_auth_token|awk '{print $2}')
SLACK_AUTH_TOKEN=$(cat ${CLUSTER_PROFILE_DIR}/.slackhook)
PACKET_PROJECT_ID=$(grep packet_project_id "${CLUSTER_PROFILE_DIR}/.packet-kni-vars" | awk '{print $2}')
PACKET_AUTH_TOKEN=$(grep packet_auth_token "${CLUSTER_PROFILE_DIR}/.packet-kni-vars" | awk '{print $2}')
SLACK_AUTH_TOKEN=$(cat "${CLUSTER_PROFILE_DIR}/.slackhook")

# Initial check
if [ "${CLUSTER_TYPE}" != "packet" ] ; then
Expand All @@ -17,9 +17,9 @@ if [ "${CLUSTER_TYPE}" != "packet" ] ; then
fi

#Packet API call to get list of servers in project
servers="$(curl -X GET --header 'Accept: application/json' --header "X-Auth-Token: ${PACKET_AUTH_TOKEN}"\
"https://api.packet.net/projects/${PACKET_PROJECT_ID}/devices?exclude=root_password,ssh_keys,created_by,project,project_lite\
,ip_addresses,plan,meta,operating_system,facility,network_ports&per_page=1000")"
servers="$(curl -X GET --header 'Accept: application/json' --header "X-Auth-Token: ${PACKET_AUTH_TOKEN}" \
"https://api.packet.net/projects/${PACKET_PROJECT_ID}/devices?exclude=root_password,ssh_keys,created_by,project,project_lite,ip_addresses,plan,meta,operating_system,facility,network_ports&per_page=1000"
)"

#Assuming all servers created more than 4 hours = 14400 sec ago are leaks
leaks="$(echo "$servers" | jq -r '.devices[]|select((now-(.created_at|fromdate))>14400 and any(.hostname; startswith("ipi-")))')"
Expand All @@ -43,8 +43,8 @@ then
#send slack notification and delete e2e-metal-ipi leaked servers
curl -X POST --data-urlencode\
"payload={\"text\":\"New Packet.net server leaks total: $leak_num. Deleting the following:\n\",\"attachments\":[{\"color\":\"warning\",\"text\":\"$leak_report\"}]}"\
https://hooks.slack.com/services/T027F3GAJ/B011TAG710V/${SLACK_AUTH_TOKEN}
"https://hooks.slack.com/services/T027F3GAJ/B011TAG710V/${SLACK_AUTH_TOKEN}"

#delete leaks
for leak in $leak_ids
do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ set -o pipefail
echo "************ baremetalds packet setup command ************"

# TODO: Remove once OpenShift CI will be upgraded to 4.2 (see https://access.redhat.com/articles/4859371)
${HOME}/fix_uid.sh
~/fix_uid.sh

# Run Ansible playbook
cd ${HOME}
cd
cat > packet-setup.yaml <<-EOF
- name: setup Packet host
hosts: localhost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ set -o pipefail
echo "************ baremetalds packet teardown command ************"

# TODO: Remove once OpenShift CI will be upgraded to 4.2 (see https://access.redhat.com/articles/4859371)
${HOME}/fix_uid.sh
~/fix_uid.sh

# Run Ansible playbook
cd ${HOME}
cd
cat > packet-teardown.yaml <<-EOF
- name: teardown Packet host
hosts: localhost
Expand Down