camerondurham / codecanvas

Remote code executor server, frontend, and CLI to run untrusted code as a non-root user in a Docker container.

Home Page:https://u64.cam/codecanvas

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `AsyncController` in server instead of default runtime

camerondurham opened this issue · comments

commented

Will add more details to this issue but should be suitable for anyone to take up. This might be a good opportunity to get more familiar with the runtime part of the project.

The goal of this issue is to make sure that we use the "thread-safe" runtime to ensure that when concurrently running user requests we don't use the same UID and GID.

The coderunner should now use a Controller instead of the RuntimeAgent directly. We can make a coderunner struct (if there isn't one already) that will be initialized with the AsyncController when the server starts up. The server can have some default configuration as well that determines how many agents the server creates.

We can also make a more appropriate type to pass into SubmitRequest: https://github.com/camerondurham/runner/blob/e6362100fba794e9ea5626bf54da1f09592e7810/engine/controller/controller.go#L59

Instead of RunProps, the coderunner should not have to pass in any Uid or Gid since the Controller should handle the Uid/Gid since agents contain what values we should use. We can make some other wrapper type for the SubmitRequest like this:

type ControllerRequest struct {
    RunArgs: []string
    Timeout: int
    NProcs: int
}

TODO:

  • create new props to pass to controller.SubmitRequest instead of RunProps
  • remove Uid and Gid from RunProps
  • use AsyncController in the coderunner instead of directly using a new runtime each time