Skip Metadata Capture on unsupported Clouds 84/66684/1
authorTrevor Bramwell <tbramwell@linuxfoundation.org>
Thu, 28 Jan 2021 17:53:35 +0000 (09:53 -0800)
committerTrevor Bramwell <tbramwell@linuxfoundation.org>
Thu, 28 Jan 2021 20:36:47 +0000 (12:36 -0800)
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 <tbramwell@linuxfoundation.org>
releasenotes/notes/instance-metadata-skip-f80ccdd0a6c696e3.yaml [new file with mode: 0644]
shell/capture-instance-metadata.sh

diff --git a/releasenotes/notes/instance-metadata-skip-f80ccdd0a6c696e3.yaml b/releasenotes/notes/instance-metadata-skip-f80ccdd0a6c696e3.yaml
new file mode 100644 (file)
index 0000000..6c0b008
--- /dev/null
@@ -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.
index a5914ad..c102d53 100644 (file)
@@ -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