From 86f276e966e01b037d96a1a87cb6ad1fce18f7cc Mon Sep 17 00:00:00 2001 From: Trevor Bramwell Date: Thu, 28 Jan 2021 09:53:35 -0800 Subject: [PATCH] Skip Metadata Capture on unsupported Clouds Updates the 'capture-instance-metadata.sh' script to skip attempting to capture instance metadata needed for job-cost.sh if the build is being run on an unsupported cloud or platform. Change-Id: I8bfea1416d11de1caeed2d414b90513f63de9b6f Signed-off-by: Trevor Bramwell --- releasenotes/notes/instance-metadata-skip-f80ccdd0a6c696e3.yaml | 6 ++++++ shell/capture-instance-metadata.sh | 5 +++++ 2 files changed, 11 insertions(+) create mode 100644 releasenotes/notes/instance-metadata-skip-f80ccdd0a6c696e3.yaml diff --git a/releasenotes/notes/instance-metadata-skip-f80ccdd0a6c696e3.yaml b/releasenotes/notes/instance-metadata-skip-f80ccdd0a6c696e3.yaml new file mode 100644 index 00000000..6c0b0087 --- /dev/null +++ b/releasenotes/notes/instance-metadata-skip-f80ccdd0a6c696e3.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Updates the 'capture-instance-metadata.sh' script to skip attempting + to capture instance metadata needed for job-cost.sh if the build is + being run on an unsupported cloud or platform. diff --git a/shell/capture-instance-metadata.sh b/shell/capture-instance-metadata.sh index a5914ad9..c102d53c 100644 --- a/shell/capture-instance-metadata.sh +++ b/shell/capture-instance-metadata.sh @@ -17,6 +17,11 @@ if [ -n "${NOMAD_DC}" ]; then exit 0 fi +if [[ ! -f /run/cloud-init/result.json ]]; then + echo "INFO: Running in unsupported cloud, no metadata" + exit 0 +fi + # AWS not supported, exit cloudtype="$(jq -r .v1.datasource /run/cloud-init/result.json)" if [[ $cloudtype == "DataSourceEc2Local" ]]; then -- 2.16.6