From 7589a92c1c41a18d254e07ebef1c86ec89faca8b Mon Sep 17 00:00:00 2001 From: Bob Fournier Date: Fri, 8 Jul 2022 08:12:29 -0400 Subject: [PATCH] For agent mirror testing force disconnect from masters This simulates a disconnect from the masters when using the agent with mirroring. It sets a bogus /etc/hosts entry so that the local mirror mut be used. This is currently needed since we must have a valid connection to create the mirror and create the iso so we can't break the connection until after that's done. --- agent/05_agent_create_cluster.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/agent/05_agent_create_cluster.sh b/agent/05_agent_create_cluster.sh index 9209d2c64..8736f6fb7 100755 --- a/agent/05_agent_create_cluster.sh +++ b/agent/05_agent_create_cluster.sh @@ -39,6 +39,32 @@ function attach_agent_iso() { done } +function force_mirror_disconnect() { + + # Set a bogus entry in /etc/hosts on all masters to force the local mirror to be used + node0_name=$(printf ${MASTER_HOSTNAME_FORMAT} 0) + node0_ip=$(sudo virsh net-dumpxml ostestbm | xmllint --xpath "string(//dns[*]/host/hostname[. = '${node0_name}']/../@ip)" -) + ssh_opts=(-o 'StrictHostKeyChecking=no' -q core@${node0_ip}) + + for (( n=0; n<${NUM_MASTERS}; n++ )) + do + node_name=$(printf ${MASTER_HOSTNAME_FORMAT} $n) + node_ip=$(sudo virsh net-dumpxml ostestbm | xmllint --xpath "string(//dns[*]/host/hostname[. = '${node_name}']/../@ip)" -) + ssh_opts=(-o 'StrictHostKeyChecking=no' -q core@${node_ip}) + + until ssh "${ssh_opts[@]}" "[[ -f /etc/hosts ]]" + do + echo "Waiting for $node_name to set remote host disconnect " + sleep 30s; + done + + # Set a bogus entry in /etc/hosts to break remote access + ssh "${ssh_opts[@]}" "echo '125.12.15.15 quay.io' | sudo tee -a /etc/hosts " + ssh "${ssh_opts[@]}" "echo '125.12.15.16 registry.ci.openshift.org' | sudo tee -a /etc/hosts " + done + +} + function wait_for_cluster_ready() { node0_name=$(printf ${MASTER_HOSTNAME_FORMAT} 0) @@ -66,6 +92,10 @@ create_image attach_agent_iso master $NUM_MASTERS attach_agent_iso worker $NUM_WORKERS +if [ ! -z "${MIRROR_IMAGES}" ]; then + force_mirror_disconnect +fi + wait_for_cluster_ready # Temporary fix for the CI. To be removed once we'll # be able to generate the cluster credentials