From 270aabf1d8cabd69b9851209ad5d9c874348e21d Mon Sep 17 00:00:00 2001 From: Saravanan Balasubramanian <33908564+sarabala1979@users.noreply.github.com> Date: Thu, 30 May 2019 17:10:36 -0700 Subject: [PATCH] Fixed: failed to save outputs: verify serviceaccount default:default has necessary privileges (#1362) Fixed: failed to save outputs: verify serviceaccount default:default has necessary privileges (#1362) --- cmd/argoexec/commands/root.go | 2 ++ util/util.go | 10 ++++++++++ workflow/executor/executor.go | 3 +++ 3 files changed, 15 insertions(+) diff --git a/cmd/argoexec/commands/root.go b/cmd/argoexec/commands/root.go index 2cf792f06da5..a233b0fc2839 100644 --- a/cmd/argoexec/commands/root.go +++ b/cmd/argoexec/commands/root.go @@ -2,6 +2,7 @@ package commands import ( "encoding/json" + "github.com/argoproj/argo/util" "os" "github.com/argoproj/pkg/cli" @@ -105,6 +106,7 @@ func initExecutor() *executor.WorkflowExecutor { // checkErr is a convenience function to panic upon error func checkErr(err error) { if err != nil { + util.WriteTeriminateMessage(err.Error()) panic(err.Error()) } } diff --git a/util/util.go b/util/util.go index 4ebc1d5995eb..b091d3817fdb 100644 --- a/util/util.go +++ b/util/util.go @@ -1,5 +1,7 @@ package util +import "io/ioutil" + type Closer interface { Close() error } @@ -9,3 +11,11 @@ type Closer interface { func Close(c Closer) { _ = c.Close() } + +// Write the Terminate message in pod spec +func WriteTeriminateMessage(message string) { + err := ioutil.WriteFile("/dev/termination-log", []byte(message), 0644) + if err != nil { + panic(err) + } +} diff --git a/workflow/executor/executor.go b/workflow/executor/executor.go index 500dc93c9ba0..63d7d9681e80 100644 --- a/workflow/executor/executor.go +++ b/workflow/executor/executor.go @@ -6,6 +6,7 @@ import ( "context" "encoding/json" "fmt" + "github.com/argoproj/argo/util" "io" "io/ioutil" "net/url" @@ -112,9 +113,11 @@ func NewExecutor(clientset kubernetes.Interface, podName, namespace, podAnnotati func (we *WorkflowExecutor) HandleError() { if r := recover(); r != nil { _ = we.AddAnnotation(common.AnnotationKeyNodeMessage, fmt.Sprintf("%v", r)) + util.WriteTeriminateMessage(fmt.Sprintf("%v", r)) log.Fatalf("executor panic: %+v\n%s", r, debug.Stack()) } else { if len(we.errors) > 0 { + util.WriteTeriminateMessage(we.errors[0].Error()) _ = we.AddAnnotation(common.AnnotationKeyNodeMessage, we.errors[0].Error()) } }