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 {