@@ -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
677677func 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