From 0918bdbd88fa4185021a087a220ebeba3220bf9b Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Sat, 10 Jan 2015 08:16:02 -0800 Subject: [PATCH] Fix monitoring.sh flake (hopefully) This was staring at me yesterday, and I even commented that "huh, there's got to be something wrong with the firewall rules, but then job/kubernetes-e2e-gce/1002/tapResults/ made it obvious: If you have two e2e jobs running at the same time in the same project (hint: Jenkins does), they'll race with each other, since resource names are project scoped. --- hack/e2e-suite/monitoring.sh | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/hack/e2e-suite/monitoring.sh b/hack/e2e-suite/monitoring.sh index eff8bcdc813..e027d7dd32a 100755 --- a/hack/e2e-suite/monitoring.sh +++ b/hack/e2e-suite/monitoring.sh @@ -28,20 +28,19 @@ source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh" MONITORING="${KUBE_ROOT}/cluster/addons/cluster-monitoring" KUBECTL="${KUBE_ROOT}/cluster/kubectl.sh" -MONITORING_FIREWALL_RULE="monitoring-test" +BIGRAND=$(printf "%x\n" $(( $RANDOM << 16 | $RANDOM ))) # random 2^32 in hex +MONITORING_FIREWALL_RULE="monitoring-test-${BIGRAND}" function setup { # This only has work to do on gce and gke if [[ "${KUBERNETES_PROVIDER}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then detect-project - if ! "${GCLOUD}" compute firewall-rules describe $MONITORING_FIREWALL_RULE &> /dev/null; then - if ! "${GCLOUD}" compute firewall-rules create $MONITORING_FIREWALL_RULE \ - --project "${PROJECT}" \ - --network "${NETWORK}" \ - --quiet \ - --allow tcp:80 tcp:8083 tcp:8086 tcp:9200; then - echo "Failed to set up firewall for monitoring" && false - fi + if ! "${GCLOUD}" compute firewall-rules create "${MONITORING_FIREWALL_RULE}" \ + --project "${PROJECT}" \ + --network "${NETWORK}" \ + --quiet \ + --allow tcp:80 tcp:8083 tcp:8086 tcp:9200; then + echo "Failed to set up firewall for monitoring" && false fi fi @@ -58,11 +57,11 @@ function cleanup { # This only has work to do on gce and gke if [[ "${KUBERNETES_PROVIDER}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then detect-project - if "${GCLOUD}" compute firewall-rules describe $MONITORING_FIREWALL_RULE &> /dev/null; then + if "${GCLOUD}" compute firewall-rules describe "${MONITORING_FIREWALL_RULE}" &> /dev/null; then "${GCLOUD}" compute firewall-rules delete \ --project "${PROJECT}" \ --quiet \ - $MONITORING_FIREWALL_RULE || true + "${MONITORING_FIREWALL_RULE}" || true fi fi } @@ -123,4 +122,3 @@ influx-data-exists echo "monitoring setup works" exit 0 -