Merge branch '16129-scoped-token-doc' refs #16129
[arvados.git] / lib / dispatchcloud / worker / worker.go
index a455a7d06d88770080fa42e62a19cb878e5050d6..357ac20a038d56ca7a4778c6df38f05f2e2dae08 100644 (file)
@@ -369,7 +369,6 @@ func (wkr *worker) probeBooted() (ok bool, stderr []byte) {
                wkr.logger.WithError(err).WithField("stderr", string(stderr2)).Warn("error copying runner binary")
                return false, stderr2
        } else {
-               wkr.logger.Info("runner binary OK")
                stderr = append(stderr, stderr2...)
        }
        return true, stderr
@@ -378,19 +377,25 @@ func (wkr *worker) probeBooted() (ok bool, stderr []byte) {
 func (wkr *worker) copyRunnerData() (stdout, stderr []byte, err error) {
        hash := fmt.Sprintf("%x", wkr.wp.runnerMD5)
        dstdir, _ := filepath.Split(wkr.wp.runnerCmd)
+       logger := wkr.logger.WithFields(logrus.Fields{
+               "hash": hash,
+               "path": wkr.wp.runnerCmd,
+       })
 
        stdout, stderr, err = wkr.executor.Execute(nil, `md5sum `+wkr.wp.runnerCmd, nil)
        if err == nil && len(stderr) == 0 && bytes.Equal(stdout, []byte(hash+"  "+wkr.wp.runnerCmd+"\n")) {
+               logger.Info("runner binary already exists on worker, with correct hash")
                return
        }
 
        // Note touch+chmod come before writing data, to avoid the
        // possibility of md5 being correct while file mode is
        // incorrect.
-       cmd := `set -e; dstdir="` + dstdir + `"; dstfile="` + wkr.wp.runnerCmd + `"; mkdir -p "$dstdir"; touch "$dstfile"; chmod 0700 "$dstfile"; cat >"$dstfile"`
+       cmd := `set -e; dstdir="` + dstdir + `"; dstfile="` + wkr.wp.runnerCmd + `"; mkdir -p "$dstdir"; touch "$dstfile"; chmod 0755 "$dstdir" "$dstfile"; cat >"$dstfile"`
        if wkr.instance.RemoteUser() != "root" {
                cmd = `sudo sh -c '` + strings.Replace(cmd, "'", "'\\''", -1) + `'`
        }
+       logger.WithField("cmd", cmd).Info("installing runner binary on worker")
        stdout, stderr, err = wkr.executor.Execute(nil, cmd, bytes.NewReader(wkr.wp.runnerData))
        return
 }