Skip to content

Commit

Permalink
Fixed: failed to save outputs: verify serviceaccount default:default …
Browse files Browse the repository at this point in the history
…has necessary privileges (#1362)

Fixed:  failed to save outputs: verify serviceaccount default:default has necessary privileges (#1362)
  • Loading branch information
sarabala1979 authored May 31, 2019
1 parent 163f4a5 commit 270aabf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/argoexec/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"encoding/json"
"github.com/argoproj/argo/util"
"os"

"github.com/argoproj/pkg/cli"
Expand Down Expand Up @@ -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())
}
}
10 changes: 10 additions & 0 deletions util/util.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package util

import "io/ioutil"

type Closer interface {
Close() error
}
Expand All @@ -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)
}
}
3 changes: 3 additions & 0 deletions workflow/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/argoproj/argo/util"
"io"
"io/ioutil"
"net/url"
Expand Down Expand Up @@ -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())
}
}
Expand Down

0 comments on commit 270aabf

Please sign in to comment.