Skip to content

Commit

Permalink
Writes out new "managed" metadata file with appropriate value (#257)
Browse files Browse the repository at this point in the history
* Adds a new "managed" metadata file

The content of this file will indicate which parts of the infrastructure are
managed by M-Lab. In the case of a "full" site, M-Lab manages both the switch
and machine. For "minimal" deployments M-Lab manages only the machine. For BYOS
deployments, M-Lab manages nothing. For virtual machines M-Lab manages only the
machine.

* Runs write-metadata.server After network.target

write-metadata.service needs to query information from device eth0, so
networking must be up and configured for this to work.

* Adds After=systemd-networkd-wait-online.service

This is an attempt to be sure that eth0 exists before the
write-metadata.service unit runs.

* Makes sure eth0 device exists before running write-metadata.service

* Calculates prefix length in a more robust way

No matter how I tried to order the write-metadata.service systemd unit, eth0
was always not present when the service ran. This change extracts the prefix
length from /proc/cmdline.

* Removes comment that is no longer necessary

* Removes the "none" option for the metadata file "managed"

The "none" option was supposed to account for BYOS deployments, but this repo
and script will not be used for those deployments.
  • Loading branch information
nkinkade committed Mar 20, 2024
1 parent b98b0ab commit 5ccab30
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions configs/stage3_ubuntu/opt/mlab/bin/write-metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,22 @@ mkdir -p $METADATA_DIR

# Write the kernel version
uname -r | tr -d '\n' > $METADATA_DIR/kernel-version

# Write out the metadata value for "managed". This will allow data users to know
# what environment the test was run. For a "full" site M-Lab manages both the
# machine and an upstream switch. For "minimal" deployments M-Lab only manages
# the machine, and nothing upstream.
PREFIX_LEN=$(egrep -o 'epoxy.ipv4=[^ ]+' /proc/cmdline | cut -d= -f2 | cut -d, -f1 | cut -d/ -f 2)
case "$PREFIX_LEN" in
26)
MANAGED="switch,machine"
;;
28|29)
MANAGED="machine"
;;
*)
echo "ERROR: cannot set MANAGED. Unknown prefix length ${PREFIX_LEN}"
MANAGED="unknown"
;;
esac
echo -n "$MANAGED" > $METADATA_DIR/managed
4 changes: 4 additions & 0 deletions configs/virtual_ubuntu/opt/mlab/bin/write-metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ echo -n ${machine_type##*/} > $METADATA_DIR/machine-type
echo -n "PREMIUM" > $METADATA_DIR/network-tier

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

# For virtual machines this indicates that M-Lab manages only the machine and
# none of the infrastructure upstream of it.
echo -n "machine" > $METADATA_DIR/managed

0 comments on commit 5ccab30

Please sign in to comment.