Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,38 @@

## Changes

- Make docker compose logging options configurable

Introduce a new component `components/logging` that sets default logging options for all docker
compose services started by `birdhouse-deploy`. This component is enabled by default.

The default value is set by the `BIRDHOUSE_DOCKER_LOGGING_DEFAULT` environment variable. To change the default
value, set the `BIRDHOUSE_DOCKER_LOGGING_DEFAULT` to a JSON string in the local environment file that contains
a valid
[docker compose logging configuration](https://docs.docker.com/reference/compose-file/services/#logging).

For example, to set the default driver to "local" set the following in your local environment file:

```sh
export BIRDHOUSE_DOCKER_LOGGING_DEFAULT='{"driver": "local"}'
```

You can also override logging options for a single service using environment variables using a variable
`BIRDHOUSE_DOCKER_LOGGING_<service_name>` where `<service_name>` is the uppercase name of the docker compose
service with hyphens replaced with underscores. For example, to set the default driver to "local" only for the
`weaver-worker` service:

```sh
export BIRDHOUSE_DOCKER_LOGGING_WEAVER_WORKER='{"driver": "local"}'
```

Logging options can can also be set directly in a component's ``docker-compose-extra.yml`` file.
The order of precedence for logging options are as follows:

1. logging options specified by `BIRDHOUSE_DOCKER_LOGGING_<service_name>` environment variable
2. logging options set in a `docker-compose-extra.yml` file
3. logging options specified by `BIRDHOUSE_DOCKER_LOGGING_DEFAULT` environment variable

- Add script that automatically updates postgres databases to a later version

In anticipation of upgrading postgres databases in the future, this introduces a script that automatically
Expand Down
33 changes: 33 additions & 0 deletions birdhouse/components/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1040,3 +1040,36 @@ How to Enable the Component
---------------------------

- Do not enable this component directly. It will be enabled as a dependency of other components

logging
=======

Sets default logging options for all docker compose services started by `birdhouse-deploy`.

The default value is set by the ``BIRDHOUSE_DOCKER_LOGGING_DEFAULT`` environment variable. To change the default
value, set the ``BIRDHOUSE_DOCKER_LOGGING_DEFAULT`` to a JSON string in the local environment file that contains
a valid `docker compose logging configuration`_.

For example, to set the default driver to "local" set the following in your local environment file:

.. code::shell

export BIRDHOUSE_DOCKER_LOGGING_DEFAULT='{"driver": "local"}'

You can also override logging options for a single service using environment variables using a variable
``BIRDHOUSE_DOCKER_LOGGING_<service_name>`` where ``<service_name>`` is the uppercase name of the docker compose service
with hyphens replaced with underscores. For example, to set the default driver to "local" only for the ``weaver-worker``
service:

.. code::shell

export BIRDHOUSE_DOCKER_LOGGING_WEAVER_WORKER='{"driver": "local"}'

Logging options can can also be set directly in a component's ``docker-compose-extra.yml`` file. The order of
precedence for logging options are as follows:

1. logging options specified by ``BIRDHOUSE_DOCKER_LOGGING_<service_name>`` environment variable
2. logging options set in a ``docker-compose-extra.yml`` file
3. logging options specified by ``BIRDHOUSE_DOCKER_LOGGING_DEFAULT`` environment variable

.. _docker compose logging configuration: https://docs.docker.com/reference/compose-file/services/#logging
10 changes: 0 additions & 10 deletions birdhouse/components/canarie-api/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
canarie-api:
image: ${CANARIE_IMAGE}
Expand All @@ -19,7 +11,6 @@ services:
CANARIE_MONITORING_EXTRA_CONF_DIR: ${CANARIE_MONITORING_EXTRA_CONF_DIR}
restart: always
entrypoint: /entrypoint
logging: *default-logging
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:2000"]
interval: 60s
Expand All @@ -44,7 +35,6 @@ services:
CANARIE_MONITORING_EXTRA_CONF_DIR: ${CANARIE_MONITORING_EXTRA_CONF_DIR}
restart: always
entrypoint: /entrypoint
logging: *default-logging

volumes:
canarie-data:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
canarie-api: &canarie-volumes
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
cowbird:
environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
# extend Magpie permissions to grant access to Cowbird API via secured Twitcher proxy
magpie:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
# extend proxy with endpoint and config for Cowbird API access
proxy:
Expand Down
11 changes: 0 additions & 11 deletions birdhouse/components/cowbird/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
cowbird:
image: ${COWBIRD_IMAGE_API}
Expand Down Expand Up @@ -43,7 +35,6 @@ services:
- ./components/cowbird/config/cowbird/celeryconfig.py:/opt/local/src/cowbird/config/celeryconfig.py
- "${BIRDHOUSE_DATA_PERSIST_SHARED_ROOT}:${BIRDHOUSE_DATA_PERSIST_SHARED_ROOT}"
restart: always
logging: *default-logging
healthcheck:
test: ["CMD", "wget", "-qO-", "http://0.0.0.0:7000"]
interval: 60s
Expand Down Expand Up @@ -79,7 +70,6 @@ services:
- ./components/cowbird/config/cowbird/celeryconfig.py:/opt/local/src/cowbird/config/celeryconfig.py
- "${BIRDHOUSE_DATA_PERSIST_SHARED_ROOT}/${USER_WORKSPACES}:${BIRDHOUSE_DATA_PERSIST_SHARED_ROOT}/${USER_WORKSPACES}"
restart: always
logging: *default-logging
# TODO: create a stable healthcheck for this service (`inspect ping` or `status` is not reliable)

# Dedicated database for Cowbird, since other 'mongodb' image does not employ the same version.
Expand All @@ -91,7 +81,6 @@ services:
volumes:
- ${COWBIRD_MONGODB_DATA_DIR}:/data/db
restart: always
logging: *default-logging
healthcheck:
test: ["CMD", "mongo", "--eval", "print('connected')"]
interval: 60s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
magpie:
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
# extend twitcher with MagpieAdapter hooks employed for DGGS proxied requests
twitcher:
Expand Down
9 changes: 0 additions & 9 deletions birdhouse/components/dggs/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
dggs:
container_name: dggs
Expand Down Expand Up @@ -46,7 +38,6 @@ services:
# The volume is mounted read-write to allow creation of temporary/cache files by the service to accelerate access.
- ${DGGS_DATA_DIR}:/data/dggs:rw
restart: always
logging: *default-logging
healthcheck:
test: [
"CMD",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
finch:
volumes:
Expand Down
9 changes: 0 additions & 9 deletions birdhouse/components/finch/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
finch:
image: ${FINCH_IMAGE}
Expand All @@ -19,7 +11,6 @@ services:
# - data:/opt/birdhouse/var/lib
- /tmp
restart: always
logging: *default-logging
healthcheck:
test:
[
Expand Down
10 changes: 0 additions & 10 deletions birdhouse/components/geoserver/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
geoserver:
image: ${GEOSERVER_IMAGE}
Expand All @@ -28,7 +20,6 @@ services:
links:
- postgis
restart: always
logging: *default-logging
healthcheck:
test: curl --fail --silent http://localhost:8080/geoserver || exit 1
interval: 1m30s
Expand All @@ -41,4 +32,3 @@ services:
image: pavics/postgis:2.2
container_name: postgis
restart: always
logging: *default-logging
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
hummingbird:
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
hummingbird:
volumes:
Expand Down
9 changes: 0 additions & 9 deletions birdhouse/components/hummingbird/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
hummingbird:
image: ${HUMMINGBIRD_IMAGE}
Expand All @@ -17,7 +9,6 @@ services:
depends_on:
- postgres
restart: always
logging: *default-logging
healthcheck:
test:
[
Expand Down
9 changes: 0 additions & 9 deletions birdhouse/components/jupyterhub/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
jupyterhub:
image: ${JUPYTERHUB_IMAGE}
Expand Down Expand Up @@ -44,7 +36,6 @@ services:
# ensure the deployment does not fail when upgrading Jupyterhub version
command: bash -c "jupyterhub upgrade-db && jupyterhub"
restart: always
logging: *default-logging
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8000/jupyter"]
interval: 60s
Expand Down
2 changes: 2 additions & 0 deletions birdhouse/components/logging/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker-compose-extra-defaults.yml
docker-compose-extra-services.yml
1 change: 1 addition & 0 deletions birdhouse/components/logging/default.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export BIRDHOUSE_DOCKER_LOGGING_DEFAULT='{"driver": "json-file", "options": {"max-size": "50m", "max-file": 10}}'
30 changes: 30 additions & 0 deletions birdhouse/components/logging/pre-docker-compose-up.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env sh

# Note: filename is not docker-compose-extra.yml so that it won't get added prematurely to COMPOSE_CONF_LIST
DEFAULT_COMPOSE_FILE="${COMPOSE_DIR}/components/logging/docker-compose-extra-defaults.yml"
SERVICE_COMPOSE_FILE="${COMPOSE_DIR}/components/logging/docker-compose-extra-services.yml"
echo "services:" > "${DEFAULT_COMPOSE_FILE}"
echo "services:" > "${SERVICE_COMPOSE_FILE}"

SERVICES_ADDED=
for service in $(PROXY_HTTP_PORT=80 HOSTNAME=${BIRDHOUSE_FQDN} ${DOCKER_COMPOSE} ${COMPOSE_CONF_LIST} config --services 2> /dev/null); do
printf ' %s:\n logging: %s\n' "$service" "$BIRDHOUSE_DOCKER_LOGGING_DEFAULT" >> "${DEFAULT_COMPOSE_FILE}"
service_settings="$(eval "echo \$BIRDHOUSE_DOCKER_LOGGING_$(echo $service | tr '-' '_' | tr '[:lower:]' '[:upper:]')")"
[ -n "$service_settings" ] && SERVICES_ADDED=true && printf ' %s:\n logging: %s\n' "$service" "$service_settings" >> "${SERVICE_COMPOSE_FILE}"
done

# Insert DEFAULT_COMPOSE_FILE as the first docker compose file because we want to allow logging settings in later
# docker compose files to override the defaults.
# Append SERVICE_COMPOSE_FILE as the last docker compose file because we want settings in this file to take precedence
# over other options.
log INFO "adding ${DEFAULT_COMPOSE_FILE} to COMPOSE_CONF_LIST"
COMPOSE_CONF_LIST="-f docker-compose.yml -f "${DEFAULT_COMPOSE_FILE}" ${COMPOSE_CONF_LIST#-f[[:space:]]+docker-compose.yml}"

if [ -n "${SERVICES_ADDED}" ]; then
log INFO "adding ${SERVICE_COMPOSE_FILE} to COMPOSE_CONF_LIST"
COMPOSE_CONF_LIST="${COMPOSE_CONF_LIST} -f ${SERVICE_COMPOSE_FILE}"
fi

unset DEFAULT_COMPOSE_FILE
unset SERVICE_COMPOSE_FILE
unset SERVICES_ADDED
10 changes: 0 additions & 10 deletions birdhouse/components/magpie/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
magpie:
image: ${MAGPIE_IMAGE}
Expand Down Expand Up @@ -33,7 +25,6 @@ services:
- ./components/magpie/permissions.cfg:${MAGPIE_PERMISSIONS_CONFIG_PATH}/permissions.cfg
- ./components/magpie/magpie.ini:/opt/local/src/magpie/config/magpie.ini
restart: always
logging: *default-logging
healthcheck:
test: ["CMD", "wget", "-qO-", "http://0.0.0.0:2001"]
interval: 60s
Expand All @@ -54,7 +45,6 @@ services:
- ${MAGPIE_PERSIST_DIR}:/var/lib/postgresql/data/pgdata
- ./components/magpie/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
restart: always
logging: *default-logging
healthcheck:
test: ["CMD", "pg_isready"]
interval: 60s
Expand Down
9 changes: 0 additions & 9 deletions birdhouse/components/mongodb/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@

x-logging:
&default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "10"

services:
mongodb:
image: mongo:3.4.0
Expand All @@ -17,7 +9,6 @@ services:
# Mongodb crash with permission denied errors if the command is not overridden like this
command: bash -c 'chown -R mongodb:mongodb /data && chmod -R 755 /data && mongod'
restart: always
logging: *default-logging
healthcheck:
test: ["CMD", "mongo", "--eval", "print('connected')"]
interval: 60s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
magpie:
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
proxy:
volumes:
Expand Down
1 change: 0 additions & 1 deletion birdhouse/components/monitoring/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

services:
# https://github.com/google/cadvisor/blob/master/docs/running.md
# Collect per container metrics.
Expand Down
Loading