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

Bind mounting MFEs fails on dev #711

Closed
moonesque opened this issue Jul 24, 2022 · 1 comment · Fixed by #713
Closed

Bind mounting MFEs fails on dev #711

moonesque opened this issue Jul 24, 2022 · 1 comment · Fixed by #713
Labels
bug Bugs will be investigated and fixed as quickly as possible.

Comments

@moonesque
Copy link

moonesque commented Jul 24, 2022

This bug has been reported on tutor-mfe but I believe it concerns tutor not tutor-mfe.

Bug description
Running tutor dev start --mount=<MFE_PATH> <MFE_NAME> results in docker-compose error. Please find the output for the command regarding the profile MFE from the tutor-mfe readme in the How to reproduce section below.
I've tried the command using both syntaxes of --mount, running the commands in the frontend-app-profile directory:
tutor dev start --mount=profile:.:/openedx/app
and
tutor dev start --mount=. profile

How to reproduce
command: tutor dev start --mount=. profile
output:

Bind-mount: /home/mahan/projects/avid/mfe-dev/frontend-app-profile -> /openedx/app in profile
docker-compose -f /home/mahan/projects/avid/mfe-dev/tutor-13.3.1/env/local/docker-compose.yml -f /home/mahan/projects/avid/mfe-dev/tutor-13.3.1/env/local/docker-compose.prod.yml -f /home/mahan/projects/avid/mfe-dev/tutor-13.3.1/env/local/docker-compose.tmp.yml --project-name tutor_local stop
ERROR: The Compose file is invalid because:
Service profile has neither an image nor a build context specified. At least one must be provided.
Error applying action 'compose:project:started': func=<function _stop_on_dev_start at 0x7f2ce7811a60> contexts=[]'
Error: Command failed with status 1: docker-compose -f /home/mahan/projects/avid/mfe-dev/tutor-13.3.1/env/local/docker-compose.yml -f /home/mahan/projects/avid/mfe-dev/tutor-13.3.1/env/local/docker-compose.prod.yml -f /home/mahan/projects/avid/mfe-dev/tutor-13.3.1/env/local/docker-compose.tmp.yml --project-name tutor_local stop

mfe plugin is installed and enabled.

Environment
Ubuntu 20.04
Tutor version: 13.3.1
tutor-mfe version: 13.0.6

Additional context
The problem seems to be that running tutor dev start triggers _stop_on_dev_start (code) which in turns calls self.__update_docker_compose_tmp() (code) on the runner which populates /env/local/docker-compose.tmp.yml with the volume configuration:

 services:
   profile:
     volumes:
     - /home/mahan/projects/avid/mfe-dev/frontend-app-profile:/openedx/app
 version: '3.7'

But since the profile mfe service is not defined in the /env/local/docker-compose.prod.yml docker-compose sees the service definition as insufficient.
I've gone through this PR by @kdmccormick which seems closely related.
I'm thinking a solution would be that services must only be added to docker-compose.tmp.yml files if such service exists in non temp files.

@moonesque moonesque changed the title Bind mounting MFEs failure on dev Bind mounting MFEs fails on dev Jul 24, 2022
@regisb regisb added the bug Bugs will be investigated and fixed as quickly as possible. label Jul 25, 2022
@regisb
Copy link
Contributor

regisb commented Jul 25, 2022

I'm currently working on a fix to this issue. In the meantime, it seems to me that Compose v2 is not affected by this issue. On my machine, I use docker compose instead of docker-compose (note the missing dash) and the issue does not occur. Thus, as a temporary fix, you may install Compose as a Docker plugin and define the TUTOR_USE_COMPOSE_SUBCOMMAND environment variable:

export TUTOR_USE_COMPOSE_SUBCOMMAND=1

Of course this would only be a temporary fix.

Cc @dagg who might be interested in this.

regisb added a commit that referenced this issue Jul 25, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close #711. Close also overhangio/tutor-mfe#57.
regisb added a commit that referenced this issue Jul 25, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close #711. Close also overhangio/tutor-mfe#57.
regisb added a commit that referenced this issue Jul 25, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close #711. Close also overhangio/tutor-mfe#57.
regisb added a commit that referenced this issue Jul 29, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close #711. Close also overhangio/tutor-mfe#57.
regisb added a commit that referenced this issue Jul 29, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close #711. Close also overhangio/tutor-mfe#57.
regisb added a commit that referenced this issue Jul 29, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close #711. Close also overhangio/tutor-mfe#57.
regisb added a commit that referenced this issue Jul 29, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close #711. Close also overhangio/tutor-mfe#57.
moonesque pushed a commit to edSPIRIT/tutor that referenced this issue Jul 31, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close overhangio#711. Close also overhangio/tutor-mfe#57.
moonesque pushed a commit to edSPIRIT/tutor that referenced this issue Jul 31, 2022
The -m/--mount option makes it possible to bind-mount volumes at runtime. The
volumes are declared in a local/docker-compose.tmp.yml file. The problem with
this approach is when we want to bind-mount a volume to a service which is
specific to the dev context. For instance: the "learning" service when the MFE
plugin is enabled.

In such a case, starting the service triggers a call to `docker-compose stop`
in the local context. This call fails because the "learning" service does not
exist in the local context. Note that this issue only seems to occur with
docker-compose v1.

To resolve this issue, we create two additional filters for
the dev context, which emulate the behaviour of the local context. With this approach, we convert the -m/--mount arguments right after they are parsed. Because they are parsed just once, we can get rid of the de-duplication logic initially introduced with the COMPOSE_CLI_MOUNTS context.

Close overhangio#711. Close also overhangio/tutor-mfe#57.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs will be investigated and fixed as quickly as possible.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants