X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/88bb9b9fc4392f4a3514ae59e3ffd454d3ce90a8..a76b52ff503ae14df608904349670151a5b15e47:/lib/crunchrun/crunchrun.go diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go index f28593fe0c..969682f465 100644 --- a/lib/crunchrun/crunchrun.go +++ b/lib/crunchrun/crunchrun.go @@ -623,7 +623,7 @@ func (runner *ContainerRunner) SetupMounts() (err error) { return fmt.Errorf("output path does not correspond to a writable mount point") } - if wantAPI := runner.Container.RuntimeConstraints.API; needCertMount && wantAPI != nil && *wantAPI { + if needCertMount && runner.Container.RuntimeConstraints.API { for _, certfile := range arvadosclient.CertFiles { _, err := os.Stat(certfile) if err == nil { @@ -1094,7 +1094,7 @@ func (runner *ContainerRunner) CreateContainer() error { }, } - if wantAPI := runner.Container.RuntimeConstraints.API; wantAPI != nil && *wantAPI { + if runner.Container.RuntimeConstraints.API { tok, err := runner.ContainerToken() if err != nil { return err @@ -1271,7 +1271,7 @@ func (runner *ContainerRunner) updateLogs() { // CaptureOutput saves data from the container's output directory if // needed, and updates the container output accordingly. func (runner *ContainerRunner) CaptureOutput() error { - if wantAPI := runner.Container.RuntimeConstraints.API; wantAPI != nil && *wantAPI { + if runner.Container.RuntimeConstraints.API { // Output may have been set directly by the container, so // refresh the container record to check. err := runner.DispatcherArvClient.Get("containers", runner.Container.UUID, @@ -1433,15 +1433,20 @@ func (runner *ContainerRunner) saveLogCollection(final bool) (response arvados.C // Already finalized. return } - mt, err := runner.LogCollection.MarshalManifest(".") - if err != nil { - err = fmt.Errorf("error creating log manifest: %v", err) - return - } updates := arvadosclient.Dict{ - "name": "logs for " + runner.Container.UUID, - "manifest_text": mt, + "name": "logs for " + runner.Container.UUID, + } + mt, err1 := runner.LogCollection.MarshalManifest(".") + if err1 == nil { + // Only send updated manifest text if there was no + // error. + updates["manifest_text"] = mt } + + // Even if flushing the manifest had an error, we still want + // to update the log record, if possible, to push the trash_at + // and delete_at times into the future. Details on bug + // #17293. if final { updates["is_trashed"] = true } else { @@ -1450,16 +1455,20 @@ func (runner *ContainerRunner) saveLogCollection(final bool) (response arvados.C updates["delete_at"] = exp } reqBody := arvadosclient.Dict{"collection": updates} + var err2 error if runner.logUUID == "" { reqBody["ensure_unique_name"] = true - err = runner.DispatcherArvClient.Create("collections", reqBody, &response) + err2 = runner.DispatcherArvClient.Create("collections", reqBody, &response) } else { - err = runner.DispatcherArvClient.Update("collections", runner.logUUID, reqBody, &response) + err2 = runner.DispatcherArvClient.Update("collections", runner.logUUID, reqBody, &response) } - if err != nil { - return + if err2 == nil { + runner.logUUID = response.UUID + } + + if err1 != nil || err2 != nil { + err = fmt.Errorf("error recording logs: %q, %q", err1, err2) } - runner.logUUID = response.UUID return } @@ -1878,10 +1887,12 @@ func (command) RunCommand(prog string, args []string, stdin io.Reader, stdout, s Log: cr.CrunchLog, } os.Unsetenv("GatewayAuthSecret") - err = cr.gateway.Start() - if err != nil { - log.Printf("error starting gateway server: %s", err) - return 1 + if cr.gateway.Address != "" { + err = cr.gateway.Start() + if err != nil { + log.Printf("error starting gateway server: %s", err) + return 1 + } } parentTemp, tmperr := cr.MkTempDir("", "crunch-run."+containerID+".")