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

Forker process #489

Merged
merged 1 commit into from
Feb 22, 2022
Merged

Forker process #489

merged 1 commit into from
Feb 22, 2022

Conversation

rosds
Copy link
Contributor

@rosds rosds commented Jan 21, 2022

Spawning container processes is delegated to a separated 'forker'
process. The runtime communicates with this process through a unix
domain socket.

With this change, northstar's runtime can execute in multithreaded mode
without the danger of the libc deadlocking issue. The 'forker' process
must consequently be single threaded.

Additionally, this patch introduces a small API for the container Init
processes that enables the request to start new processes inside the
container. This is a prerequisite to #454.

Additional details

  • Northstar version is bumped to 0.7.0-dev (see Start using SemVer 'pre-releases' #496 )

  • Panic if the forker process exits unexpectedly

    If the forker process dies for whatever reason, it is not possible
    to recoverable and the runtime bails out.

  • Do not limit the number of threads of the runtime in demo main

  • Parallel loading of NPKs from disk

    The loading of NPKs from disk is slow and blocking. Spawn a thread
    for each NPK in order to speed up the boring parsing of the NPK
    headers.

  • Replace manifest IO Pipe with Log

    The 'pipe' option for the container output is removed from the
    manifest. The option 'log' is renamed to 'pipe'. A new option
    'discard' is added for the output.

  • Refactor container IO handling

    When the container IO configuration in the manifest indicates that
    any of stdout or stderr is to be 'piped', a socket is used to
    receive the output from the container. On the other side, the
    runtime uses a async task to forward the incoming output from the
    socket to the runtime log.

  • Pipes removed and replaced with sockets

@rosds rosds mentioned this pull request Jan 21, 2022
@rosds rosds marked this pull request as ready for review January 25, 2022 10:11
@rosds rosds force-pushed the fork branch 2 times, most recently from 329ff00 to 11e1bfc Compare January 25, 2022 17:38
@flxo flxo force-pushed the fork branch 2 times, most recently from 4e42e6a to 36aa0df Compare January 26, 2022 10:26
@rosds rosds force-pushed the fork branch 6 times, most recently from 4d1448b to 5411d42 Compare January 31, 2022 16:19
images/container-startup.puml Outdated Show resolved Hide resolved
@rosds rosds force-pushed the fork branch 2 times, most recently from c7a5689 to e3cd25b Compare February 1, 2022 17:34
@rosds rosds mentioned this pull request Feb 5, 2022
@flxo flxo force-pushed the fork branch 5 times, most recently from 7661d8d to 321abd6 Compare February 11, 2022 09:45
@rosds rosds force-pushed the fork branch 4 times, most recently from 94f8ac1 to 1e416fc Compare February 21, 2022 16:26
Spawning container processes is delegated to a separated 'forker'
process. The runtime communicates with this process through a unix
domain socket.

With this change, northstar's runtime can now execute in multithreaded
mode without the danger of the libc deadlocking issue.

  ┌───────────┐    ┌────────┐   ┌────────────────────────────┐
  │ Northstar ├────┤ Forker │   │ Container A                │
  │  Runtime  │    └────┬───┘   │ ┌──────┐ ┌───────────────┐ │
  └───────────┘         ├───────┼►│ Init ├─┤ Application A │ │
                        │       │ └──────┘ └───────────────┘ │
                        │       └────────────────────────────┘
                        │
                        │       ┌────────────────────────────┐
                        │       │ Container B                │
                        │       │ ┌──────┐ ┌───────────────┐ │
                        ├───────┼►│ Init ├─┤ Application B │ │
                        │       │ └──────┘ └───────────────┘ │
                        │       └────────────────────────────┘
                        ▼
                       ...

The 'forker' process must consequently be single threaded.

Additionally, Init processes handle requests to start new processes
inside the container. This is a prerequisite to #454.

Additional details
------------------
- Northstar version is bumped to 0.7.0-dev
- Panic if the forker process exits unexpectedly

    If the forker process dies for whatever reason, it is not possible
    to recoverable and the runtime bails out.

- Do not limit the number of threads of the runtime in demo main
- Parallel loading of NPKs from disk

    The loading of NPKs from disk is slow and blocking. Spawn a thread
    for each NPK in order to speed up the boring parsing of the NPK
    headers.

- Replace manifest IO Pipe with Log

    The 'pipe' option for the container output is removed from the
    manifest. The option 'log' is renamed to 'pipe'. A new option
    'discard' is added for the output.

- Refactor container IO handling

    When the container IO configuration in the manifest indicates that
    any of `stdout` or `stderr` is to be 'piped', a socket is used to
    receive the output from the container. On the other side, the
    runtime uses a `async` task to forward the incoming output from the
    socket to the runtime log.

- Pipes are removed and replaced with sockets

Co-authored-by: Felix Obenhuber <[email protected]>
Co-authored-by: Alfonso Ros <[email protected]>
@rosds rosds merged commit 1da30d9 into master Feb 22, 2022
@rosds rosds deleted the fork branch February 22, 2022 13:54
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.

2 participants