Просмотр исходного кода

Merge pull request #2260 from opencost/sean/bugfix/big-query-nil-iter

return err from query
Sean Holcomb 2 лет назад
Родитель
Сommit
e7028f6e61
1 измененных файлов с 6 добавлено и 2 удалено
  1. 6 2
      pkg/cloud/gcp/bigqueryquerier.go

+ 6 - 2
pkg/cloud/gcp/bigqueryquerier.go

@@ -2,6 +2,7 @@ package gcp
 
 import (
 	"context"
+	"fmt"
 
 	"cloud.google.com/go/bigquery"
 	"github.com/opencost/opencost/pkg/cloud"
@@ -49,9 +50,12 @@ func (bqq *BigQueryQuerier) Query(ctx context.Context, queryStr string) (*bigque
 	// If result is empty and connection status is not already successful update status to missing data
 	if iter == nil && bqq.ConnectionStatus != cloud.SuccessfulConnection {
 		bqq.ConnectionStatus = cloud.MissingData
-		return iter, nil
+	} else {
+		bqq.ConnectionStatus = cloud.SuccessfulConnection
 	}
 
-	bqq.ConnectionStatus = cloud.SuccessfulConnection
+	if err != nil {
+		return iter, fmt.Errorf("BigQueryQuerier: Query: error reading query results: %w", err)
+	}
 	return iter, nil
 }