Home

Awesome

Sidecar Executor

Run Docker containers on Mesos with Sidecar service discovery! We're running it with HubSpot's Singularity scheduler.

This is a Mesos executor that integrates with the service discovery platform Sidecar to more tightly tie Sidecar into the Mesos ecosystem. The main advantage is that the executor leverages the service health checking that Sidecar already provides in order to fail Mesos tasks quickly when they have gone off the rails.

With Sidecar and Sidecar Executor you get service health checking unified with service Discovery, regardless of which Mesos scheduler you are running. The system is completely scheduler agnostic to the extent possible.

Note that unlike Sidecar, Sidecar Executor assumes that tasks are to be run as Docker containers. You may of course still integrate non-Dockerized services with Sidecar as normal.

Subset of Features

This executor does not attempt to support every single option that Docker can support for running containers. It supports the core feature set that most people actually use. If you are looking for something that it doesn't currently provide, pull requests or feature requests are welcome.

Currently supported:

This set of features probably supports most of the production containers out there.

Debugability

This executor tries to expose as much information as possible to help with the painful task of debugging a Mesos task failure. It logs each of the actions that it takes and why. And, on startup it logs both the current environment variables which the executor will run with, the settings for the executor, and the Docker environment that will be supplied to the container. This can be critical in understanding how a task failed.

When a task fails or is killed, the executor will fetch the last logs that were sent to the container, and copy them to its own stdout and stderr. This means that in most cases the Mesos logs will now contain the failure messages and there is usually no need to dig further into logging frameworks to find out what happened.

Additionally since each instance of the executor manages a single container, the process name of the executor that shows up in ps output contains both the ID of the Docker container and the Docker image name that was used to start it.

Running the Executor

A separate copy of the executor is started for each task. The binary is small and only uses a few MB of memory so this is fairly cheap.

But, since the executor will always be running as long as your task, it will have the file open and you won't be ablet to replace it (e.g. to upgrade) while the task is running. It's thus recommended that you run the executor.sh script as the actual executor defined in each of your tasks. That will in turn copy the binary from a location of your choosing to the task's sandbox and then execute it from there. This means that the copy of the executor used to start the task will remain in the sandbox directory for the life of the task and solves the problem nicely.

To upgrade the executor you can then simply replace the binary in the defined location on your systems and any new tasks will start under the new copy while older tasks remain running under their respective version. By default the shell script assumes the path will be /opt/mesos/sidecar-executor.

Configuration

Each task can be run with its own executor configuration. This is helpful when in situations such as needing to delay health checking for apps that are slow to start, allowing for longer grace periods or a larger failure count before shooting a container. You may configure the executor via environment variables in the Mesos task. These will then be present for the executor at the time that it runs. Note that these are separate from the environment variables used in the Docker container. Currently the settings available are:

SettingDefault
KillTaskTimeout5 (seconds)
HttpTimeout2s
SidecarRetryCount5
SidecarRetryDelay3s
SidecarUrlhttp://localhost:7777/state.json
SidecarBackoff1m
SidecarPollInterval30s
SidecarMaxFails3
SidecarDrainingDuration10s
SeedSidecarfalse
DockerRepositoryhttps://index.docker.io/v1/
LogsSince3m
ForceCpuLimitfalse
ForceMemoryLimitfalse
UseCpuSharesfalse
Debugfalse
MesosMasterPort5050
RelaySyslogfalse
RelaySyslogStartupOnlyfalse
RelaySyslogStartupTime1m
SyslogAddr127.0.0.1:514
ContainerLogsStdoutfalse
SendDockerLabels[]
LogHostnameSystem Hostname

All of the environment variables are of the form EXECUTOR_SIDECAR_RETRY_DELAY where all of the CamelCased words are split apart, and each setting is prefixed with EXECUTOR_.

Special AWS Role Configuration

In addition to all the executor level settings above, you may also pass the following env vars into the executor to enable the executor to maintain AWS creds with a specific role via Vault:

Vault Configuration

Because the executor uses the Vault library, it lets the Vault client configure itself from its own environment settings. You can look these up in the Vault source if you'd like to see them all. The executor adds a couple of others to better control the Vault integration. You should specify at least the following:

WARNING If you are using Vault, you really want to have the executor cache tokens to a VAULT_TOKEN_FILE. If not you can build up quite a lot of tokens in Vault, and that doesn't work well. Especially in a fast job failure scenario where executors running on multiple machines might be generating tokens constantly.

Configuring Docker Connectivity

Sidecar Executor supports all the normal environment variables for configuring your connection to the Docker daemon. It will look for DOCKER_HOST, etc in the runtime environment and configure connectivity accordingly.

Contributing

Contributions are more than welcome. Bug reports with specific reproduction steps are great. If you have a code contribution you'd like to make, open a pull request with suggested code.

Pull requests should:

Ping us to let us know you're working on something interesting by opening a GitHub Issue on the project.