Codesearch/Admin

codesearch currently runs from the "codesearch" Cloud VPS project (instances). Nagf is helpful to monitor the health of the instance.

Architecture
Each search profile (everything, extensions, skins, etc.) listed are backed by individual instances of Hound, that are controlled by  systemd units. Hound is a go application that is run in a Docker container using an upstream-provided image (TODO: build our own image). A flask web application proxies requests to the individual Hound backends and injects in our customizations. It runs through the  systemd unit.

Everything is puppetized, so puppet will ensure all of the systemd units are running. Note that all of the backend units depend upon the proxy, so restarting the proxy will restart all of the backends.

The larger backends can take up to 15 minutes to start. The start up process can be rather memory and CPU intensive (especially on a truly cold start on a brand new instance), so the wait.py script tries to only allow one backend to start up at once.

The health check page should be helpful in seeing whether the Hound backends are actually down, or just starting up still.

The configuration for each backend is written by the  systemd timer. Each backend's unit is configured to restart every 24 hours, so it picks up the new configuration.

Adding a new search profile/backend
In labs/codesearch:
 * Update  to generate configuration for the new backend
 * Update  with a label for the search profile
 * Example: 565424

In operations/puppet:
 * Update  with the new backend and the next numerical port
 * Example: 567190

The codesearch patch must be merged before the puppet one. Also ensure that the  systemd timer has run before the puppet patch is merged.

Upgrading hound
Codesearch is a wrapper around hound. We deploy Hound using a container image built by the deployment pipeline. To upgrade Hound:

In a checkout of the labs/codesearch Git repo:

Merge the patch in Gerrit, which will trigger the deployment pipeline to build a new image. Once that's done, log into the codesearch instance and run:

Adding a new instance
TODO

Format /srv, then apply puppet role and run puppet, switch over web proxy.