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

decrease optional var logging level and allow to pass extra opts to pavics-compose.sh up -d #426

Merged
merged 11 commits into from
Mar 6, 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.1.0
current_version = 2.1.1
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-02-23T20:32:41Z
search = {current_version} 2024-03-06T22:15:17Z
replace = {new_version} {utcnow:%Y-%m-%dT%H:%M:%SZ}

[bumpversion:part:releaseTime]
values = 2024-02-23T20:32:41Z
values = 2024-03-06T22:15:17Z

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

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

[2.1.1](https://github.com/bird-house/birdhouse-deploy/tree/2.1.1) (2024-03-06)
------------------------------------------------------------------------------------------------------------------

## Changes

- logging: decrease logging level for empty optional vars from WARN to DEBUG

To avoid drowning real WARN messages. Many optional vars can be valid if empty.

- config: add sample config to configure docker-compose to remove orphans

To remove orphans containers when components are disabled. Also link to full
documentations if other env var can be used.

- compose script: allow to pass extra options to `up` operation

The previous docker-compose built-in env var was not working so had to add
this homegrown solution.

When disabling components, their existing containers will not be removed
unless option `--remove-orphans` is given together with `./pavics-compose.sh up -d`.

This change allow any additional options, not just `--remove-orphans`.

- compose script: exit early when any errors occurred during invocation

Before, all the `post-docker-compose-up` would still execute after
`docker-compose` has an error.


[2.1.0](https://github.com/bird-house/birdhouse-deploy/tree/2.1.0) (2024-02-23)
------------------------------------------------------------------------------------------------------------------

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.1.0
override APP_VERSION := 2.1.1

# 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 @@ -14,13 +14,13 @@ for a full-fledged production platform.
* - releases
- | |latest-version| |commits-since|

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

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

.. |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.1.0 2024-02-23T20:32:41Z
2.1.1 2024-03-06T22:15:17Z
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,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.1.0',
'releaseTime': '2024-02-23T20:32:41Z',
'version': '2.1.1',
'releaseTime': '2024-03-06T22:15:17Z',
'institution': '${SERVER_INSTITUTION}',
'researchSubject': '${SERVER_SUBJECT}',
'supportEmail': '${SUPPORT_EMAIL}',
Expand Down Expand Up @@ -142,8 +142,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.1.0',
'releaseTime': '2024-02-23T20:32:41Z',
'version': '2.1.1',
'releaseTime': '2024-03-06T22:15:17Z',
'institution': '${SERVER_INSTITUTION}',
'researchSubject': '${SERVER_SUBJECT}',
'supportEmail': '${SUPPORT_EMAIL}',
Expand Down
17 changes: 17 additions & 0 deletions birdhouse/env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,20 @@ export CATALOG_PASSWORD="${__DEFAULT__CATALOG_PASSWORD}"
export CATALOG_THREDDS_SERVICE="thredds"
export PHOENIX_PASSWORD="${__DEFAULT__PHOENIX_PASSWORD}"
export PHOENIX_PASSWORD_HASH="${__DEFAULT__PHOENIX_PASSWORD_HASH}"

#############################################################################
# Compose vars
# https://docs.docker.com/compose/environment-variables/envvars/
# https://docs.docker.com/compose/environment-variables/envvars-precedence/
# https://docs.docker.com/engine/reference/commandline/cli/#environment-variables
#############################################################################

# Remove orphans containers, useful when disabling components.
# Harmless when left enabled all the time.
# Not working at the time of this writing, see https://github.com/docker/compose/issues/11374.
# Use COMPOSE_UP_EXTRA_OPTS below as a work-around.
#export COMPOSE_REMOVE_ORPHANS=true

# Extra options for 'pavics-compose.sh up'.
# --remove-orphans useful when disabling components. Harmless when left enabled all the time.
#export COMPOSE_UP_EXTRA_OPTS="--remove-orphans"
10 changes: 9 additions & 1 deletion birdhouse/pavics-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ if [ x"$1" = x"info" ]; then
exit 0
fi

COMPOSE_EXTRA_OPTS=""

if [ x"$1" = x"up" ]; then
COMPOSE_EXTRA_OPTS="${COMPOSE_UP_EXTRA_OPTS}"
for adir in $ALL_CONF_DIRS; do
COMPONENT_PRE_COMPOSE_UP="$adir/pre-docker-compose-up"
if [ -x "$COMPONENT_PRE_COMPOSE_UP" ]; then
Expand All @@ -115,9 +118,14 @@ if [ x"$1" = x"up" ]; then
done
fi

log INFO "Executing docker-compose with extra options: $* ${COMPOSE_EXTRA_OPTS}"
# the PROXY_SECURE_PORT is a little trick to make the compose file invalid without the usage of this wrapper script
PROXY_SECURE_PORT=443 HOSTNAME=${PAVICS_FQDN} docker-compose ${COMPOSE_CONF_LIST} $*
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should there be some kind of duplicate filtering, or we simply let the command fail with any (possibility ambiguous) error message?
For example, COMPOSE_EXTRA_OPTS="-d" and the user does pavics-compose up -d by mistake.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, yes double -d do not work ! Weird ! Which reason would motivate such a strict cli args parsing !

Copy link
Collaborator

Choose a reason for hiding this comment

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

Often CLI libraries support duplicating flags to increase some level. For example, -v means verbose level 1 and -v -v means verbose level 2.
Differentiating between options that support this duplication and those that don't are important to these argument parsing libraries.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right ! But activating this "strict count" for all options seems excessive !

PROXY_SECURE_PORT=443 HOSTNAME=${PAVICS_FQDN} docker-compose ${COMPOSE_CONF_LIST} $* ${COMPOSE_EXTRA_OPTS}
ERR=$?
if [ ${ERR} -gt 0 ]; then
log ERROR "docker-compose error, exit code ${ERR}"
exit ${ERR}
fi

# execute post-compose function if exists and no error occurred
type post-compose 2>&1 | grep 'post-compose is a function' > /dev/null
Expand Down
2 changes: 1 addition & 1 deletion birdhouse/read-configs.include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ check_default_vars() {
result=`echo "${d}" | grep -c "${default}"`
if [ -z "`eval "echo ${v}"`" ]
then
log WARN "Optional variable [${n}] is not set. Check env.local file."
log DEBUG "Optional variable [${n}] is not set. Check env.local file."
fi
if [ "${result}" -gt 0 ]
then
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
# built documents.
#
# The short X.Y version.
version = '2.1.0'
version = '2.1.1'
# The full version, including alpha/beta/rc tags.
release = '2.1.0'
release = '2.1.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
Loading