Cloudbees Build Acceleration 13.0 introduces receivers, a new server component in the execserver executable that reduces privilege drops (using setuid and setgid to switch to the build user’s credentials) during job execution. The non-receiver version of the execserver performs a privilege drop before every job runs.
On newer versions of the Linux kernel under Red Hat Enterprise Linux, each privilege drop causes NFS caches to be cleared. When running a build that depends on an NFS filesystem, this seriously degrades performance, indicated by excessive NFS access calls.
The receiver component is designed to address this issue. It is dynamically forked off of the execserver the first time a new UID/GID combination is encountered, where the receiver performs the privilege drop once, and then the execserver delegates the job execution to the receiver, which reports back with the results. The receivers are self-contained and shut themselves down if they are without activity for a (configurable) period of time.
| In practice, receivers add very slight delays (on the order of seconds) to job execution and aren’t needed for operations not involving heavy NFS use. |
Enabling receivers
To enable receivers, create a receiver configuration file, receiver.conf, in one of two locations:
-
/var/tmp/receiver.conf -
/opt/ecloud/i686_Linux/conf/receiver.conf(or wherever your installation is located)
Receivers check these locations in order. The first file found becomes the active configuration.
An existing configuration file enables receivers; agents check for it once at startup only. The file’s contents are then read and processed, and any settings in the configuration file are applied. Any unspecified settings use the defaults.
| A blank configuration file enables receivers with all the configuration defaults, which is fine for typical usage. |
When the configuration file is put in place, restart the agents to activate receivers:
sudo /etc/init.d/ecagent restart
Managing socket files
The execserver communicates with receivers via local Unix domain sockets, readable and writable only by root. These socket files are stored in /var/tmp (by default) and are identified by a signature, a string consisting of $(EXECSERVER_PID):$(USER)$(GROUP)$(SUPPLEMENTARY_GROUP_HASH). This allows an execserver to communicate with only the receivers that it created, and distinguish between those created for different sets of credentials.
When a receiver shuts itself down from inactivity, it deletes the corresponding socket file. To manually shut down all receivers and remove all socket files, run sudo execserver --purge. This may cause running builds to fail.
Logging
By default, receivers log at the INFO (and up) level to syslog. You can configure them to write to local log files with the LOG_DIR setting. Receivers don’t perform log rotation for these files, so they must be rotated manually.
Sample configuration file
This is a sample receiver.conf file that shows all of the settings, their defaults, and their meanings:
# receiver.conf -- # # Sample configuration file for the execserver's Linux receiver daemon. # Every key below is set to its built-in default, so this file has no # effect if installed verbatim. # # Format: KEY=value, one per line. Blank lines and lines starting with # '#' are ignored. The mere presence of a receiver.conf is what enables # the receiver; an empty file means "enabled, defaults unchanged." # # receiver.conf is searched for in the following locations, in order; the # first one found is canonical and the rest are not consulted: # # 1. /var/tmp/receiver.conf # 2. <installed configuration directory>/receiver.conf # (e.g., /opt/ecloud/i686_Linux/conf/receiver.conf) # # The first location allows a test image create this file in place # before the agent/execserver is even installed. # # The configuration is only read once, when an execserver process starts # up. Any existing execserver/agent processes must be restarted (a fresh # install or an explicit agent restart) before a new or changed # receiver.conf takes effect -- dropping or editing the file has no # effect on processes already running. # Directory containing the receiver's .sock files. SOCKET_DIR=/var/tmp # Directory for receiver log files. Leave empty to log via syslog instead. LOG_DIR= # syslog identifier passed to openlog() when LOG_DIR is empty. LOG_IDENT=receiver # Filename prefix shared by both socket and log files. FILE_PREFIX=receiver_ # Permission bits (octal) on the created socket file. SOCKET_MODE=0600 # listen() backlog for the receiver's socket. SOCKET_BACKLOG=5 # How long (in seconds) an idle receiver waits before exiting its loop(). IDLE_TIMEOUT_S=300 # Retry count in Sender::prepare() when connecting to/launching a receiver. CONNECT_TRIES=10 # Delay (in microseconds) between connect retries in Sender::prepare(). CONNECT_DELAY_US=50000 # Max time (in milliseconds) to poll for ESRCH after sending X2R_EXIT. EXIT_WAIT_MS=5000 # Poll interval (in milliseconds) used while waiting for ESRCH. EXIT_POLL_INTERVAL_MS=10 # Extra sleep (in milliseconds) after ESRCH is detected, before returning. EXIT_GRACE_MS=50 # SO_RCVTIMEO (in milliseconds) while waiting for R2X_ABORTED. ABORT_TIMEOUT_MS=5000 # Lowest Logger::Level that gets logged. One of: # ALL, SENDER, DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, NONE. MIN_LOG_LEVEL=INFO # Highest Logger::Level that gets logged. Same set of values as above. MAX_LOG_LEVEL=NONE