Skip to content

Commit

Permalink
feat: longer status messages
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed May 20, 2021
1 parent 9bef0df commit e4a4b1a
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 46 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## v0.0.16 (2021-05-19)


### Contributors


## v0.0.15 (2021-05-19)

* [9bef0df](https://github.com/argoproj/argo-workflows/commit/9bef0df2ec1eb398f63c9ba4b99be76b8b08aee8) feat: expose pod failure reason

### Contributors

* Alex Collins

## v0.0.14 (2021-05-18)

* [2a23cb8](https://github.com/argoproj/argo-workflows/commit/2a23cb8abc4343272d4dd04f493d888694923114) fix: scale to 1 rather than 0 on start
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1alpha1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type Error struct {
// +kubebuilder:validation:MaxLength=32
// +kubebuilder:validation:MaxLength=64
Message string `json:"message" protobuf:"bytes,1,opt,name=message"`
Time metav1.Time `json:"time" protobuf:"bytes,2,opt,name=time"`
}
4 changes: 2 additions & 2 deletions api/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/v1alpha1/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1alpha1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

type Message struct {
// +kubebuilder:validation:MaxLength=32
// +kubebuilder:validation:MaxLength=64
Data string `json:"data" protobuf:"bytes,1,opt,name=data"`
Time metav1.Time `json:"time" protobuf:"bytes,2,opt,name=time"`
}
4 changes: 2 additions & 2 deletions api/v1alpha1/source_statuses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestSourceStatuses_Set(t *testing.T) {
if assert.Len(t, ss, 1) {
s := ss["bar"]
if assert.NotNil(t, s.LastMessage) {
assert.Equal(t, "xxxxxxxxxxxxxxx...xxxxxxxxxxxxxx", s.LastMessage.Data)
assert.NotEmpty(t, s.LastMessage.Data)
}
if assert.Len(t, s.Metrics, 1) {
assert.Equal(t, uint64(1), s.Metrics["1"].Total)
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestSourceStatuses_IncErrors(t *testing.T) {
err := errors.New(strings.Repeat("x", 33))
ss.IncErrors("foo", 0, err)
assert.Equal(t, uint64(1), ss["foo"].Metrics["0"].Errors)
assert.Equal(t, "xxxxxxxxxxxxxxx...xxxxxxxxxxxxxx", ss["foo"].LastError.Message)
assert.NotEmpty(t, ss["foo"].LastError.Message)
assert.NotEmpty(t, ss["foo"].LastError.Time)
ss.IncErrors("foo", 0, err)
assert.Equal(t, uint64(2), ss["foo"].Metrics["0"].Errors)
Expand Down
9 changes: 7 additions & 2 deletions api/v1alpha1/trunc.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package v1alpha1

func trunc(msg string) string {
if len(msg) > 32 {
return msg[0:15] + "..." + msg[len(msg)-14:]
return truncN(msg, 64)
}

func truncN(msg string, n int) string {
x := n / 2
if len(msg) > n {
return msg[0:x-1] + "..." + msg[len(msg)-x+2:]
}
return msg
}
24 changes: 12 additions & 12 deletions api/v1alpha1/trunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import (
)

func Test_trunc(t *testing.T) {
t.Run("31", func(t *testing.T) {
x := trunc(strings.Repeat("x", 31))
assert.Len(t, x, 31)
assert.Equal(t, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", x)
t.Run("63", func(t *testing.T) {
x := trunc(strings.Repeat("x", 63))
assert.Len(t, x, 63)
assert.Equal(t, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", x)
})
t.Run("32", func(t *testing.T) {
x := trunc(strings.Repeat("x", 32))
assert.Len(t, x, 32)
assert.Equal(t, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", x)
t.Run("64", func(t *testing.T) {
x := trunc(strings.Repeat("x", 64))
assert.Len(t, x, 64)
assert.Equal(t, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", x)
})
t.Run("33", func(t *testing.T) {
x := trunc(strings.Repeat("x", 33))
assert.Len(t, x, 32)
assert.Equal(t, "xxxxxxxxxxxxxxx...xxxxxxxxxxxxxx", x)
t.Run("65", func(t *testing.T) {
x := trunc(strings.Repeat("x", 65))
assert.Len(t, x, 64)
assert.Equal(t, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", x)
})
}
8 changes: 4 additions & 4 deletions config/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3615,7 +3615,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -3627,7 +3627,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down Expand Up @@ -3655,7 +3655,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -3667,7 +3667,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/dataflow.argoproj.io_steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2662,7 +2662,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -2674,7 +2674,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down Expand Up @@ -2702,7 +2702,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -2714,7 +2714,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down
8 changes: 4 additions & 4 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3615,7 +3615,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -3627,7 +3627,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down Expand Up @@ -3655,7 +3655,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -3667,7 +3667,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down
8 changes: 4 additions & 4 deletions config/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3615,7 +3615,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -3627,7 +3627,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down Expand Up @@ -3655,7 +3655,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -3667,7 +3667,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down
8 changes: 4 additions & 4 deletions config/quick-start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3615,7 +3615,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -3627,7 +3627,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down Expand Up @@ -3655,7 +3655,7 @@ spec:
lastError:
properties:
message:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand All @@ -3667,7 +3667,7 @@ spec:
lastMessage:
properties:
data:
maxLength: 32
maxLength: 64
type: string
time:
format: date-time
Expand Down
12 changes: 6 additions & 6 deletions runner/sidecar/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func Exec(ctx context.Context) error {
}

go func() {
defer runtimeutil.HandleCrash(runtimeutil.PanicHandlers...)
defer runtimeutil.HandleCrash()
lastStatus := &dfv1.StepStatus{}
for {
status := &dfv1.StepStatus{
Expand Down Expand Up @@ -279,7 +279,7 @@ func connectSources(ctx context.Context, toMain func([]byte) error) error {
} else {
closers = append(closers, sub.Close)
go func() {
defer runtimeutil.HandleCrash(runtimeutil.PanicHandlers...)
defer runtimeutil.HandleCrash()
for {
if pending, _, err := sub.Pending(); err != nil {
logger.Error(err, "failed to get pending", "subject", x.Subject)
Expand Down Expand Up @@ -311,13 +311,13 @@ func connectSources(ctx context.Context, toMain func([]byte) error) error {
closers = append(closers, group.Close)
handler := &handler{sourceName, toMain, 0}
go func() {
defer runtimeutil.HandleCrash(runtimeutil.PanicHandlers...)
defer runtimeutil.HandleCrash()
if err := group.Consume(ctx, []string{x.Topic}, handler); err != nil {
logger.Error(err, "failed to create kafka consumer")
}
}()
go func() {
defer runtimeutil.HandleCrash(runtimeutil.PanicHandlers...)
defer runtimeutil.HandleCrash()
for {
if partitions, err := client.Partitions(x.Topic); err != nil {
logger.Error(err, "failed to get offset", "topic", x.Topic)
Expand Down Expand Up @@ -451,7 +451,7 @@ func connectTo(ctx context.Context) (func([]byte) error, error) {
func connectOut(toSink func([]byte) error) {
logger.Info("FIFO out interface configured")
go func() {
defer runtimeutil.HandleCrash(runtimeutil.PanicHandlers...)
defer runtimeutil.HandleCrash()
err := func() error {
fifo, err := os.OpenFile(dfv1.PathFIFOOut, os.O_RDONLY, os.ModeNamedPipe)
if err != nil {
Expand Down Expand Up @@ -497,7 +497,7 @@ func connectOut(toSink func([]byte) error) {
}
})
go func() {
defer runtimeutil.HandleCrash(runtimeutil.PanicHandlers...)
defer runtimeutil.HandleCrash()
logger.Info("starting HTTP server")
err := http.ListenAndServe(":3569", nil)
if err != nil {
Expand Down

0 comments on commit e4a4b1a

Please sign in to comment.