hundreds-father-404
09/02/2022, 12:27 AMcontext.core.command_runners
to let you dynamically change which CommandRunners are used for a particular process, whereas right now it's the same for the whole Pants hundreds-father-404
09/02/2022, 12:29 AMdocker_environment
targets & re-initialize the scheduler to create the command runners. Then, individual Processes can change which is used, or
2) Allow defining a new CommandRunner value on-the-flyhundreds-father-404
09/02/2022, 12:29 AMfast-nail-55400
09/02/2022, 12:35 AMProcess
and switch accordinglyfast-nail-55400
09/02/2022, 12:36 AMhundreds-father-404
09/02/2022, 12:38 AMhundreds-father-404
09/02/2022, 12:40 AMfast-nail-55400
09/02/2022, 12:46 AMfast-nail-55400
09/02/2022, 12:47 AMwitty-crayon-22786
09/02/2022, 1:21 AMhundreds-father-404
09/02/2022, 1:22 AMimage
string, so I figured we must know what images the user told us to use. @fast-nail-55400 how hard would that be to change to not be eagerly set?witty-crayon-22786
09/02/2022, 1:22 AMhundreds-father-404
09/02/2022, 1:23 AMAfter plugin initialization, discover all defined docker_environment targets & re-initialize the scheduler to create the command runners. Then, individual Processes can change which is used, orOr, we need to move this info into the (bootstrap) options system
hundreds-father-404
09/02/2022, 1:24 AMAfter plugin initialization, discover all defined docker_environment targets & re-initialize the scheduler to create the command runners. Then, individual Processes can change which is used, orBut I think I may be off base here. We can discover the docker targets before plugin resolver runs. The plugin resolver does not impact that
witty-crayon-22786
09/02/2022, 1:25 AMhundreds-father-404
09/02/2022, 1:26 AM/// `CommandRunner` executes processes using a local Docker client.
pub struct CommandRunner {
docker: Docker,
store: Store,
executor: Executor,
work_dir_base: PathBuf,
named_caches: NamedCaches,
immutable_inputs: ImmutableInputs,
keep_sandboxes: KeepSandboxes,
image: String,
}
I can try that refactor right now. I really want to understand this Rust code betterwitty-crayon-22786
09/02/2022, 1:28 AMfast-nail-55400
09/02/2022, 1:31 AMProcess
.fast-nail-55400
09/02/2022, 1:31 AMdocker::CommandRunner
doesn't need to be initialized with an image.hundreds-father-404
09/02/2022, 1:32 AMfast-nail-55400
09/02/2022, 1:32 AMProcess
doesn't yet have a Docker image attribute.fast-nail-55400
09/02/2022, 1:32 AMfast-nail-55400
09/02/2022, 1:33 AMhundreds-father-404
09/02/2022, 2:02 AMhundreds-father-404
09/02/2022, 2:20 AMinner: super::local::CommandRunner,
and then inside run()
if req.docker_image.is_none() {
return self.inner.run(context, workunit, req).await;
}
I'm not certain what order the naive docker command runner should take inside the stack created at <http://context.rs|context.rs>
, though. Is it a leaf_runner()
?
Also, my understanding is we should likely always create the command runner? Only it won't run unless a user explicitly uses a docker_environment
target. It would always early return inside run()
fast-nail-55400
09/02/2022, 2:22 AMfast-nail-55400
09/02/2022, 2:22 AMDockerLocalSwitchCommandRunner
which owns both a docker::ComandRunner
and a local::CommandRunner
.fast-nail-55400
09/02/2022, 2:23 AMProcess
fast-nail-55400
09/02/2022, 2:24 AMlocal::CommandRunner
. I had a solution for that earlier in the development of the naive docker command runner PR, but took it out before landing after discussion with Stu.hundreds-father-404
09/02/2022, 2:24 AMI'd rather not the docker command runner know anything about any inner command runners.for my understanding, why not?
fast-nail-55400
09/02/2022, 2:25 AMfast-nail-55400
09/02/2022, 2:26 AMDockerLocalSwitchCommandRunner
is easy to write and is very straight-forward to understand since it would not be many linesfast-nail-55400
09/02/2022, 2:26 AMdocker::CommandRunner
and local::CommandRunner
together, now it is necessary to understand how they interact in order to understand themfast-nail-55400
09/02/2022, 2:26 AMfast-nail-55400
09/02/2022, 2:27 AMwitty-crayon-22786
09/02/2022, 2:35 AMsrc/nodes.rs
and src/context.rs
, and give it two CommandRunner stacks.witty-crayon-22786
09/02/2022, 2:36 AMProcess
struct, maybe it does make sense for it to be in the CommandRunner.witty-crayon-22786
09/02/2022, 2:37 AMProcess
struct have this field, or is it maybe provided as one of the inputs to the Process->ProcessResult
intrinsic?fast-nail-55400
09/02/2022, 2:47 AMyou could do it even higher: inyes. still maintains a good separation of concerns vis-a-visandsrc/nodes.rs
, and give it two CommandRunner stacks.src/context.rs
local::CommandRunner
and docker::CommandRunner
hundreds-father-404
09/02/2022, 5:26 PMyou could do it even higher: in src/nodes.rs and src/context.rsI'm not following that. Something like change
context.core.command_runners
so that we have two command_runners stacks?witty-crayon-22786
09/02/2022, 6:33 PMwitty-crayon-22786
09/02/2022, 6:34 PMwitty-crayon-22786
09/02/2022, 6:46 PMhundreds-father-404
09/02/2022, 6:48 PMbut there is also prior-art in that the nailgun CommandRunner wraps a locally runner and disables itself:That was how I already implemented it hehe. Is it fine, or we want me to do
DockerLocalSwitchCommandRunner
?witty-crayon-22786
09/02/2022, 6:48 PMwitty-crayon-22786
09/02/2022, 6:48 PMhundreds-father-404
09/02/2022, 6:49 PM<http://context.rs|context.rs>
trying to figure out the ordering of the command runners. Do you know what order makes sense? With that direction, I can play with implementation
For example, {RemoteExecutionRunner,LocalRunner -> NailgunRunner} -> LocalCacheRunner -> RemoteCacheRunner
witty-crayon-22786
09/02/2022, 6:51 PMwitty-crayon-22786
09/02/2022, 6:52 PMwitty-crayon-22786
09/02/2022, 6:52 PMwitty-crayon-22786
09/02/2022, 6:53 PMhundreds-father-404
09/02/2022, 9:26 PMbounded::CommandRunner
?witty-crayon-22786
09/02/2022, 9:27 PMwitty-crayon-22786
09/02/2022, 9:27 PMwitty-crayon-22786
09/02/2022, 9:28 PMhundreds-father-404
09/02/2022, 9:29 PMabove
Docker-wrapping-Nailgunthe ordering is tripping me up. Is this right? What we have now: local runner -> (maybe) Nailgun Now: local runner -> (maybe) Nailgun -> Docker
witty-crayon-22786
09/02/2022, 9:29 PMwitty-crayon-22786
09/02/2022, 9:30 PMwitty-crayon-22786
09/02/2022, 9:31 PM