From e7007158c6a9be0f671fed56ec87beb6f8dc8693 Mon Sep 17 00:00:00 2001 From: Beata Skiba Date: Thu, 11 Apr 2019 18:03:02 +0200 Subject: [PATCH] Add logging for errors on adding samples. --- .../pkg/recommender/input/cluster_feeder.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go b/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go index 6f2ebf95189d..d33738a614ba 100644 --- a/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go +++ b/vertical-pod-autoscaler/pkg/recommender/input/cluster_feeder.go @@ -212,10 +212,12 @@ func (feeder *clusterStateFeeder) InitFromHistoryProvider(historyProvider histor ContainerName: containerName} klog.V(4).Infof("Adding %d samples for container %v", len(sampleList), containerID) for _, sample := range sampleList { - feeder.clusterState.AddSample( + if err := feeder.clusterState.AddSample( &model.ContainerUsageSampleWithKey{ ContainerUsageSample: sample, - Container: containerID}) + Container: containerID}); err != nil { + klog.Warningf("Error adding metric sample for container %v: %v", containerID, err) + } } } } @@ -372,13 +374,18 @@ func (feeder *clusterStateFeeder) LoadRealTimeMetrics() { } sampleCount := 0 + droppedSampleCount := 0 for _, containerMetrics := range containersMetrics { for _, sample := range newContainerUsageSamplesWithKey(containerMetrics) { - feeder.clusterState.AddSample(sample) - sampleCount++ + if err := feeder.clusterState.AddSample(sample); err != nil { + klog.Warningf("Error adding metric sample for container %v: %v", sample.Container, err) + droppedSampleCount++ + } else { + sampleCount++ + } } } - klog.V(3).Infof("ClusterSpec fed with #%v ContainerUsageSamples for #%v containers", sampleCount, len(containersMetrics)) + klog.V(3).Infof("ClusterSpec fed with #%v ContainerUsageSamples for #%v containers. Dropped #%v samples.", sampleCount, len(containersMetrics), droppedSampleCount) Loop: for {