Skip to content

Commit

Permalink
Add a check for http response code
Browse files Browse the repository at this point in the history
  • Loading branch information
ubhattacharjya committed Oct 4, 2022
1 parent 0ae333e commit 2e05d8f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions agent/api/appnet/client_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/aws/amazon-ecs-agent/agent/logger"
"github.com/aws/amazon-ecs-agent/agent/logger/field"
"github.com/aws/amazon-ecs-agent/agent/utils/retry"
"github.com/pkg/errors"
prometheus "github.com/prometheus/client_model/go"
)

Expand All @@ -42,6 +43,9 @@ func (cl *client) GetStats(config serviceconnect.RuntimeConfig) (map[string]*pro
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, errors.Wrapf(err, "received non-OK HTTP status %v from Service Connect stats endpoint", resp.StatusCode)
}
return parseServiceConnectStats(resp.Body)
}

Expand Down

0 comments on commit 2e05d8f

Please sign in to comment.