Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump canarie api 1.0.0 #452

Merged
merged 14 commits into from
May 14, 2024
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
6 changes: 3 additions & 3 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.2.2
current_version = 2.3.0
commit = True
tag = False
tag_name = {new_version}
Expand Down Expand Up @@ -30,11 +30,11 @@ search = {current_version}
replace = {new_version}

[bumpversion:file:RELEASE.txt]
search = {current_version} 2024-05-11T03:52:01Z
search = {current_version} 2024-05-14T13:43:50Z
replace = {new_version} {utcnow:%Y-%m-%dT%H:%M:%SZ}

[bumpversion:part:releaseTime]
values = 2024-05-11T03:52:01Z
values = 2024-05-14T13:43:50Z

[bumpversion:file(version):birdhouse/components/canarie-api/docker_configuration.py.template]
search = 'version': '{current_version}'
Expand Down
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@

[//]: # (list changes here, using '-' for each new entry, remove this when items are added)

[2.3.0](https://github.com/bird-house/birdhouse-deploy/tree/2.3.0) (2024-05-14)
------------------------------------------------------------------------------------------------------------------

## Changes

- bump canarie-api version to [1.0.0](https://github.com/Ouranosinc/CanarieAPI/releases/tag/1.0.0)

- This version of canarie-api permits running the proxy (nginx) container independently of the canarie-api
application. This makes it easier to monitor the logs of canarie-api and proxy containers simultaneously and
allows for the configuration files for canarie-api to be mapped to the canarie-api containers where appropriate.

[2.2.2](https://github.com/bird-house/birdhouse-deploy/tree/2.2.2) (2024-05-11)
------------------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generic variables
override SHELL := bash
override APP_NAME := birdhouse-deploy
override APP_VERSION := 2.2.2
override APP_VERSION := 2.3.0

# utility to remove comments after value of an option variable
override clean_opt = $(shell echo "$(1)" | $(_SED) -r -e "s/[ '$'\t'']+$$//g")
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ for a full-fledged production platform.
* - citation
- | |citation|

.. |commits-since| image:: https://img.shields.io/github/commits-since/bird-house/birdhouse-deploy/2.2.2.svg
.. |commits-since| image:: https://img.shields.io/github/commits-since/bird-house/birdhouse-deploy/2.3.0.svg
:alt: Commits since latest release
:target: https://github.com/bird-house/birdhouse-deploy/compare/2.2.2...master
:target: https://github.com/bird-house/birdhouse-deploy/compare/2.3.0...master

.. |latest-version| image:: https://img.shields.io/badge/tag-2.2.2-blue.svg?style=flat
.. |latest-version| image:: https://img.shields.io/badge/tag-2.3.0-blue.svg?style=flat
:alt: Latest Tag
:target: https://github.com/bird-house/birdhouse-deploy/tree/2.2.2
:target: https://github.com/bird-house/birdhouse-deploy/tree/2.3.0

.. |readthedocs| image:: https://readthedocs.org/projects/birdhouse-deploy/badge/?version=latest
:alt: ReadTheDocs Build Status (latest version)
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.2 2024-05-11T03:52:01Z
2.3.0 2024-05-14T13:43:50Z
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
location /canarie/ {
proxy_pass http://127.0.0.1:2000;
proxy_pass http://canarie-api:2000/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $real_scheme;
proxy_set_header X-Script-Name /canarie;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,4 @@ services:
proxy:
volumes:
- ./components/canarie-api/config/proxy/conf.extra-service.d:/etc/nginx/conf.extra-service.d/canarie-api:ro
- ./components/canarie-api/docker_configuration.py:/config/docker_configuration.py
- ./components/canarie-api/entrypoint:/entrypoint:ro
environment:
CANARIE_API_CONFIG_FN: /config/docker_configuration.py
CANARIE_MONITORING_EXTRA_CONF_DIR: ${CANARIE_MONITORING_EXTRA_CONF_DIR}
entrypoint: /entrypoint
- proxy-logs:${PROXY_LOG_DIR}
9 changes: 8 additions & 1 deletion birdhouse/components/canarie-api/default.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Folder inside "proxy" container to drop extra monitoring config
export CANARIE_MONITORING_EXTRA_CONF_DIR="/conf.d"

export PROXY_IMAGE="pavics/canarieapi:0.7.1"
export CANARIE_DOCKER=pavics/canarieapi
export CANARIE_VERSION=1.0.0
export CANARIE_IMAGE='${CANARIE_DOCKER}:${CANARIE_VERSION}'

export DELAYED_EVAL="
$DELAYED_EVAL
CANARIE_IMAGE
"

# add any component that this component requires to run
COMPONENT_DEPENDENCIES="
Expand Down
45 changes: 45 additions & 0 deletions birdhouse/components/canarie-api/docker-compose-extra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: "3.4"

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

services:
canarie-api:
image: ${CANARIE_IMAGE}
container_name: canarie-api
volumes:
- canarie-data:/data/
- ./components/canarie-api/docker_configuration.py:/config/docker_configuration.py:ro
- ./components/canarie-api/entrypoint:/entrypoint:ro
environment:
CANARIE_API_CONFIG_FN: /config/docker_configuration.py
CANARIE_MONITORING_EXTRA_CONF_DIR: ${CANARIE_MONITORING_EXTRA_CONF_DIR}
restart: always
entrypoint: /entrypoint
logging: *default-logging

canarie-api-cron:
image: ${CANARIE_IMAGE}
container_name: canarie-api-cron
depends_on:
- canarie-api
# The volumes and environment should be the same as the canarie-api container except for the proxy-logs volume
volumes:
- canarie-data:/data/
- ./components/canarie-api/docker_configuration.py:/config/docker_configuration.py:ro
- ./components/canarie-api/entrypoint-cron:/entrypoint:ro
- proxy-logs:/logs/:ro # aligns with the DATABASE["access_log"] value in docker_configuration.py.template
environment:
CANARIE_API_CONFIG_FN: /config/docker_configuration.py
CANARIE_MONITORING_EXTRA_CONF_DIR: ${CANARIE_MONITORING_EXTRA_CONF_DIR}
restart: always
entrypoint: /entrypoint
logging: *default-logging

volumes:
canarie-data:
proxy-logs:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much like this PR. It's much cleaner this way that the canarie-api monitoring is separate from the proxy container.

I just wonder why are you using data-volume and not direct persistence on disk. And if you really need to use data-volume, the current way we will lose the data on ./pavics-compose.sh down -v.

To avoid losing data on ./pavics-compose.sh down -v, use external data-volume like the monitoring component.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few reasons...

No other component is storing logs in a persistent manner. I'm not opposed to this but this could be a larger discussion about log retention that isn't related to this PR

the current way we will lose the data on ./pavics-compose.sh down -v

Sure, but are you bringing the stack down with the -v flag often? Personally, I never ever use the -v flag in production for that reason, and I'll delete a volume if needed manually.

I actually find it annoying to have to delete the externally created jupyterhub, prometheus, grafana, etc. volumes when I'm testing and want to start with a blank slate. I personally would actually like to see the externally created volumes become non-external (or a bind-mount from disk) for this reason.

Like I mentioned above, we don't currently have a defined log retention mechanism/policy. I'd love to add one, but maybe we can defer the discussion of how to manage logs when we discuss that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way it is defined currently is the right way.
If a platform maintainer wants to persist the logs at a specific location/drive/bind-mount, they simply need to add the relevant overrides to define the volume.
The flexibility is left up to the maintainer.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but are you bringing the stack down with the -v flag often?

I actually do use -v from time to time. Otherwise, all the anonymous volume are not delete and next up new anonymous volumes will be created and the old anonymous volumes are only deleted with docker volume prune --all.

Here is an example of anonymous volume:

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ logger = logging.getLogger("canarie-api-config")
MY_SERVER_NAME = 'https://${PAVICS_FQDN_PUBLIC}/canarie'

DATABASE = {
'filename': '/opt/local/src/CanarieAPI/stats.db',
'access_log': '/var/log/nginx/access_file.log',
'log_pid': '/var/run/nginx.pid'
'filename': '/data/stats.db',
'access_log': '/logs/${PROXY_LOG_FILE}'
}


Expand Down Expand Up @@ -109,8 +108,8 @@ SERVICES = {
# NOTE:
# Below version and release time auto-managed by 'make VERSION=x.y.z bump'.
# Do NOT modify it manually. See 'Tagging policy' in 'birdhouse/README.rst'.
'version': '2.2.2',
'releaseTime': '2024-05-11T03:52:01Z',
'version': '2.3.0',
'releaseTime': '2024-05-14T13:43:50Z',
'institution': '${SERVER_INSTITUTION}',
'researchSubject': '${SERVER_SUBJECT}',
'supportEmail': '${SUPPORT_EMAIL}',
Expand Down Expand Up @@ -142,8 +141,8 @@ PLATFORMS = {
# NOTE:
# Below version and release time auto-managed by 'make VERSION=x.y.z bump'.
# Do NOT modify it manually. See 'Tagging policy' in 'birdhouse/README.rst'.
'version': '2.2.2',
'releaseTime': '2024-05-11T03:52:01Z',
'version': '2.3.0',
'releaseTime': '2024-05-14T13:43:50Z',
'institution': '${SERVER_INSTITUTION}',
'researchSubject': '${SERVER_SUBJECT}',
'supportEmail': '${SUPPORT_EMAIL}',
Expand Down
9 changes: 0 additions & 9 deletions birdhouse/components/canarie-api/entrypoint
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
#!/bin/sh -x

# hack needed for Boreas and Medus only else cronjob do not fire
# this hack should still work for other deployments
# remove if cause problem with newer version of canarieapi
touch /etc/cron.d/canarieapi-cron

pip install requests-cache

# chain existing cmd
exec /bin/sh -c "\
env >> /etc/environment && \
cron && \
nginx && \
gunicorn -b 0.0.0.0:2000 --workers 1 --log-level=DEBUG --timeout 30 -k gevent canarieapi.wsgi \
"
14 changes: 14 additions & 0 deletions birdhouse/components/canarie-api/entrypoint-cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -x

# hack needed for Boreas and Medus only else cronjob do not fire
# this hack should still work for other deployments
# remove if cause problem with newer version of canarieapi
touch /etc/cron.d/canarieapi-cron

pip install requests-cache

# chain existing cmd
exec /bin/sh -c "\
env >> /etc/environment && \
cron -f
"
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
version: "3.4"

services:
proxy:
canarie-api: &canarie-volumes
volumes:
# NOTE:
# Prefix '0_' to the mounted file name to ensure it is loaded first by 'birdhouse/components/canarie-api/docker_configuration.py'
# This ensures that the alphabetical loading order it defines will first load the default configs, then will load
# the Cowbird config, and then all python configuration within 'optional-components/canarie-api-full-monitoring'.
# It is important to load Cowbird before, as the full monitoring need to know if 'Cowbird' service is added to the
# stack in order to apply the corresponding public endpoint conditionally.
- ./components/cowbird/config/proxy/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/0_cowbird_config.py:ro
- ./components/cowbird/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/0_cowbird_config.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/finch/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/finch_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/geoserver/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/geoserver_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/hummingbird/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/hummingbird_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/jupyterhub/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/jupyterhub_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/magpie/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/magpie_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
7 changes: 7 additions & 0 deletions birdhouse/components/proxy/default.env
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@ export PROXY_ROOT_LOCATION="return 302 https://\$host/jupyter/hub/login;"

export INCLUDE_FOR_PORT_80='$([ x"$ALLOW_UNSECURE_HTTP" = x"True" ] && echo "include /etc/nginx/conf.d/all-services.include;" || echo "include /etc/nginx/conf.d/redirect-to-https.include;")'

export PROXY_LOG_DIR="/var/log/nginx/"
export PROXY_LOG_FILE="access_file.log"
export PROXY_LOG_PATH='${PROXY_LOG_DIR}/${PROXY_LOG_FILE}'

export DELAYED_EVAL="
$DELAYED_EVAL
INCLUDE_FOR_PORT_80
PROXY_LOG_PATH
"

# add any new variables not already in 'VARS' or 'OPTIONAL_VARS' that must be replaced in templates here
Expand All @@ -33,4 +38,6 @@ export OPTIONAL_VARS="
\$INCLUDE_FOR_PORT_80
\$PROXY_READ_TIMEOUT_VALUE
\$PROXY_ROOT_LOCATION
\$PROXY_LOG_FILE
\$PROXY_LOG_PATH
"
2 changes: 1 addition & 1 deletion birdhouse/components/proxy/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ http {
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access_file.log main;
access_log ${PROXY_LOG_PATH} main;

sendfile on;
#tcp_nopush on;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/raven/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/raven_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/stac/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/stac_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/thredds/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/thredds_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/twitcher/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/twitcher_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Comment on lines +3 to +6
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this anchor work when all components are combined into one big compose file?
Doesn't it get overridden by whichever definition was loaded first/last/whatever?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it works, docker compose parses yaml file individually first and then combines them into one big definition. Yaml anchors are applied at the file level.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.4"

services:
# extend proxy configuration with weaver endpoints
proxy:
canarie-api: &canarie-volumes
volumes:
# NOTE:
# Prefix '0_' to the mounted file name to ensure it is loaded first by 'birdhouse/components/canarie-api/docker_configuration.py'
Expand All @@ -12,3 +12,4 @@ services:
# stack in order to apply the corresponding public endpoint conditionally.
- ./components/weaver/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/0_weaver_config.py:ro
- ./components/weaver/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/weaver_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./components/wps_outputs-volume/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/wps_outputs-volume_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./deprecated-components/catalog/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/catalog_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./deprecated-components/flyingpigeon/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/flyingpigeon_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./deprecated-components/frontend/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/frontend_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./deprecated-components/malleefowl/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/malleefowl_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
version: "3.4"
services:
proxy:
canarie-api: &canarie-volumes
volumes:
- ./deprecated-components/phoenix/config/canarie-api/canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/phoenix_canarie_api_monitoring.py:ro
canarie-api-cron: *canarie-volumes
Loading
Loading