Skip to content

Commit

Permalink
Get rid of mysql-client container
Browse files Browse the repository at this point in the history
This has an impact on plugin hooks. Plugin hooks that needed to run
inside mysql-client now need to run inside mysql container. This
simplifies the deployment, as we no longer have an empty mysql-client
container sitting around.

When mysql is not enabled (ACTIVATE_MYSQL=False) the mysql container is
simply a mysql client.
  • Loading branch information
regisb committed Sep 3, 2019
1 parent 14dd9e5 commit 0c0db78
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 54 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Note: Breaking changes between versions are indicated by "💥".

## Latest

- 💥[Improvement] Get rid of mysql-client container
- [Improvement] Add "local-docker-compose-lms/cms-dependencies" plugin patches
- [Improvement] Use "exec" instead of "run" to initialise local platform

Expand Down
2 changes: 1 addition & 1 deletion tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_render_file(self):
config = {}
tutor_config.merge(config, tutor_config.load_defaults())
config["MYSQL_ROOT_PASSWORD"] = "testpassword"
rendered = env.render_file(config, "hooks", "mysql-client", "init")
rendered = env.render_file(config, "hooks", "mysql", "init")
self.assertIn("testpassword", rendered)

@unittest.mock.patch.object(tutor_config.fmt, "echo")
Expand Down
30 changes: 14 additions & 16 deletions tutor/commands/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def quickstart(root, non_interactive, pullimages_):
start.callback(root, True, [])
click.echo(fmt.title("Database creation and migrations"))
init.callback(root)
echo_platform_info(config)


@click.command(help="Update docker images")
Expand All @@ -62,25 +63,22 @@ def start(root, detach, services):
config = tutor_config.load(root)
docker_compose(root, config, *command, *services)

