mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 18:54:06 +00:00
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.
This commit is contained in:
parent
6cd37637f5
commit
0918bdbd88
@ -28,14 +28,14 @@ source "${KUBE_ROOT}/cluster/$KUBERNETES_PROVIDER/util.sh"
|
|||||||
|
|
||||||
MONITORING="${KUBE_ROOT}/cluster/addons/cluster-monitoring"
|
MONITORING="${KUBE_ROOT}/cluster/addons/cluster-monitoring"
|
||||||
KUBECTL="${KUBE_ROOT}/cluster/kubectl.sh"
|
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 {
|
function setup {
|
||||||
# This only has work to do on gce and gke
|
# This only has work to do on gce and gke
|
||||||
if [[ "${KUBERNETES_PROVIDER}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
|
if [[ "${KUBERNETES_PROVIDER}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
|
||||||
detect-project
|
detect-project
|
||||||
if ! "${GCLOUD}" compute firewall-rules describe $MONITORING_FIREWALL_RULE &> /dev/null; then
|
if ! "${GCLOUD}" compute firewall-rules create "${MONITORING_FIREWALL_RULE}" \
|
||||||
if ! "${GCLOUD}" compute firewall-rules create $MONITORING_FIREWALL_RULE \
|
|
||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
--network "${NETWORK}" \
|
--network "${NETWORK}" \
|
||||||
--quiet \
|
--quiet \
|
||||||
@ -43,7 +43,6 @@ function setup {
|
|||||||
echo "Failed to set up firewall for monitoring" && false
|
echo "Failed to set up firewall for monitoring" && false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
"${KUBECTL}" create -f "${MONITORING}/influx-grafana-pod.json"
|
"${KUBECTL}" create -f "${MONITORING}/influx-grafana-pod.json"
|
||||||
"${KUBECTL}" create -f "${MONITORING}/influx-grafana-service.json"
|
"${KUBECTL}" create -f "${MONITORING}/influx-grafana-service.json"
|
||||||
@ -58,11 +57,11 @@ function cleanup {
|
|||||||
# This only has work to do on gce and gke
|
# This only has work to do on gce and gke
|
||||||
if [[ "${KUBERNETES_PROVIDER}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
|
if [[ "${KUBERNETES_PROVIDER}" == "gce" ]] || [[ "${KUBERNETES_PROVIDER}" == "gke" ]]; then
|
||||||
detect-project
|
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 \
|
"${GCLOUD}" compute firewall-rules delete \
|
||||||
--project "${PROJECT}" \
|
--project "${PROJECT}" \
|
||||||
--quiet \
|
--quiet \
|
||||||
$MONITORING_FIREWALL_RULE || true
|
"${MONITORING_FIREWALL_RULE}" || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -123,4 +122,3 @@ influx-data-exists
|
|||||||
|
|
||||||
echo "monitoring setup works"
|
echo "monitoring setup works"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user