Skip to content

Create setup for sidecar #198

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

Closed
4 of 5 tasks
pcrespov opened this issue Aug 24, 2018 · 7 comments · Fixed by #199
Closed
4 of 5 tasks

Create setup for sidecar #198

pcrespov opened this issue Aug 24, 2018 · 7 comments · Fixed by #199
Assignees
Labels
t:enhancement Improvement or request on an existing feature
Milestone

Comments

@pcrespov
Copy link
Member

pcrespov commented Aug 24, 2018

The origin of this issue is that the sidecar could import simcore-sdk but not its dependencies because they were actually not installed. This issue blocks #186. In order to solve it properly we need to fulfill:

  • Missing setup.py
  • Missing requirement-dev.txt
  • Non-root user in docker.
    • devel target will not create eggs as root and in production :
usr/local/lib/python3.6/site-packages/celery/platforms.py:795: RuntimeWarning: You're running the worker with superuser privileges: this is
sidecar_1    | absolutely not recommended!
  • venv in docker wont' do. For this case, I agree that docker provides desired isolation
  • rearrange package structure: main.py, tasks.py, celery.py and utils.py
@pcrespov pcrespov self-assigned this Aug 24, 2018
@pcrespov
Copy link
Member Author

pcrespov commented Aug 24, 2018

Error running boot.sh.

>>> import sidecar
DEBUG:docker.utils.config:Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
DEBUG:docker.utils.config:No config file found
DEBUG:docker.utils.config:Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
DEBUG:docker.utils.config:No config file found
DEBUG:urllib3.connectionpool:http://localhost:None "GET /version HTTP/1.1" 200 543
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/work/services/sidecar/src/sidecar/__init__.py", line 1, in <module>
    from .core import *
  File "/work/services/sidecar/src/sidecar/core.py", line 455, in <module>
    SIDECAR = Sidecar()
  File "/work/services/sidecar/src/sidecar/core.py", line 43, in __init__
    self._s3 = S3Settings()
  File "/work/services/sidecar/src/sidecar/utils.py", line 70, in __init__
    access_key=self._config.access_key, secret_key=self._config.secret_key)
  File "/work/packages/s3wrapper/src/s3wrapper/s3_client.py", line 23, in __init__
    secure=secure)
  File "/usr/local/lib/python3.6/site-packages/minio/api.py", line 135, in __init__
    is_valid_endpoint(endpoint)
  File "/usr/local/lib/python3.6/site-packages/minio/helpers.py", line 301, in is_valid_endpoint
    if hostname[-1] == '.':
IndexError: string index out of range

solved restructuring sidecar service (last point above)

@pcrespov pcrespov added t:enhancement Improvement or request on an existing feature bug buggy, it does not work as expected labels Aug 24, 2018
@pcrespov pcrespov added this to the Libra milestone Aug 24, 2018
pcrespov pushed a commit to pcrespov/osparc-simcore that referenced this issue Aug 24, 2018
 - created setup and requirements for dev&prod
 - installs package in docker (instead of reference via sys.path). this way all third-parties are installed.
 - minor cleanup of code
pcrespov pushed a commit to pcrespov/osparc-simcore that referenced this issue Aug 24, 2018
 - added a boot.sh script to start celery worker
 - restructured package submodules. Otherwise got error (see comments in ITISFoundation#198)
 -
@pcrespov pcrespov removed the bug buggy, it does not work as expected label Aug 24, 2018
pcrespov pushed a commit to pcrespov/osparc-simcore that referenced this issue Aug 27, 2018
 - all volumes bound to /home/scu
 - All modules pip installed (in dev w/ edit mode).
 - All files produce in dev mode on bound volumes are not deletable
 - Production stage is further optimized by taking only venv from base
 - Fixes sidecar access to input/output/log volumes
@pcrespov
Copy link
Member Author

pcrespov commented Aug 29, 2018

Error

sidecar_1    | Traceback (most recent call last):
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/celery/app/trace.py", line 374, in trace_task
sidecar_1    |     R = retval = fun(*args, **kwargs)
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/celery/app/trace.py", line 629, in __protected_call__
sidecar_1    |     return self.run(*args, **kwargs)
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/sidecar/tasks.py", line 11, in pipeline
sidecar_1    |     from .core import SIDECAR
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/sidecar/core.py", line 451, in <module>
sidecar_1    |     SIDECAR = Sidecar()
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/sidecar/core.py", line 32, in __init__
sidecar_1    |     self._docker = DockerSettings()
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/sidecar/utils.py", line 59, in __init__
sidecar_1    |     self.client = docker.from_env(version='auto')
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/docker/client.py", line 81, in from_env
sidecar_1    |     **kwargs_from_env(**kwargs))
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/docker/client.py", line 38, in __init__
sidecar_1    |     self.api = APIClient(*args, **kwargs)
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/docker/api/client.py", line 154, in __init__
sidecar_1    |     self._version = self._retrieve_server_version()
sidecar_1    |   File "/home/scu/.venv/lib/python3.6/site-packages/docker/api/client.py", line 179, in _retrieve_server_version
sidecar_1    |     'Error while fetching server API version: {0}'.format(e)
sidecar_1    | docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))

