Commit 77e651ae authored by mattjmcnaughton's avatar mattjmcnaughton

Clarify error messages in HPA metrics

With the introduction of the RESTMetrics client, there are two ways to fetch metrics for auto-scaling. However, they previously shared error messages. This could be misleading. Make the error message more clearly show which method is in use.
parent da9a4d5d
...@@ -58,11 +58,11 @@ type resourceMetricsClient struct { ...@@ -58,11 +58,11 @@ type resourceMetricsClient struct {
func (c *resourceMetricsClient) GetResourceMetric(resource v1.ResourceName, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) { func (c *resourceMetricsClient) GetResourceMetric(resource v1.ResourceName, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) {
metrics, err := c.client.PodMetricses(namespace).List(metav1.ListOptions{LabelSelector: selector.String()}) metrics, err := c.client.PodMetricses(namespace).List(metav1.ListOptions{LabelSelector: selector.String()})
if err != nil { if err != nil {
return nil, time.Time{}, fmt.Errorf("unable to fetch metrics from API: %v", err) return nil, time.Time{}, fmt.Errorf("unable to fetch metrics from resource metrics API: %v", err)
} }
if len(metrics.Items) == 0 { if len(metrics.Items) == 0 {
return nil, time.Time{}, fmt.Errorf("no metrics returned from heapster") return nil, time.Time{}, fmt.Errorf("no metrics returned from resource metrics API")
} }
res := make(PodMetricsInfo, len(metrics.Items)) res := make(PodMetricsInfo, len(metrics.Items))
...@@ -101,7 +101,7 @@ type customMetricsClient struct { ...@@ -101,7 +101,7 @@ type customMetricsClient struct {
func (c *customMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) { func (c *customMetricsClient) GetRawMetric(metricName string, namespace string, selector labels.Selector) (PodMetricsInfo, time.Time, error) {
metrics, err := c.client.NamespacedMetrics(namespace).GetForObjects(schema.GroupKind{Kind: "Pod"}, selector, metricName) metrics, err := c.client.NamespacedMetrics(namespace).GetForObjects(schema.GroupKind{Kind: "Pod"}, selector, metricName)
if err != nil { if err != nil {
return nil, time.Time{}, fmt.Errorf("unable to fetch metrics from API: %v", err) return nil, time.Time{}, fmt.Errorf("unable to fetch metrics from custom metrics API: %v", err)
} }
if len(metrics.Items) == 0 { if len(metrics.Items) == 0 {
...@@ -134,7 +134,7 @@ func (c *customMetricsClient) GetObjectMetric(metricName string, namespace strin ...@@ -134,7 +134,7 @@ func (c *customMetricsClient) GetObjectMetric(metricName string, namespace strin
} }
if err != nil { if err != nil {
return 0, time.Time{}, fmt.Errorf("unable to fetch metrics from API: %v", err) return 0, time.Time{}, fmt.Errorf("unable to fetch metrics from custom metrics API: %v", err)
} }
return metricValue.Value.MilliValue(), metricValue.Timestamp.Time, nil return metricValue.Value.MilliValue(), metricValue.Timestamp.Time, nil
......
...@@ -252,7 +252,7 @@ func TestRESTClientQpsSumEqualZero(t *testing.T) { ...@@ -252,7 +252,7 @@ func TestRESTClientQpsSumEqualZero(t *testing.T) {
func TestRESTClientCPUEmptyMetrics(t *testing.T) { func TestRESTClientCPUEmptyMetrics(t *testing.T) {
tc := restClientTestCase{ tc := restClientTestCase{
resourceName: v1.ResourceCPU, resourceName: v1.ResourceCPU,
desiredError: fmt.Errorf("no metrics returned from heapster"), desiredError: fmt.Errorf("no metrics returned from resource metrics API"),
reportedMetricPoints: []metricPoint{}, reportedMetricPoints: []metricPoint{},
reportedPodMetrics: [][]int64{}, reportedPodMetrics: [][]int64{},
} }
......
...@@ -579,7 +579,7 @@ func TestReplicaCalcMissingMetrics(t *testing.T) { ...@@ -579,7 +579,7 @@ func TestReplicaCalcMissingMetrics(t *testing.T) {
func TestReplicaCalcEmptyMetrics(t *testing.T) { func TestReplicaCalcEmptyMetrics(t *testing.T) {
tc := replicaCalcTestCase{ tc := replicaCalcTestCase{
currentReplicas: 4, currentReplicas: 4,
expectedError: fmt.Errorf("unable to get metrics for resource cpu: no metrics returned from heapster"), expectedError: fmt.Errorf("unable to get metrics for resource cpu: no metrics returned from resource metrics API"),
resource: &resourceInfo{ resource: &resourceInfo{
name: v1.ResourceCPU, name: v1.ResourceCPU,
requests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")}, requests: []resource.Quantity{resource.MustParse("1.0"), resource.MustParse("1.0"), resource.MustParse("1.0")},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment