catchpoint / WebPageTest.agent-install

Automated scripts for installing dedicated wptagent instances
Apache License 2.0
10 stars 25 forks source link

Agents fail to start if you don't install all browsers if you use WPT_UPDATE_OS=n and WPT_UPDATE_BROWSERS=y #10

Open rposbo opened 2 years ago

rposbo commented 2 years ago

tl;dr - --only-upgrade fails for uninstalled packages that live in different apt-repositories, so if you've set up your installation using WPT_UPDATE_OS=n and WPT_UPDATE_BROWSERS=y the agent will fail to start

Although theoretically you can call apt install --only-upgrade with all the browsers you might have installed and let it silently ignore those that are not installed, this line fails if you choose to install a subset of the browsers using, e.g., WPT_FIREFOX=false as apt doesn't know about the packages, so it is erroring instead of failing silently: https://github.com/WPO-Foundation/wptagent-install/blob/d9d967271cf9b857bf59c1c9c1a64de424faff10/debian.sh#L603

To replicate on a clean ubuntu 20.04 EC2:

  1. Execute a failing install (this example just using Chrome and Firefox packages)
sudo DEBIAN_FRONTEND=noninteractive apt -yq --only-upgrade -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install google-chrome-stable google-chrome-beta google-chrome-unstable firefox firefox-trunk firefox-esr firefox-geckodriver

Results show failures for Chrome and Firefox, instead of silently ignoring them as they're not installed:

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package google-chrome-stable
E: Unable to locate package google-chrome-beta
E: Unable to locate package google-chrome-unstable
E: Unable to locate package firefox-trunk
E: Unable to locate package firefox-esr
E: Unable to locate package firefox-geckodriver

This causes the agent to fall into an infinite loop, as that line is part of a until loop.

  1. Add the Firefox repository
sudo add-apt-repository -y ppa:ubuntu-mozilla-daily/ppa
sudo add-apt-repository -y ppa:mozillateam/ppa

# and update the package tree
sudo apt -y update
  1. Run the exact same --only-upgrade command again (i.e., referencing both Chrome and Firefox, neither of which are installed, but only Firefox has an apt repository referenced)
sudo DEBIAN_FRONTEND=noninteractive apt -yq --only-upgrade -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install google-chrome-stable google-chrome-beta google-chrome-unstable firefox firefox-trunk firefox-esr firefox-geckodriver

This time only Chrome fails, not Firefox:

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package google-chrome-stable
E: Unable to locate package google-chrome-beta
E: Unable to locate package google-chrome-unstable

These lines mean the apt-repository are unknown to the WPT agent: https://github.com/WPO-Foundation/wptagent-install/blob/d9d967271cf9b857bf59c1c9c1a64de424faff10/debian.sh#L557-L560

Proposed patch

a) Either add all browser's apt repositories regardless of the choice the user has made, or b) Build the list of browsers to update according to the choice the user has made