fix(input/prometheus): move err check to correct place (#9920)

This commit is contained in:
Sebastian Spaink 2021-10-13 14:43:05 -05:00 committed by GitHub
parent 97e19ebd55
commit 432b30d2e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -154,12 +154,11 @@ func (p *Prometheus) cAdvisor(ctx context.Context, bearerToken string) error {
// The request will be the same each time
podsURL := fmt.Sprintf("https://%s:10250/pods", p.NodeIP)
req, err := http.NewRequest("GET", podsURL, nil)
req.Header.Set("Authorization", "Bearer "+bearerToken)
req.Header.Add("Accept", "application/json")
if err != nil {
return fmt.Errorf("error when creating request to %s to get pod list: %w", podsURL, err)
}
req.Header.Set("Authorization", "Bearer "+bearerToken)
req.Header.Add("Accept", "application/json")
// Update right away so code is not waiting the length of the specified scrape interval initially
err = updateCadvisorPodList(p, req)