if detach:
fmt.echo_info("The Open edX platform is now running in detached mode")
http = "https" if config["ACTIVATE_HTTPS"] else "http"
urls = []
if not config["ACTIVATE_HTTPS"] and not config["WEB_PROXY"]:
urls += ["http://localhost", "http://studio.localhost"]
urls.append(
"{http}://{lms_host}".format(http=http, lms_host=config["LMS_HOST"])
)
urls.append(
"{http}://{cms_host}".format(http=http, cms_host=config["CMS_HOST"])
)
fmt.echo_info(
"""Your Open edX platform is ready and can be accessed at the following urls:

def echo_platform_info(config):
fmt.echo_info("The Open edX platform is now running in detached mode")
http = "https" if config["ACTIVATE_HTTPS"] else "http"
urls = []
if not config["ACTIVATE_HTTPS"] and not config["WEB_PROXY"]:
urls += ["http://localhost", "http://studio.localhost"]
urls.append("{http}://{lms_host}".format(http=http, lms_host=config["LMS_HOST"]))
urls.append("{http}://{cms_host}".format(http=http, cms_host=config["CMS_HOST"]))
fmt.echo_info(
"""Your Open edX platform is ready and can be accessed at the following urls:
{}""".format(
"\n ".join(urls)
)
"\n ".join(urls)
)
)


@click.command(help="Stop a running platform")
Expand Down
2 changes: 1 addition & 1 deletion tutor/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def iter_plugin_hooks(self, hook):

def initialise(runner):
fmt.echo_info("Initialising all services...")
runner.run("mysql-client", "hooks", "mysql-client", "init")
runner.run("mysql", "hooks", "mysql", "init")
for plugin_name, hook in runner.iter_plugin_hooks("pre-init"):
for service in hook:
fmt.echo_info(
Expand Down
File renamed without changes.
30 changes: 7 additions & 23 deletions tutor/templates/k8s/deployments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ spec:
persistentVolumeClaim:
claimName: mongodb
{% endif %}
{% if ACTIVATE_MYSQL %}
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -317,7 +316,12 @@ spec:
containers:
- name: mysql
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
{% if ACTIVATE_MYSQL %}
args: ["mysqld", "--character-set-server=utf8", "--collation-server=utf8_general_ci"]
{% else %}
command: ["sh", "-e", "-c"]
args: ["echo 'ready'; while true; do sleep 60; done"]
{% endif %}
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
Expand All @@ -326,35 +330,15 @@ spec:
key: MYSQL_ROOT_PASSWORD
ports:
- containerPort: 3306
{% if ACTIVATE_MYSQL %}
volumeMounts:
- mountPath: /var/lib/mysql
name: data
volumes:
- name: data
persistentVolumeClaim:
claimName: mysql
{% endif %}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-client
labels:
app.kubernetes.io/name: mysql-client
spec:
selector:
matchLabels:
app.kubernetes.io/name: mysql-client
template:
metadata:
labels:
app.kubernetes.io/name: mysql-client
spec:
containers:
- name: mysql
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
command: ["sh", "-e", "-c"]
args: ["echo 'ready'; while true; do sleep 60; done"]
{% endif %}
{% if ACTIVATE_SMTP %}
---
apiVersion: apps/v1
Expand Down
4 changes: 2 additions & 2 deletions tutor/templates/kustomization.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ configMapGenerator:
- name: nginx-config
files:{% for file in "apps/nginx"|walk_templates %}
- {{ file }}{% endfor %}
{% if ACTIVATE_MYSQL %}- name: mysql-config
env: apps/mysql/auth.env{% endif %}
- name: mysql-config
env: apps/mysql/auth.env
{{ patch("kustomization-configmapgenerator") }}

{{ patch("kustomization") }}
18 changes: 7 additions & 11 deletions tutor/templates/local/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,18 @@ services:
- ../../data/mongodb:/data/db
{% endif %}

{% if ACTIVATE_MYSQL %}
mysql:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
{% if ACTIVATE_MYSQL %}
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
{% else %}
entrypoint: ["sh", "-e", "-c"]
command: ["echo 'ready'; while true; do sleep 60; done"]
{% endif %}
restart: unless-stopped
volumes:
- ../../data/mysql:/var/lib/mysql
env_file: ../apps/mysql/auth.env
{% endif %}
mysql-client:
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_MYSQL }}
entrypoint: ["sh", "-e", "-c"]
command: ["echo 'ready'; while true; do sleep 60; done"]
restart: unless-stopped
{% if ACTIVATE_MYSQL%}depends_on:
- mysql{% endif %}

{% if ACTIVATE_ELASTICSEARCH %}
elasticsearch:
Expand Down Expand Up @@ -123,11 +119,11 @@ services:
- ../../data/lms:/openedx/data
- ../../data/openedx-media:/openedx/media
depends_on:
- mysql
{% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %}
{% if ACTIVATE_FORUM %}- forum{% endif %}
{% if ACTIVATE_MEMCACHED %}- memcached{% endif %}
{% if ACTIVATE_MONGODB %}- mongodb{% endif %}
{% if ACTIVATE_MYSQL %}- mysql{% endif %}
{% if ACTIVATE_RABBITMQ %}- rabbitmq{% endif %}
{% if ACTIVATE_SMTP %}- smtp{% endif %}
{{ patch("local-docker-compose-lms-dependencies")|indent(6) }}
Expand All @@ -147,10 +143,10 @@ services:
- ../../data/cms:/openedx/data
- ../../data/openedx-media:/openedx/media
depends_on:
- mysql
{% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %}
{% if ACTIVATE_MEMCACHED %}- memcached{% endif %}
{% if ACTIVATE_MONGODB %}- mongodb{% endif %}
{% if ACTIVATE_MYSQL %}- mysql{% endif %}
{% if ACTIVATE_RABBITMQ %}- rabbitmq{% endif %}
{% if ACTIVATE_SMTP %}- smtp{% endif %}
{{ patch("local-docker-compose-cms-dependencies")|indent(6) }}
Expand Down

0 comments on commit 0c0db78

Please sign in to comment.