projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
19099: Fix typos.
[arvados.git]
/
lib
/
dispatchcloud
/
worker
/
runner.go
diff --git
a/lib/dispatchcloud/worker/runner.go
b/lib/dispatchcloud/worker/runner.go
index 0fd99aeeef136cdc1113f55466b1342b7c975cc1..29c4b8e0a36a3be2a721e1bc509335817e86842c 100644
(file)
--- a/
lib/dispatchcloud/worker/runner.go
+++ b/
lib/dispatchcloud/worker/runner.go
@@
-9,9
+9,11
@@
import (
"encoding/json"
"fmt"
"net"
"encoding/json"
"fmt"
"net"
+ "strings"
"syscall"
"time"
"syscall"
"time"
+ "git.arvados.org/arvados.git/lib/crunchrun"
"github.com/sirupsen/logrus"
)
"github.com/sirupsen/logrus"
)
@@
-20,8
+22,9
@@
import (
type remoteRunner struct {
uuid string
executor Executor
type remoteRunner struct {
uuid string
executor Executor
-
envJSON
json.RawMessage
+
configJSON
json.RawMessage
runnerCmd string
runnerCmd string
+ runnerArgs []string
remoteUser string
timeoutTERM time.Duration
timeoutSignal time.Duration
remoteUser string
timeoutTERM time.Duration
timeoutSignal time.Duration
@@
-45,7
+48,8
@@
func newRemoteRunner(uuid string, wkr *worker) *remoteRunner {
if err := enc.Encode(wkr.instType); err != nil {
panic(err)
}
if err := enc.Encode(wkr.instType); err != nil {
panic(err)
}
- env := map[string]string{
+ var configData crunchrun.ConfigData
+ configData.Env = map[string]string{
"ARVADOS_API_HOST": wkr.wp.arvClient.APIHost,
"ARVADOS_API_TOKEN": wkr.wp.arvClient.AuthToken,
"InstanceType": instJSON.String(),
"ARVADOS_API_HOST": wkr.wp.arvClient.APIHost,
"ARVADOS_API_TOKEN": wkr.wp.arvClient.AuthToken,
"InstanceType": instJSON.String(),
@@
-53,17
+57,22
@@
func newRemoteRunner(uuid string, wkr *worker) *remoteRunner {
"GatewayAuthSecret": wkr.wp.gatewayAuthSecret(uuid),
}
if wkr.wp.arvClient.Insecure {
"GatewayAuthSecret": wkr.wp.gatewayAuthSecret(uuid),
}
if wkr.wp.arvClient.Insecure {
-
e
nv["ARVADOS_API_HOST_INSECURE"] = "1"
+
configData.E
nv["ARVADOS_API_HOST_INSECURE"] = "1"
}
}
- envJSON, err := json.Marshal(env)
+ if bufs := wkr.wp.cluster.Containers.LocalKeepBlobBuffersPerVCPU; bufs > 0 {
+ configData.Cluster = wkr.wp.cluster
+ configData.KeepBuffers = bufs * wkr.instType.VCPUs
+ }
+ configJSON, err := json.Marshal(configData)
if err != nil {
panic(err)
}
rr := &remoteRunner{
uuid: uuid,
executor: wkr.executor,
if err != nil {
panic(err)
}
rr := &remoteRunner{
uuid: uuid,
executor: wkr.executor,
-
envJSON: env
JSON,
+
configJSON: config
JSON,
runnerCmd: wkr.wp.runnerCmd,
runnerCmd: wkr.wp.runnerCmd,
+ runnerArgs: wkr.wp.runnerArgs,
remoteUser: wkr.instance.RemoteUser(),
timeoutTERM: wkr.wp.timeoutTERM,
timeoutSignal: wkr.wp.timeoutSignal,
remoteUser: wkr.instance.RemoteUser(),
timeoutTERM: wkr.wp.timeoutTERM,
timeoutSignal: wkr.wp.timeoutSignal,
@@
-81,11
+90,15
@@
func newRemoteRunner(uuid string, wkr *worker) *remoteRunner {
// assume the remote process _might_ have started, at least until it
// probes the worker and finds otherwise.
func (rr *remoteRunner) Start() {
// assume the remote process _might_ have started, at least until it
// probes the worker and finds otherwise.
func (rr *remoteRunner) Start() {
- cmd := rr.runnerCmd + " --detach --stdin-env '" + rr.uuid + "'"
+ cmd := rr.runnerCmd + " --detach --stdin-config"
+ for _, arg := range rr.runnerArgs {
+ cmd += " '" + strings.Replace(arg, "'", "'\\''", -1) + "'"
+ }
+ cmd += " '" + rr.uuid + "'"
if rr.remoteUser != "root" {
cmd = "sudo " + cmd
}
if rr.remoteUser != "root" {
cmd = "sudo " + cmd
}
- stdin := bytes.NewBuffer(rr.
env
JSON)
+ stdin := bytes.NewBuffer(rr.
config
JSON)
stdout, stderr, err := rr.executor.Execute(nil, cmd, stdin)
if err != nil {
rr.logger.WithField("stdout", string(stdout)).
stdout, stderr, err := rr.executor.Execute(nil, cmd, stdin)
if err != nil {
rr.logger.WithField("stdout", string(stdout)).