@cryptotaxi247 / netdata-1 / commits / 1692eedb7

add validation step before using GCP metadata (#14801)

* add GCP data validation * Update daemon/system-info.sh --------- Co-authored-by: Austin S. Hemmelgarn <ahferroin7@gmail.com>

Ilya Mashchenko committed Mar 23, 2023 at 21:13 UTC 1692eedb7ab6cce4aed6cb9bef04b0ff23337501
1 file changed +1 -1
daemon/system-info.sh
+1 -1
@@ -462,7 +462,7 @@ if [ "${VIRTUALIZATION}" != "none" ] && command -v curl > /dev/null 2>&1; then
462
463 # Try GCE computeMetadata v1
464 if [ "${CLOUD_TYPE}" = "unknown" ]; then
465 - if [ -n "$(curl --fail -s --connect-timeout 1 -m 3 --noproxy "*" -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1")" ]; then
465 + if curl --fail -s --connect-timeout 1 -m 3 --noproxy "*" -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1" | grep -sq computeMetadata; then
466 CLOUD_TYPE="GCP"
467 CLOUD_INSTANCE_TYPE="$(curl --fail -s --connect-timeout 1 -m 3 --noproxy "*" -H "Metadata-Flavor: Google" "http://metadata.google.internal/computeMetadata/v1/instance/machine-type")"
468 [ -n "$CLOUD_INSTANCE_TYPE" ] && CLOUD_INSTANCE_TYPE=$(basename "$CLOUD_INSTANCE_TYPE")