Skip to content

Commit

Permalink
Add check for host process container before reading from hcshim (amaz…
Browse files Browse the repository at this point in the history
  • Loading branch information
KlwntSingh authored Feb 1, 2024
1 parent 6cd1657 commit fc380a1
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ func NewHnSProvider(logger *zap.Logger, info cExtractor.CPUMemInfoProvider, mext
}

func (hp *HCSStatsProvider) GetMetrics() ([]*cExtractor.CAdvisorMetric, error) {
containerToEndpointMap, err := hp.getContainerToEndpointMap()
if err != nil {
hp.logger.Error("failed to create container to endpoint map using HCS shim APIs, ", zap.Error(err))
return nil, err
var metrics []*cExtractor.CAdvisorMetric
if ci.IsWindowsHostProcessContainer() {
containerToEndpointMap, err := hp.getContainerToEndpointMap()
if err != nil {
hp.logger.Error("failed to create container to endpoint map using HCS shim APIs, ", zap.Error(err))
return nil, err
}
hp.containerToEndpoint = containerToEndpointMap
return hp.getPodMetrics()
}
hp.containerToEndpoint = containerToEndpointMap
return hp.getPodMetrics()
return metrics, nil
}

func (hp *HCSStatsProvider) getContainerMetrics(containerId string) (extractors.HCSStat, error) {
Expand Down

0 comments on commit fc380a1

Please sign in to comment.