Skip to content

Commit fb6c69a

Browse files
Improve QueryAllLogs.
1 parent 16386f5 commit fb6c69a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

integration_test/gce-testing-internal/gce/gce_testing.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ func shouldRetryHasMatchingLog(err error) bool {
655655
strings.Contains(err.Error(), "Internal error encountered")
656656
}
657657

658-
// QueryLog looks in the logging backend for logs matching the given query,
658+
// QueryLog looks in the logging backend a log matching the given query,
659659
// over the trailing time interval specified by the given window.
660660
// Returns the first log entry found, or an error if the log could not be
661661
// found after some retries.
@@ -677,9 +677,11 @@ func QueryLog(ctx context.Context, logger *log.Logger, vm *VM, logNameRegex stri
677677
func QueryAllLogs(ctx context.Context, logger *log.Logger, vm *VM, logNameRegex string, window time.Duration, query string, maxAttempts int) ([]*cloudlogging.Entry, error) {
678678
for attempt := 1; attempt <= maxAttempts; attempt++ {
679679
matchingLogs, err := findMatchingLogs(ctx, logger, vm, logNameRegex, window, query)
680-
if len(matchingLogs) > 0 {
681-
// Success.
682-
return matchingLogs, nil
680+
if err == nil {
681+
if len(matchingLogs) > 0 {
682+
// Success.
683+
return matchingLogs, nil
684+
}
683685
}
684686
logger.Printf("Query returned matchingLogs=%v, err=%v, attempt=%d", matchingLogs, err, attempt)
685687
if err != nil && !shouldRetryHasMatchingLog(err) {

0 commit comments

Comments
 (0)