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

Improved plugable component architecture #64

Merged
merged 12 commits into from
Aug 25, 2020
Merged

Conversation

tlvu
Copy link
Collaborator

@tlvu tlvu commented Aug 5, 2020

Before this PR, components needing default values, needing template variable substitution, needing to execute commands pre and post docker-compose up are hardcoding their needs directly to the "core" system, basically "leaking" their requirements out even when they are not activated (fixes #62).

This PR provides true plugable architecture for the components so they can provide all their needs without having to modify the code of the "core" system.

All the components (monitoring, generic_bird, emu, testthredds) are modified to leverage the new plugable architecture, with additional customizations given it is cleaner/easier to have default configuration values.

Given this PR both changes the architecture and modify many components at the same time, it is best to read each commit separately to easier understand which code change belongs to which "goal".

Deployed here https://lvupavicsmaster.ouranos.ca with all the impacted components activated to test the change:

tlvu added 10 commits August 3, 2020 18:20
All the other scripts that source default.env do not need to source each
component default.env since those scripts are not component specific so
should not rely on config env from each components.  This can change in
the future.
Could not move PAVICS_FQDN_PUBLIC since it depends on PAVICS_FQDN in
env.local.

default.env must not depend on any vars from env.local.
…t enabled

Achieved by adding to the templating required vars list only if
"monitoring" component is enabled in EXTRA_CONF_DIRS.
…component

Also move defaults in generic_bird/docker-compose-extra.yml into
generic_bird/default.env to centralize them all.
…ontained component

Emu is also "generalized" like generic_bird, it can be used to deploy
another bird.  Only difference vs generic_bird is that Emu do not have a
postgres DB.
Also make original thredds entrypointwrapper customization to also work
with testthredds.

Force default testthredds image to be same as regular thredds.
All changes are inside testthredds component, sweet first new
improvement leveraging the improved plugable architecture.
@tlvu tlvu requested review from dbyrns and moulab88 August 5, 2020 04:00
Copy link
Collaborator

@dbyrns dbyrns left a comment

Choose a reason for hiding this comment

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

Looks good and I appreciate keeping extra stuff aside.
I see more and more image name moving from the compose file to an env, what is the rational for this? (My fear is for the component tracking system with auto PR that will have a hard time to update the image version)
Also if you are not in a rush before your vacation, I would like that Mathieu take a look at this PR too.


# Re-read env.local to make sure it can override ALL defaults from all
# components.
[ -f env.local ] && . ./env.local
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should indicate the priority of all those envs file somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same priority as before with the docker-compose-extra.yml fragment

# Last dir/docker-compose fragment in the list have highest override precedence.
# Ex: last docker-compose volume mount to same destination win over the
# previous docker-compose volume mount.

I can elaborate a little bit more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done be1581a

@tlvu
Copy link
Collaborator Author

tlvu commented Aug 5, 2020

I see more and more image name moving from the compose file to an env, what is the rational for this? (My fear is for the component tracking system with auto PR that will have a hard time to update the image version)

The reason for image moving from the docker-compose.yml into the default.env file is for multiple components to be able to refer to the same image (ex: thredds and testthredds, finch and generic_bird).

I also found an unexpected benefit to this, having the image in the default.env file means it can be overridden by env.local which in turns means we can quickly deploy new image without even committing code (just override the value in default.env in env.local). Useful for emergency fix not having to wait for PR approval or on test machine to test new build without having to modify the code. New Jupyter image is deployed to our staging Medus even before the PR is merged via this override mechanism.

For the future auto image update detection, maybe we can move all images into the default.env file and the tool will lookup for a list of image variable to scan for update, something like IMAGES_TO_UPDATE='$FINCH_IMAGE $THREDDS_IMAGE ... and so on.

Also if you are not in a rush before your vacation, I would like that Mathieu take a look at this PR too.

I wanted to add @matprov as reviewer but he was not in the list of contributor for this repo so I sent him an invite last night already.

@dbyrns
Copy link
Collaborator

dbyrns commented Aug 5, 2020

I wanted to add @matprov as reviewer but he was not in the list of contributor for this repo so I sent him an invite last night already.

Thank you for that.

Comment on lines -28 to -29
$ALERTMANAGER_ADMIN_EMAIL_RECEIVER
$SMTP_SERVER
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 on this one
I was wondering why these variable needed to be defined even if monitoring wasn't enabled.
This offers more flexibility, great.

Comment on lines +23 to +28
if [ -z "$WANTED_CONTEXT_ROOT" ]; then
WANTED_CONTEXT_ROOT="twitcher/ows/proxy/thredds"
fi
if [ -z "$WANTED_CONTEXT_ROOT_WARFILE_NAME" ]; then
WANTED_CONTEXT_ROOT_WARFILE_NAME="twitcher#ows#proxy#thredds"
fi
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure of both variable names starting with WANTED_.
Would only CONTEXT_ROOT do the job instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Existing variable name, I did not want to change the existing code too much. There is EXISTING_CONTEXT_ROOT and this WANTED_CONTEXT_ROOT. Does this naming really bother you a lot?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not at all. Seemed strange when I first saw it but I would probably not even notice if I haven't reviewed this part.

Comment on lines +55 to +67
# Last dir/component in the EXTRA_CONF_DIRS list have highest override
# precedence, example:
#
# * Last docker-compose volume mount to same destination win over the
# previous docker-compose volume mount.
#
# * Last default.env can change the values of all previous default.env.
#
# * Last pre/post docker-compose-up script can potentially undo actions
# from previous scripts.
#
# Suggested to keep the private-config-repo last in the list to be able to
# override anything.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for specifying.
It is worth mentioning since with the pre/post hooks and custom configs, precedence can become tricky at a certain point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. The variable names in each component default.env file should not collide else one will override the other one. Probably not an issue for components in this repo but if we pull in components from other repos, this might become an issue.

@matprov
Copy link
Collaborator

matprov commented Aug 24, 2020

The reason for image moving from the docker-compose.yml into the default.env file is for multiple components to be able to refer to the same image (ex: thredds and testthredds, finch and generic_bird).

I also found an unexpected benefit to this, having the image in the default.env file means it can be overridden by env.local which in turns means we can quickly deploy new image without even committing code

Great benefits. Of course we need to manually update the env.local to contain the updated versions specified in default.env. Simple solution is to comment image versions overrides in env.local to use the ones from default.env. @dbyrns Looking at our multiple projects using compose.sh scripts, I don't see reason why this practice might not be good. Especially for templates overrides, which sometimes require to have the image version to be passed at other places, that version declaration syntax gets pretty useful.

I went through this PR and I agree with the changes, especially the one related to extra config not having to be defined if the extra is not used.

@tlvu Please re-send me the invitation since it was a time limited offer

@tlvu
Copy link
Collaborator Author

tlvu commented Aug 25, 2020

@tlvu Please re-send me the invitation since it was a time limited offer

@matprov Done, also invited you to all the Jenkins related repos.

@tlvu tlvu merged commit cf055cc into master Aug 25, 2020
@tlvu tlvu deleted the true-plugable-components branch August 25, 2020 10:38
@tlvu
Copy link
Collaborator Author

tlvu commented Aug 31, 2020

Tagged 1.11.0 as this is an architecture design change that allows much more freedom and increased capabilities for the components.

@tlvu
Copy link
Collaborator Author

tlvu commented Aug 31, 2020

The automated deployment is broken due to the rename of common.env to default.env.

Error in logs:

+ . ./default.env
/tmp/latestdeploy.sh: .: line 124: can't open './default.env': No such file or directory

Easy and one time only work-around is to manually perform a git pull in this birdhouse-deploy checkout, followed by ./deployment/deploy.sh . ./env.local, assuming current path is <birdhouse-deploy checkout>/birdhouse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monitoring settings in env.local is required even if monitoring component is not enabled
3 participants