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

Return usable URL from remoteapprest app start #568

Merged
merged 9 commits into from
Sep 7, 2021

Conversation

robertopreste
Copy link
Contributor

@robertopreste robertopreste commented Sep 6, 2021

Closes #567

[Includes changes from #566, changes will clean once that PR is merged]

Passing the right port to the response parsed by remoteapprest app start seems to be quite convoluted, so here is an approach which is a bit of a cheating, but it works and doesn't affect any other functionality.

The container name is changed to include the right host port (e.g. "/simphony-remote_49165"), however this new name is not used internally (in fact it doesn't show in the logs); the container URL is still e.g. "http://127.0.0.1:49165/user/rpreste/containers/simphony-paraview/", because it is generated earlier in the process.

The new alternative URL is not functional, but it is sent in the response to the remoteapprest app start call, so it can then be parsed and rearranged to return the correct URL.

@codecov-commenter
Copy link

codecov-commenter commented Sep 6, 2021

Codecov Report

Merging #568 (1198470) into master (9ad2c6f) will decrease coverage by 0.08%.
The diff coverage is 89.58%.

❗ Current head 1198470 differs from pull request most recent head c90c28c. Consider uploading reports for the commit c90c28c to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #568      +/-   ##
==========================================
- Coverage   95.16%   95.07%   -0.09%     
==========================================
  Files          92       92              
  Lines        4222     4267      +45     
  Branches      271      273       +2     
==========================================
+ Hits         4018     4057      +39     
- Misses        144      150       +6     
  Partials       60       60              
Impacted Files Coverage Δ
remoteappmanager/cli/remoteapprest/__main__.py 84.12% <72.22%> (-2.24%) ⬇️
remoteappmanager/cli/tests/test_remoteapprest.py 100.00% <100.00%> (ø)
remoteappmanager/docker/container_manager.py 82.11% <100.00%> (-0.38%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ad2c6f...c90c28c. Read the comment docs.

Copy link
Contributor

@flongford flongford left a comment

Choose a reason for hiding this comment

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

Thanks @robertopreste - I have a question about the potential implications of changing the container ID, but otherwise LGTM.

Just to clarify, is this PR currently is preferred over #567?

@@ -349,7 +349,7 @@ def _start_container(self,
'\n'.join('{0} -> {1}'.format(source, target['bind'])
for source, target in filtered_volumes.items()))

container_url_id = _generate_container_url_id()
container_url_id = image_name.split("/")[-1]
Copy link
Contributor

Choose a reason for hiding this comment

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

I am wondering if there are either any security or practical implications of this change, since the container url ID is no longer a random or unique string.

Are there any best practices for Docker container url ids? I couldn't find much information online. Maybe we can just review any potential information that we are exposing here

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 agree, however I don't think we're exposing any sensible data, being it simply the name of the image. Also, it shouldn't pose a problem practically (e.g. name conflicts with other containers), since we run only one container (for a given image) at a time.

I haven't found anything specific about container IDs, so I wouldn't know about best practices, I'm afraid.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that makes sense.

To tidy things up, could we extend the _generate_container_url_id to take a image_name keyword argument that is None by default? If the image_name is then provided, then we parse it, if not we just return a random string.

@robertopreste
Copy link
Contributor Author

Just to clarify, is this PR currently is preferred over #567?

This PR simply contains the changes from #567, because the new changes rely on them. I opened two separate PRs only to keep things in order; even if it's very small changes I think it would be better to review and merge them separately.

Copy link
Contributor

@flongford flongford left a comment

Choose a reason for hiding this comment

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

Thanks for your responses @robertopreste - LGTM!

@robertopreste robertopreste merged commit 1472bcb into master Sep 7, 2021
@robertopreste robertopreste deleted the 567-fix-returned-url branch September 7, 2021 09:46
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.

Return correct URL from remoteapprest app start
3 participants