Skip to content

Commit

Permalink
Add new "instance-type" metadata file to virtual machines (#246)
Browse files Browse the repository at this point in the history
* Populates new instance-type metadata file

We want an explicit way to know whether tests are originating from a
standard GCE VM, or one that is part of a MIG. This change updates the
write-metadatda.sh script to include a check for whether this instances
is part of a MIG or not. If it is, it writes "mig" to the file
/var/local/metadata/instance-type, else it writes "standard" to the
file.

* Fixes metadata URL

* Changes instance-type to loadbalanced and standalone

* Changes instance-type to loadbalanced

This change will create a new metadata file named "loadbalanced" with
content of "true" in the case that this is a MIG instance which is
loadbalanced.
  • Loading branch information
nkinkade authored Oct 12, 2023
1 parent 7bdcb08 commit 2e34ef8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions configs/virtual_ubuntu/opt/mlab/bin/write-metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,18 @@ echo -n ${machine_type##*/} > $METADATA_DIR/machine-type
# unlikely to change this.
echo -n "PREMIUM" > $METADATA_DIR/network-tier

# MIG instances will have an "instance-template" attribute, other VMs will not.
# Record the HTTP status code of the request into a variable. 200 means
# "instance-template" exists and that this is a MIG instance. 404 means it is
# not part of a MIG. We use this below to determine whether to flag this
# instance as loadbalanced.
is_mig=$(
curl "${CURL_FLAGS[@]}" --output /dev/null --write-out "%{http_code}" \
"${METADATA_URL}/attributes/instance-template"
)
if [[ $is_mig == "200" ]]; then
echo -n "true" > $METADATA_DIR/loadbalanced
fi

echo -n $(uname -r) > $METADATA_DIR/kernel-version

0 comments on commit 2e34ef8

Please sign in to comment.