Skip to content

Commit b69e713

Browse files
committed
First check if LogGroup exists
1 parent a52dee4 commit b69e713

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/pkg/clouds/aws/ecs/stream.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,26 @@ func QueryAndTailLogGroup(ctx context.Context, lgi LogGroupInput, start time.Tim
1919
ch: make(chan types.StartLiveTailResponseStream),
2020
}
2121

22-
// TODO: call TailLogGroup once to check if the log group exists or we have another error
22+
// First call TailLogGroup once to check if the log group exists or we have another error
23+
eventStream, err := TailLogGroup(ctx, lgi)
24+
if err != nil {
25+
var resourceNotFound *types.ResourceNotFoundException
26+
if !errors.As(err, &resourceNotFound) {
27+
return nil, err
28+
}
29+
}
2330

24-
// Start goroutine to wait for the log group to be created for the resource not found log groups
31+
// Start goroutine to wait for the log group to be created and then tail it
2532
go func() {
2633
defer close(es.ch)
2734

28-
eventStream, err := pollTailLogGroup(ctx, lgi)
29-
if err != nil {
30-
es.err = err
31-
return
35+
if eventStream == nil {
36+
// If the log group does not exist yet, poll until it does
37+
eventStream, err = pollTailLogGroup(ctx, lgi)
38+
if err != nil {
39+
es.err = err
40+
return
41+
}
3242
}
3343
defer eventStream.Close()
3444

0 commit comments

Comments
 (0)