checks

  • scu in docker group
crespo@crespo-ubuntu:~/devp/osparc-simcore$ docker logs 027
INFO: Sidecar running as uid=8004(scu) gid=8004(scu) groups=8004(scu),1001(docker)
INFO: Booting in production mode ...
[2018-08-29 16:55:29,003: ERROR/MainProcess] consumer: Cannot connect to amqp://simcore:**@rabbit:5672//: [Errno 111] Connection refused.
Trying again in 2.00 seconds...

[2018-08-29 16:55:31,015: ERROR/MainProcess] consumer: Cannot connect to amqp://simcore:**@rabbit:5672//: [Errno 111] Connection refused.
Trying again in 4.00 seconds...

[2018-08-29 16:55:35,040: INFO/MainProcess] Connected to amqp://simcore:**@rabbit:5672//
[2018-08-29 16:55:35,049: INFO/MainProcess] mingle: searching for neighbors
[2018-08-29 16:55:36,075: INFO/MainProcess] mingle: all alone
[2018-08-29 16:55:36,115: INFO/MainProcess] celery@027f68d802f7 ready.

Solution

Entrypoint with su-exec scu "$@" instead of su-exec scu:scu "$@" ... obviously! :(

@pcrespov
Copy link
Member Author

pcrespov commented Aug 30, 2018

Error

sidecar_1 | ImportError: Error loading shared library libpq.so.5: No such file or directory (needed by /home/scu/.venv/lib/python3.6/site-packages/psycopg2/_psycopg.cpython-36m-x86_64-linux-gnu.so)

It actually exists but does not work since there are some dlls that are not present. The problem is in the production stage. Solved in commit bab7831

@oetiker
Copy link
Contributor

oetiker commented Aug 30, 2018

this sounds is if the postgresql library was missing

@oetiker
Copy link
Contributor

oetiker commented Aug 30, 2018

which might make sense since the sidecar should not access postgres directly

@mguidon
Copy link
Member

mguidon commented Aug 30, 2018

It is recommended to build psycopg2 against the C low level library. You do that in your build stage by installing them into alpine. In your run stage you need the corresponding runtime libraries.
@oetiker : What is the disadvantage of letting the sidecar talk to the db?

pcrespov pushed a commit to pcrespov/osparc-simcore that referenced this issue Aug 30, 2018
commit 0df033b
Author: Pedro Crespo <[email protected]>
Date:   Thu Aug 30 14:21:44 2018 +0200

    Review feedback: removed unnecessary config sections

commit bab7831
Author: Pedro Crespo <[email protected]>
Date:   Thu Aug 30 13:59:07 2018 +0200

    Fixes missing dlls

commit c0bc7d6
Author: Pedro Crespo <[email protected]>
Date:   Thu Aug 30 11:53:41 2018 +0200

    Fixes access to docker socket:
     - cleanup Dockerfile
     - minor doc and logs

commit 5b6f4c7
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 17:47:13 2018 +0200

    Minor cleanup and doc

commit 43f7305
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 15:52:30 2018 +0200

    Minor change in web server

commit 7f07022
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 15:52:16 2018 +0200

    sidecar: starts as root (via entrypoint) but runs as scu (non-root)

commit 90359c4
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 15:51:32 2018 +0200

    Fixes sidecar: temporary fix to connection to other services

commit 7619671
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 15:44:42 2018 +0200

    Fixes host in server running inside a docker

commit bdbf078
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 15:43:56 2018 +0200

    Separating maintenance services

commit 83e492d
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 13:46:55 2018 +0200

    Fixes on web server:
     - removed usused cs_s4l from config
     - added env for rabbit

commit 8fee402
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 11:48:46 2018 +0200

    Fixes on webserver: - Tmp  solution for production target based on production-build stage -  Normalized naming of package and console script

commit a5d8220
Author: Pedro Crespo <[email protected]>
Date:   Tue Aug 28 22:06:59 2018 +0200

    Implements entry in ITISFoundation#186: - upgrades Dockerfile with .venv and pip installing 3rd parties

commit 3c55bf3
Author: Pedro Crespo <[email protected]>
Date:   Tue Aug 28 18:46:57 2018 +0200

    Setting up boot for web service and forgot configs

commit 8003744
Author: Pedro Crespo <[email protected]>
Date:   Tue Aug 28 18:40:12 2018 +0200

    Adding config data and retreiving it as resource

commit 94de3d7
Author: Pedro Crespo <[email protected]>
Date:   Tue Aug 28 10:58:02 2018 +0200

    Minor changes in docker after discussion with MaG

commit e663a1e
Author: Pedro Crespo <[email protected]>
Date:   Mon Aug 27 22:08:38 2018 +0200

    Updated ownership

commit bf486b3
Author: Pedro Crespo <[email protected]>
Date:   Mon Aug 27 21:53:12 2018 +0200

    Fixes linting errors and added notes

commit 752c7bf
Author: Pedro Crespo <[email protected]>
Date:   Mon Aug 27 19:49:39 2018 +0200

    WIP ITISFoundation#198: non-root user
     - all volumes bound to /home/scu
     - All modules pip installed (in dev w/ edit mode).
     - All files produce in dev mode on bound volumes are not deletable
     - Production stage is further optimized by taking only venv from base
     - Fixes sidecar access to input/output/log volumes

commit ec755bc
Author: Pedro Crespo <[email protected]>
Date:   Fri Aug 24 21:53:13 2018 +0200

    WIP ITISFoundation#198:
     - added a boot.sh script to start celery worker
     - restructured package submodules. Otherwise got error (see comments in ITISFoundation#198)
     -

commit 9bbfbde
Author: Pedro Crespo <[email protected]>
Date:   Fri Aug 24 21:52:12 2018 +0200

    Minor update

commit 53c7707
Author: Pedro Crespo <[email protected]>
Date:   Fri Aug 24 20:29:26 2018 +0200

    Fixes import failure of trafaret and updages vs sqalquemy

commit a27a279
Author: Pedro Crespo <[email protected]>
Date:   Fri Aug 24 20:24:49 2018 +0200

    WIP ITISFoundation#198: setup for sidecar
     - created setup and requirements for dev&prod
     - installs package in docker (instead of reference via sys.path). this way all third-parties are installed.
     - minor cleanup of code

commit bbc7cb6
Author: Pedro Crespo <[email protected]>
Date:   Fri Aug 24 20:22:31 2018 +0200

    Minor: sync req versions
@sanderegg
Copy link
Member

make sidecar run under Windows: detect windows, and run as root in entrypoint.sh

pcrespov added a commit that referenced this issue Aug 31, 2018
## What do these changes do?

Upgrades ``sidecar`` setup and module structure and fixes some issues.

- [x] Missing setup.py
- [x] Missing requirement-dev.txt
- [x] Non-root user in docker.
- [x] venv in docker
- [x] rearrange package structure: ``main.py``, ``tasks.py``,  ``celery.py`` and ``utils.py``
- [x] entrypoint script to start as ``root`` and run as ``scu``

Extra fixes on ``webserver``
- [x] retreived config files as resources
- [x] modified Dockerfile: should replicate the way we test in source
    - keeps same relative folder structure
    - all 3erd, 2nd and main packages install in a venv
    - runs as a non-root user
    - boot script

## Related issue number
- closes #198 

----

* Fixes typos in client after bad merge

* Minor: sync req versions

* WIP #198: setup for sidecar
 - created setup and requirements for dev&prod
 - installs package in docker (instead of reference via sys.path). this way all third-parties are installed.
 - minor cleanup of code

* Fixes import failure of trafaret and updages vs sqalquemy

* Minor update

* WIP #198:
 - added a boot.sh script to start celery worker
 - restructured package submodules. Otherwise got error (see comments in #198)
 -

* WIP #198: non-root user
 - all volumes bound to /home/scu
 - All modules pip installed (in dev w/ edit mode).
 - All files produce in dev mode on bound volumes are not deletable
 - Production stage is further optimized by taking only venv from base
 - Fixes sidecar access to input/output/log volumes

* Fixes linting errors and added notes

* Updated ownership

* Minor changes in docker after discussion with MaG

* Adding config data and retreiving it as resource

* Setting up boot for web service and forgot configs

* Implements entry in #186: - upgrades Dockerfile with .venv and pip installing 3rd parties

* Fixes on webserver: - Tmp  solution for production target based on production-build stage -  Normalized naming of package and console script

* Fixes on web server:
 - removed usused cs_s4l from config
 - added env for rabbit

* Separating maintenance services

* Fixes host in server running inside a docker

* Fixes sidecar: temporary fix to connection to other services

* sidecar: starts as root (via entrypoint) but runs as scu (non-root)

* Minor change in web server

* Minor cleanup and doc

* Fixes access to docker socket:
 - cleanup Dockerfile
 - minor doc and logs

* Fixes missing dlls

* Review feedback: removed unnecessary config sections

* Fixed volume map between sidecar and workcar containers
@ghost ghost removed the review label Aug 31, 2018
@sanderegg sanderegg mentioned this issue Sep 4, 2018
4 tasks
@ghost ghost assigned sanderegg Sep 4, 2018
pcrespov added a commit that referenced this issue Sep 25, 2018
- [x] adds rest-api following same procedure as in director (see #185)
- [x] wait director integration before merging (requires #185)
- [x] webserver-sdk 
- [x] mockup logic (business logic will be added later)
- [x] adds infrastructure for testing
- [x] sessions, security, configuration, resources (draft)


commit c0bc7d6
Author: Pedro Crespo <[email protected]>
Date:   Thu Aug 30 11:53:41 2018 +0200

    Fixes access to docker socket:
     - cleanup Dockerfile
     - minor doc and logs

commit 7f07022
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 15:52:16 2018 +0200

    sidecar: starts as root (via entrypoint) but runs as scu (non-root)

commit 90359c4
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 15:51:32 2018 +0200

    Fixes sidecar: temporary fix to connection to other services

commit 7619671
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 15:44:42 2018 +0200

    Fixes host in server running inside a docker

commit 83e492d
Author: Pedro Crespo <[email protected]>
Date:   Wed Aug 29 13:46:55 2018 +0200

    Fixes on web server:
     - removed usused cs_s4l from config
     - added env for rabbit

commit a5d8220
Author: Pedro Crespo <[email protected]>
Date:   Tue Aug 28 22:06:59 2018 +0200

    Implements entry in #186: - upgrades Dockerfile with .venv and pip installing 3rd parties

commit 3c55bf3
Author: Pedro Crespo <[email protected]>
Date:   Tue Aug 28 18:46:57 2018 +0200

    Setting up boot for web service and forgot configs

commit 8003744
Author: Pedro Crespo <[email protected]>
Date:   Tue Aug 28 18:40:12 2018 +0200

    Adding config data and retrieving it as resource

commit 94de3d7
Author: Pedro Crespo <[email protected]>
Date:   Tue Aug 28 10:58:02 2018 +0200

    Minor changes in docker after discussion with MaG


commit 752c7bf
Author: Pedro Crespo <[email protected]>
Date:   Mon Aug 27 19:49:39 2018 +0200

    WIP #198: non-root user
     - all volumes bound to /home/scu
     - All modules pip installed (in dev w/ edit mode).
     - All files produce in dev mode on bound volumes are not deletable
     - Production stage is further optimized by taking only venv from base
     - Fixes sidecar access to input/output/log volumes

commit ec755bc
Author: Pedro Crespo <[email protected]>
Date:   Fri Aug 24 21:53:13 2018 +0200

    WIP #198:
     - added a boot.sh script to start celery worker
     - restructured package submodules. Otherwise got error (see comments in #198)
     -

commit a27a279
Author: Pedro Crespo <[email protected]>
Date:   Fri Aug 24 20:24:49 2018 +0200

    WIP #198: setup for sidecar
     - created setup and requirements for dev&prod
     - installs package in docker (instead of reference via sys.path). this way all third-parties are installed.
     - minor cleanup of code

* is#186 web: Normalized package name and added new placeholders for submodules
* is#186 web: Normalized package name and added new placeholders for submodules
* is#186 web: fix import in docker context
 - temporarily a thick production stage
 - boot and entrypoint sh to .docker/
- separated middlewares, routing and setup
- merged api submodule into rest - removed aiohttp swagger since already in apiset - split rest/handlers
- web api: moved routings into separate functions
- Allowed disabling services from configuration
- Fixes cyclic import rest.routing -> rest.settings
- Fixes fix bug1 in issue #186 using a decorator
- Testing authentication
- added a light/fast test config
- simple test unauthorized access
- imp#186: Route to retrieve openapi specs json /v1/oas
- Fixes test_rest to access to api specs.
- Fixes coverage failure reported in travis
- Simplified resources functionality and updated tests
- Squashed PR 187 before merged to master.
- Merging bulk changes
- Director with openapi that includes new data model.
- Only missing is adapting business loging to new data model (see issue #213)
- Added test to check openapi specs
- Change first oas.server to overcome client-sdk limitation
- Added autogenerated code for webserver-sdk. Added some ignores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t:enhancement Improvement or request on an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants