Sfoglia il codice sorgente

Merge pull request #12302 from grafana/12199_cloudwatch_panic

cloudwatch: handle invalid time range
Carl Bergquist 7 anni fa
parent
commit
e2adb4ced5
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5 0
      pkg/tsdb/cloudwatch/cloudwatch.go

+ 5 - 0
pkg/tsdb/cloudwatch/cloudwatch.go

@@ -3,6 +3,7 @@ package cloudwatch
 import (
 	"context"
 	"errors"
+	"fmt"
 	"regexp"
 	"sort"
 	"strconv"
@@ -144,6 +145,10 @@ func (e *CloudWatchExecutor) executeQuery(ctx context.Context, parameters *simpl
 		return nil, err
 	}
 
+	if endTime.Before(startTime) {
+		return nil, fmt.Errorf("Invalid time range: End time can't be before start time")
+	}
+
 	params := &cloudwatch.GetMetricStatisticsInput{
 		Namespace:  aws.String(query.Namespace),
 		MetricName: aws.String(query.MetricName),