pkg: propagate metric providers context

In custom-metrics-apiserver v1.22.0, contexts were added to the metric
providers. We can benefit from that by propagating the context given to
the provider down to the requests.

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
This commit is contained in:
Damien Grisonnet 2021-08-11 17:00:26 +02:00
parent 4264c97f7b
commit 8b85c68c9e
2 changed files with 5 additions and 5 deletions

View file

@ -51,7 +51,7 @@ func (p *externalPrometheusProvider) GetExternalMetric(ctx context.Context, name
return nil, provider.NewMetricNotFoundError(p.selectGroupResource(namespace), info.Metric)
}
// Here is where we're making the query, need to be before here xD
queryResults, err := p.promClient.Query(context.TODO(), pmodel.Now(), selector)
queryResults, err := p.promClient.Query(ctx, pmodel.Now(), selector)
if err != nil {
klog.Errorf("unable to fetch metrics from prometheus: %v", err)