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

MDBF-876 - Remove BuildBot configuration code needed for systemd setup #674

Conversation

RazvanLiviuVarzaru
Copy link
Collaborator

Previously when the BuildBot Production environment was running on systemd services, we couldn't use the .env files defined in the project tree because they were specifically designed for usage in docker-compose.

This led to hard coding variable defaults in the buildbot code, in the form of os.getenv(#env_variable_for_containers#, default=#default_for_systemd#)

In this task:
-> switch to a fail proof approach of loading variables using os.environ which will raise a key not found exception if the environment variable is not defined
-> adapt the GitHub CI script validate_masters to load the environment variables for each environment << dev , prod >>
-> remove "systemd" approach of loading PORTS for masters.

This PR was tested using:
./validate_master_cfg.sh -e {PROD,DEV}
- run docker-compose with .env files

Please see the commit messages for more details.

Copy link
Member

@cvicentiu cvicentiu left a comment

Choose a reason for hiding this comment

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

Overall ok, a few nitpicks. Perhaps the sed command can be removed in validate masters.

define_masters.py Show resolved Hide resolved
docker-compose/.env Show resolved Hide resolved
master-bintars/master.cfg Show resolved Hide resolved
master-docker-nonstandard-2/master.cfg Show resolved Hide resolved
master-private.cfg-sample Show resolved Hide resolved
master-private.cfg-sample Show resolved Hide resolved
utils.py Outdated Show resolved Hide resolved
validate_master_cfg.sh Show resolved Hide resolved
@cvicentiu
Copy link
Member

@RazvanLiviuVarzaru Please push once you make the agreed upon changes. I'll be building on top of this one.

Copy link
Member

@grooverdan grooverdan left a comment

Choose a reason for hiding this comment

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

minor cleanup items.

define_masters.py Show resolved Hide resolved
validate_master_cfg.sh Outdated Show resolved Hide resolved
--env-file behaves differently between docker-compose and docker run.

1. docker run --env-file cannot handle white-spaces and new-line
   Reference: moby/moby#12997
   Workaround:
    -> used one-liners for multi-line variable values
    -> removed unnecessary whitespaces

2. docker run --env-file will preserve single/double quotes
   Reference: docker/cli#3630
   Workaround:
      -> in validate_master script use
         --env-file <(sed "s/='\([^']*\)'/=\1/" $ENVFILE)
         to remove the single quotes
      -> modified .env files to be quote consistent.
      Single quotes for variable value.
      Double quotes for JSON structures inside variable value

Test:
- ./validate_master_cfg.sh -e PROD
- ./validate_master_cfg.sh -e DEV
- run docker-compose and check variable values

The sample master private file was changed for two reasons:
1. If you want to run buildbot locally, MariaDB Server (docker) will run
by default with --skip-name-resolve thus using 127.0.0.1
is mandatory to allow buildbot to connect to the database

2. bb-rhel9-docker entry was added because now the validation scripts
load the specific Dev environment variables for which there's
a different workername for the docker builder
@RazvanLiviuVarzaru RazvanLiviuVarzaru force-pushed the feature/validate-container-environment branch from 4e07bd7 to 986076f Compare January 9, 2025 09:32
Both BuildBot environments now run in containers so we can get rid of the
default="" in << os.getenv >>.
To check that the variable is defined and to prevent typos
use os.environ which would raise a key error if the variable does not exist.

PORT is a special case, because it's defined in docker-compose generation script
and is not present in the .env and .env.dev files, hence the hardcoded value
in the validation script.
Keep os.environ for PORT because the correct value will be passed by
docker-compose during initialization (docker-compose --env-file .env up)
This was the "systemd" approach on BuildBot services
for getting the PORT number.
Now that both environments run in docker containers, the port variable
is exposed to the container environment via docker-compose.
@RazvanLiviuVarzaru RazvanLiviuVarzaru force-pushed the feature/validate-container-environment branch from 986076f to cdcf7c8 Compare January 9, 2025 09:44
@RazvanLiviuVarzaru RazvanLiviuVarzaru merged commit b732992 into MariaDB:dev Jan 9, 2025
4 checks passed
@RazvanLiviuVarzaru
Copy link
Collaborator Author

RazvanLiviuVarzaru commented Jan 9, 2025

@RazvanLiviuVarzaru Please push once you make the agreed upon changes. I'll be building on top of this one.

@cvicentiu
All changes were made and merged.

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

Successfully merging this pull request may close these issues.

3 participants