Skip to content

Commit

Permalink
Configures TCP pacing on boot depending on site's uplink speed (#138)
Browse files Browse the repository at this point in the history
* Modifies cloud-config to write two new files to set up TCP pacing and one new service unit file to run the pacing configuration script.

* Removes trying to set net.core.default_qdisc=fq in /etc/sysctl.d, since changes don't need to be persisted since machines reinitialize 100% on every boot anyway. Use replace instead of add in tc command.

* Removes the set-tc-qdisc.service, since this functionality is now handled by the configure-tc-fq.service.

* Adds a better systemd service unit description for configure-tc-fq.service.

* Uses long options with curl. Adds a small echo so that logs should some useful output on success.

* Set maxrate for 1g site to 1gbit, per @stephen-soltesz request in PR.
  • Loading branch information
nkinkade authored Aug 21, 2019
1 parent 948739a commit 6e845af
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions configs/stage3_coreos/resources/cloud-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ coreos:
Type=oneshot
ExecStart=/usr/share/oem/generate_network_config.sh /etc/systemd/network/00-eth0.network
# Replaces eth0's qdisc with fq.
- name: set-tc-qdisc.service
command: start
content: |
[Service]
Type=oneshot
ExecStart=/usr/sbin/tc qdisc replace dev eth0 root fq
# Restarts the networkd service using our new config.
- name: systemd-networkd.service
command: restart
Expand Down Expand Up @@ -174,6 +166,41 @@ coreos:
Type=oneshot
ExecStart=/usr/sbin/modprobe tcp_bbr
# A unit to run the script that configures Fair Queue ("TCP pacing") for eth0.
- name: configure-tc-fq.service
command: start
enable: true
content: |
[Unit]
Description=Configures TCP pacing properly depending on the site's uplink speed
Requires=network-online.target
After=systemd-networkd-wait-online.service systemd-resolved.service format-cache.service
[Service]
Type=oneshot
ExecStart=/opt/bin/configure_tc_fq.sh
write_files:
- path: /opt/bin/configure_tc_fq.sh
permissions: 0744
owner: root:root
content: |
#!/bin/bash
SITE=$(dnsdomainname | cut -d. -f1)
SPEED=$(curl --silent --show-error --location \
https://siteinfo.mlab-oti.measurementlab.net/v1/sites/switches.json \
| jq -r ".${SITE}.uplink_speed")
if [[ "${SPEED}" == "10g" ]]; then
MAXRATE="8gbit"
elif [[ "${SPEED}" == "1g" ]]; then
MAXRATE="1gbit"
else
echo "Unknown uplink speed '${SPEED}'. Not configuring default qdisc for eth0."
exit 1
fi
/sbin/tc qdisc replace dev eth0 root fq maxrate "${MAXRATE}"
echo "Set maxrate for qdisc fq on dev eth0 to: ${MAXRATE}"
# TODO: collect list of ssh keys from a metadata service during post-boot setup.
ssh_authorized_keys:
- "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvIKeMHcEO1xnTmEdMY6E9Y4pBdGBCDXZnuQC5ZPjNQr9IG3ytw0OxwyCObAzSr+WOymYv6Cwm4Ckz2jc/bWygzWJH+DMdldZe7HVQu4YxuegqahIkB0D1OzaZGNctBgTp9bmpWGxyek7U8ff7GTiFqhcms4Oer4rdd0gqUhmv3LnRWQqrIDblrBosHBED/zXgjbOj3beWCA3xHDCaui/gkbmp0J2jzCnlsc7eSI0d6Jro2UhbiS2ssxVQsLViLh5okJJeb2JyzbLbcpselUg9DSwSk0pFH/wHL0usjvBisF/fEP8eQ1svq6N6gncvPlgoJaSvtACmDvIFkU4baA2v pboothe@pboothe3.nyc.corp.google.com"
Expand Down

0 comments on commit 6e845af

Please sign in to comment.