Explorar o código

fix bug where err is not returned from query

Signed-off-by: Sean Holcomb <seanholcomb@gmail.com>
Sean Holcomb %!s(int64=2) %!d(string=hai) anos
pai
achega
531ca8f2e8
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  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
 }