Skip to content

Commit

Permalink
Merge pull request #148 from brancz/empty-err
Browse files Browse the repository at this point in the history
Fix empty pod or node list resulting in an error
  • Loading branch information
brancz authored Dec 14, 2018
2 parents 1e5a868 + 7624952 commit dce283d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/resourceprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ type nsQueryResults struct {
err error
}

// GetContainerMetrics implements the provider.MetricsProvider interface. It may return nil, nil, nil.
func (p *resourceProvider) GetContainerMetrics(pods ...apitypes.NamespacedName) ([]provider.TimeInfo, [][]metrics.ContainerMetrics, error) {
if len(pods) == 0 {
return nil, nil, fmt.Errorf("no pods to fetch metrics for")
return nil, nil, nil
}

// TODO(directxman12): figure out how well this scales if we go to list 1000+ pods
Expand Down Expand Up @@ -238,9 +239,10 @@ func (p *resourceProvider) assignForPod(pod apitypes.NamespacedName, resultsByNs
*resMetrics = containerMetricsList
}

// GetNodeMetrics implements the provider.MetricsProvider interface. It may return nil, nil, nil.
func (p *resourceProvider) GetNodeMetrics(nodes ...string) ([]provider.TimeInfo, []corev1.ResourceList, error) {
if len(nodes) == 0 {
return nil, nil, fmt.Errorf("no nodes to fetch metrics for")
return nil, nil, nil
}

now := pmodel.Now()
Expand Down

0 comments on commit dce283d

Please sign in to comment.