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

♻️🐛 docker engine cleans up volumes when removing dynamic-sidecars #2915

Merged
merged 24 commits into from
Apr 7, 2022

Conversation

GitHK
Copy link
Contributor

@GitHK GitHK commented Mar 22, 2022

What do these changes do?

Previously the docker volume had to be manually removed from the stack. This never worked on multiple node deployments.
Now the docker engine will take care of cleaning it up.

Note: @mguidon as already discussed with you, this has issues with the docker rclone plugin. Since anonymous volumes are created the docker rclone volume plugin spawns 2/3 times the same anonymous volume, but only one of the ends up being used in the end.

Related issue/s

How to test

Checklist

  • Unit tests for the changes exist
  • Runs in the swarm

@GitHK GitHK self-assigned this Mar 22, 2022
@codecov
Copy link

codecov bot commented Mar 22, 2022

Codecov Report

Merging #2915 (88c1da0) into master (8093b42) will decrease coverage by 0.0%.
The diff coverage is 100.0%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #2915     +/-   ##
========================================
- Coverage    79.6%   79.5%   -0.1%     
========================================
  Files         678     681      +3     
  Lines       28353   28385     +32     
  Branches     3655    3657      +2     
========================================
+ Hits        22578   22594     +16     
- Misses       5008    5022     +14     
- Partials      767     769      +2     
Flag Coverage Δ
integrationtests 65.7% <100.0%> (-0.2%) ⬇️
unittests 75.2% <100.0%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...tor_v2/modules/dynamic_sidecar/volumes_resolver.py 64.1% <ø> (-20.6%) ⬇️
...service_director_v2/api/routes/dynamic_services.py 88.2% <100.0%> (ø)
...re_service_director_v2/models/schemas/constants.py 100.0% <100.0%> (ø)
...or_v2/modules/db/repositories/projects_networks.py 65.2% <100.0%> (ø)
...c/simcore_service_director_v2/modules/db/tables.py 100.0% <100.0%> (ø)
..._director_v2/modules/dynamic_sidecar/client_api.py 78.4% <100.0%> (ø)
...tor_v2/modules/dynamic_sidecar/scheduler/events.py 93.8% <100.0%> (-1.7%) ⬇️
...e_service_director_v2/modules/projects_networks.py 74.1% <100.0%> (ø)
.../simcore_service_dynamic_sidecar/api/containers.py 88.2% <100.0%> (+0.2%) ⬆️
...ervice_dynamic_sidecar/api/containers_extension.py 89.1% <100.0%> (-0.6%) ⬇️
... and 24 more

@GitHK GitHK added a:director-v2 issue related with the director-v2 service changelog:♻️refactor a:dynamic-sidecar dynamic-sidecar service labels Mar 22, 2022
@GitHK GitHK added this to the E.Shackleton milestone Mar 22, 2022
@GitHK GitHK marked this pull request as ready for review March 23, 2022 06:17
@GitHK GitHK requested a review from mguidon March 23, 2022 07:04


@asynccontextmanager
async def docker_client() -> AsyncGenerator[aiodocker.Docker, None]:
Copy link
Member

@pcrespov pcrespov Mar 24, 2022

Choose a reason for hiding this comment

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

We have this function 5 times in this repository. I wonder if we could put it in some package?

Copy link
Contributor Author

@GitHK GitHK Mar 30, 2022

Choose a reason for hiding this comment

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

Not sure about the others but this one is slightly different from the rest.
If the others have the exact same body and signature maybe we could go for such a thing, but in a different PR.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure? I guess we both have access to the same codebase, right :-) Please verify and create this separate PR if necessary.

@@ -9,6 +9,8 @@
import pytest
from simcore_service_dynamic_sidecar.modules import mounted_fs

pytestmark = pytest.mark.asyncio
Copy link
Member

Choose a reason for hiding this comment

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

@sanderegg, there was a different way to set this now, right?

Copy link
Member

Choose a reason for hiding this comment

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

well I think it depends in this case if the pytest-aiohttp library is installed. in which case I think you can just remove the mark.

Copy link
Member

@pcrespov pcrespov Mar 31, 2022

Choose a reason for hiding this comment

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

@sanderegg pytest-aiohttp is NOT installed but is pytest-asyncio. I thought now it was also automatic .. perhaps i misunderstood some comment you did a while ago

for volume_state_path, state_path in zip(
self.volume_name_state_paths(), self.state_paths
):
yield f"{volume_state_path}:{state_path}"
bind_path: Path = await self._get_bind_path_from_label(volume_state_path)
yield f"{bind_path}:{state_path}"


def setup_mounted_fs() -> MountedVolumes:
Copy link
Member

@pcrespov pcrespov Mar 24, 2022

Choose a reason for hiding this comment

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

There are at least two conventions that are violated here:

  • _mounted_volumes: we discourage using global variables. Use app.state instead. Please read Data Sharing aka No Singleton
  • get_settings(): settings should be also in app.state and init at the same time as the app but a) is yet another singleton b) is created every-time you call this function (ie. does not "get" but "create" )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've already checked and can confirm the the _mounted_volumes can be moved to the app instance. For get_settings() I am not sure. Will also check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So after spending too much time on trying to move part of the get_settings() away. Will stop for now and leave it for a later PR. It's not that straight forward.

Copy link
Member

Choose a reason for hiding this comment

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

i am a bit surprised this read this since we have been refactoring settings for the whole year ... so i wonder what is the difference here. let's check together

services/dynamic-sidecar/tests/unit/test_docker_utils.py Outdated Show resolved Hide resolved
services/dynamic-sidecar/tests/unit/test_docker_utils.py Outdated Show resolved Hide resolved
@@ -9,6 +9,8 @@
import pytest
from simcore_service_dynamic_sidecar.modules import mounted_fs

pytestmark = pytest.mark.asyncio
Copy link
Member

Choose a reason for hiding this comment

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

well I think it depends in this case if the pytest-aiohttp library is installed. in which case I think you can just remove the mark.

Copy link
Member

@pcrespov pcrespov left a comment

Choose a reason for hiding this comment

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

le'ts give it a try a moment together about the settings

@GitHK GitHK requested a review from pcrespov April 6, 2022 07:49
@GitHK GitHK merged commit 5c09b8f into ITISFoundation:master Apr 7, 2022
@GitHK GitHK deleted the proper-volume-removal branch April 7, 2022 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:director-v2 issue related with the director-v2 service a:dynamic-sidecar dynamic-sidecar service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants