-
Notifications
You must be signed in to change notification settings - Fork 4k
/
cluster_feeder.go
539 lines (488 loc) · 20 KB
/
cluster_feeder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package input
import (
"context"
"fmt"
"time"
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
kube_client "k8s.io/client-go/kubernetes"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
v1lister "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/klog/v2"
vpa_types "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/apis/autoscaling.k8s.io/v1"
vpa_api "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/clientset/versioned/typed/autoscaling.k8s.io/v1"
vpa_lister "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/client/listers/autoscaling.k8s.io/v1"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/history"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/metrics"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/oom"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/input/spec"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/recommender/model"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/target"
"k8s.io/autoscaler/vertical-pod-autoscaler/pkg/target/controller_fetcher"
metrics_recommender "k8s.io/autoscaler/vertical-pod-autoscaler/pkg/utils/metrics/recommender"
)
const (
evictionWatchRetryWait = 10 * time.Second
evictionWatchJitterFactor = 0.5
// DefaultRecommenderName recommender name explicitly (and so implicitly specify that the default recommender should handle them)
DefaultRecommenderName = "default"
)
// ClusterStateFeeder can update state of ClusterState object.
type ClusterStateFeeder interface {
// InitFromHistoryProvider loads historical pod spec into clusterState.
InitFromHistoryProvider(historyProvider history.HistoryProvider)
// InitFromCheckpoints loads historical checkpoints into clusterState.
InitFromCheckpoints()
// LoadVPAs updates clusterState with current state of VPAs.
LoadVPAs()
// LoadPods updates clusterState with current specification of Pods and their Containers.
LoadPods()
// LoadRealTimeMetrics updates clusterState with current usage metrics of containers.
LoadRealTimeMetrics()
// GarbageCollectCheckpoints removes historical checkpoints that don't have a matching VPA.
GarbageCollectCheckpoints()
}
// ClusterStateFeederFactory makes instances of ClusterStateFeeder.
type ClusterStateFeederFactory struct {
ClusterState *model.ClusterState
KubeClient kube_client.Interface
MetricsClient metrics.MetricsClient
VpaCheckpointClient vpa_api.VerticalPodAutoscalerCheckpointsGetter
VpaLister vpa_lister.VerticalPodAutoscalerLister
PodLister v1lister.PodLister
OOMObserver oom.Observer
SelectorFetcher target.VpaTargetSelectorFetcher
MemorySaveMode bool
ControllerFetcher controllerfetcher.ControllerFetcher
RecommenderName string
}
// Make creates new ClusterStateFeeder with internal data providers, based on kube client.
func (m ClusterStateFeederFactory) Make() *clusterStateFeeder {
return &clusterStateFeeder{
coreClient: m.KubeClient.CoreV1(),
metricsClient: m.MetricsClient,
oomChan: m.OOMObserver.GetObservedOomsChannel(),
vpaCheckpointClient: m.VpaCheckpointClient,
vpaLister: m.VpaLister,
clusterState: m.ClusterState,
specClient: spec.NewSpecClient(m.PodLister),
selectorFetcher: m.SelectorFetcher,
memorySaveMode: m.MemorySaveMode,
controllerFetcher: m.ControllerFetcher,
recommenderName: m.RecommenderName,
}
}
// WatchEvictionEventsWithRetries watches new Events with reason=Evicted and passes them to the observer.
func WatchEvictionEventsWithRetries(kubeClient kube_client.Interface, observer oom.Observer, namespace string) {
go func() {
options := metav1.ListOptions{
FieldSelector: "reason=Evicted",
}
watchEvictionEventsOnce := func() {
watchInterface, err := kubeClient.CoreV1().Events(namespace).Watch(context.TODO(), options)
if err != nil {
klog.Errorf("Cannot initialize watching events. Reason %v", err)
return
}
watchEvictionEvents(watchInterface.ResultChan(), observer)
}
for {
watchEvictionEventsOnce()
// Wait between attempts, retrying too often breaks API server.
waitTime := wait.Jitter(evictionWatchRetryWait, evictionWatchJitterFactor)
klog.V(1).Infof("An attempt to watch eviction events finished. Waiting %v before the next one.", waitTime)
time.Sleep(waitTime)
}
}()
}
func watchEvictionEvents(evictedEventChan <-chan watch.Event, observer oom.Observer) {
for {
evictedEvent, ok := <-evictedEventChan
if !ok {
klog.V(3).Infof("Eviction event chan closed")
return
}
if evictedEvent.Type == watch.Added {
evictedEvent, ok := evictedEvent.Object.(*apiv1.Event)
if !ok {
continue
}
observer.OnEvent(evictedEvent)
}
}
}
// Creates clients watching pods: PodLister (listing only not terminated pods).
func newPodClients(kubeClient kube_client.Interface, resourceEventHandler cache.ResourceEventHandler, namespace string) v1lister.PodLister {
// We are interested in pods which are Running or Unknown (in case the pod is
// running but there are some transient errors we don't want to delete it from
// our model).
// We don't want to watch Pending pods because they didn't generate any usage
// yet.
// Succeeded and Failed failed pods don't generate any usage anymore but we
// don't necessarily want to immediately delete them.
selector := fields.ParseSelectorOrDie("status.phase!=" + string(apiv1.PodPending))
podListWatch := cache.NewListWatchFromClient(kubeClient.CoreV1().RESTClient(), "pods", namespace, selector)
indexer, controller := cache.NewIndexerInformer(
podListWatch,
&apiv1.Pod{},
time.Hour,
resourceEventHandler,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
podLister := v1lister.NewPodLister(indexer)
stopCh := make(chan struct{})
go controller.Run(stopCh)
return podLister
}
// NewPodListerAndOOMObserver creates pair of pod lister and OOM observer.
func NewPodListerAndOOMObserver(kubeClient kube_client.Interface, namespace string) (v1lister.PodLister, oom.Observer) {
oomObserver := oom.NewObserver()
podLister := newPodClients(kubeClient, oomObserver, namespace)
WatchEvictionEventsWithRetries(kubeClient, oomObserver, namespace)
return podLister, oomObserver
}
type clusterStateFeeder struct {
coreClient corev1.CoreV1Interface
specClient spec.SpecClient
metricsClient metrics.MetricsClient
oomChan <-chan oom.OomInfo
vpaCheckpointClient vpa_api.VerticalPodAutoscalerCheckpointsGetter
vpaLister vpa_lister.VerticalPodAutoscalerLister
clusterState *model.ClusterState
selectorFetcher target.VpaTargetSelectorFetcher
memorySaveMode bool
controllerFetcher controllerfetcher.ControllerFetcher
recommenderName string
}
func (feeder *clusterStateFeeder) InitFromHistoryProvider(historyProvider history.HistoryProvider) {
klog.V(3).Info("Initializing VPA from history provider")
clusterHistory, err := historyProvider.GetClusterHistory()
if err != nil {
klog.Errorf("Cannot get cluster history: %v", err)
}
for podID, podHistory := range clusterHistory {
klog.V(4).Infof("Adding pod %v with labels %v", podID, podHistory.LastLabels)
feeder.clusterState.AddOrUpdatePod(podID, podHistory.LastLabels, apiv1.PodUnknown)
for containerName, sampleList := range podHistory.Samples {
containerID := model.ContainerID{
PodID: podID,
ContainerName: containerName,
}
if err = feeder.clusterState.AddOrUpdateContainer(containerID, nil); err != nil {
klog.Warningf("Failed to add container %+v. Reason: %+v", containerID, err)
}
klog.V(4).Infof("Adding %d samples for container %v", len(sampleList), containerID)
for _, sample := range sampleList {
if err := feeder.clusterState.AddSample(
&model.ContainerUsageSampleWithKey{
ContainerUsageSample: sample,
Container: containerID,
}); err != nil {
klog.Warningf("Error adding metric sample for container %v: %v", containerID, err)
}
}
}
}
}
func (feeder *clusterStateFeeder) setVpaCheckpoint(checkpoint *vpa_types.VerticalPodAutoscalerCheckpoint) error {
vpaID := model.VpaID{Namespace: checkpoint.Namespace, VpaName: checkpoint.Spec.VPAObjectName}
vpa, exists := feeder.clusterState.Vpas[vpaID]
if !exists {
return fmt.Errorf("cannot load checkpoint to missing VPA object %+v", vpaID)
}
cs := model.NewAggregateContainerState()
err := cs.LoadFromCheckpoint(&checkpoint.Status)
if err != nil {
return fmt.Errorf("cannot load checkpoint for VPA %+v. Reason: %v", vpa.ID, err)
}
vpa.ContainersInitialAggregateState[checkpoint.Spec.ContainerName] = cs
return nil
}
func (feeder *clusterStateFeeder) InitFromCheckpoints() {
klog.V(3).Info("Initializing VPA from checkpoints")
feeder.LoadVPAs()
namespaces := make(map[string]bool)
for _, v := range feeder.clusterState.Vpas {
namespaces[v.ID.Namespace] = true
}
for namespace := range namespaces {
klog.V(3).Infof("Fetching checkpoints from namespace %s", namespace)
checkpointList, err := feeder.vpaCheckpointClient.VerticalPodAutoscalerCheckpoints(namespace).List(context.TODO(), metav1.ListOptions{})
if err != nil {
klog.Errorf("Cannot list VPA checkpoints from namespace %v. Reason: %+v", namespace, err)
}
for _, checkpoint := range checkpointList.Items {
klog.V(3).Infof("Loading VPA %s/%s checkpoint for %s", checkpoint.ObjectMeta.Namespace, checkpoint.Spec.VPAObjectName, checkpoint.Spec.ContainerName)
err = feeder.setVpaCheckpoint(&checkpoint)
if err != nil {
klog.Errorf("Error while loading checkpoint. Reason: %+v", err)
}
}
}
}
func (feeder *clusterStateFeeder) GarbageCollectCheckpoints() {
klog.V(3).Info("Starting garbage collection of checkpoints")
feeder.LoadVPAs()
namespaceList, err := feeder.coreClient.Namespaces().List(context.TODO(), metav1.ListOptions{})
if err != nil {
klog.Errorf("Cannot list namespaces. Reason: %+v", err)
return
}
for _, namespaceItem := range namespaceList.Items {
namespace := namespaceItem.Name
checkpointList, err := feeder.vpaCheckpointClient.VerticalPodAutoscalerCheckpoints(namespace).List(context.TODO(), metav1.ListOptions{})
if err != nil {
klog.Errorf("Cannot list VPA checkpoints from namespace %v. Reason: %+v", namespace, err)
}
for _, checkpoint := range checkpointList.Items {
vpaID := model.VpaID{Namespace: checkpoint.Namespace, VpaName: checkpoint.Spec.VPAObjectName}
_, exists := feeder.clusterState.Vpas[vpaID]
if !exists {
err = feeder.vpaCheckpointClient.VerticalPodAutoscalerCheckpoints(namespace).Delete(context.TODO(), checkpoint.Name, metav1.DeleteOptions{})
if err == nil {
klog.V(3).Infof("Orphaned VPA checkpoint cleanup - deleting %v/%v.", namespace, checkpoint.Name)
} else {
klog.Errorf("Cannot delete VPA checkpoint %v/%v. Reason: %+v", namespace, checkpoint.Name, err)
}
}
}
}
}
func implicitDefaultRecommender(selectors []*vpa_types.VerticalPodAutoscalerRecommenderSelector) bool {
return len(selectors) == 0
}
func selectsRecommender(selectors []*vpa_types.VerticalPodAutoscalerRecommenderSelector, name *string) bool {
for _, s := range selectors {
if s.Name == *name {
return true
}
}
return false
}
// Filter VPA objects whose specified recommender names are not default
func filterVPAs(feeder *clusterStateFeeder, allVpaCRDs []*vpa_types.VerticalPodAutoscaler) []*vpa_types.VerticalPodAutoscaler {
klog.V(3).Infof("Start selecting the vpaCRDs.")
var vpaCRDs []*vpa_types.VerticalPodAutoscaler
for _, vpaCRD := range allVpaCRDs {
if feeder.recommenderName == DefaultRecommenderName {
if !implicitDefaultRecommender(vpaCRD.Spec.Recommenders) && !selectsRecommender(vpaCRD.Spec.Recommenders, &feeder.recommenderName) {
klog.V(6).Infof("Ignoring vpaCRD %s in namespace %s as current recommender's name %v doesn't appear among its recommenders", vpaCRD.Name, vpaCRD.Namespace, feeder.recommenderName)
continue
}
} else {
if implicitDefaultRecommender(vpaCRD.Spec.Recommenders) {
klog.V(6).Infof("Ignoring vpaCRD %s in namespace %s as %v recommender doesn't process CRDs implicitly destined to %v recommender", vpaCRD.Name, vpaCRD.Namespace, feeder.recommenderName, DefaultRecommenderName)
continue
}
if !selectsRecommender(vpaCRD.Spec.Recommenders, &feeder.recommenderName) {
klog.V(6).Infof("Ignoring vpaCRD %s in namespace %s as current recommender's name %v doesn't appear among its recommenders", vpaCRD.Name, vpaCRD.Namespace, feeder.recommenderName)
continue
}
}
vpaCRDs = append(vpaCRDs, vpaCRD)
}
return vpaCRDs
}
// LoadVPAs fetches VPA objects and loads them into the cluster state.
func (feeder *clusterStateFeeder) LoadVPAs() {
// List VPA API objects.
allVpaCRDs, err := feeder.vpaLister.List(labels.Everything())
if err != nil {
klog.Errorf("Cannot list VPAs. Reason: %+v", err)
return
}
// Filter out VPAs that specified recommenders with names not equal to "default"
vpaCRDs := filterVPAs(feeder, allVpaCRDs)
klog.V(3).Infof("Fetched %d VPAs.", len(vpaCRDs))
// Add or update existing VPAs in the model.
vpaKeys := make(map[model.VpaID]bool)
for _, vpaCRD := range vpaCRDs {
vpaID := model.VpaID{
Namespace: vpaCRD.Namespace,
VpaName: vpaCRD.Name,
}
selector, conditions := feeder.getSelector(vpaCRD)
klog.V(4).Infof("Using selector %s for VPA %s/%s", selector.String(), vpaCRD.Namespace, vpaCRD.Name)
if feeder.clusterState.AddOrUpdateVpa(vpaCRD, selector) == nil {
// Successfully added VPA to the model.
vpaKeys[vpaID] = true
for _, condition := range conditions {
if condition.delete {
delete(feeder.clusterState.Vpas[vpaID].Conditions, condition.conditionType)
} else {
feeder.clusterState.Vpas[vpaID].Conditions.Set(condition.conditionType, true, "", condition.message)
}
}
}
}
// Delete non-existent VPAs from the model.
for vpaID := range feeder.clusterState.Vpas {
if _, exists := vpaKeys[vpaID]; !exists {
klog.V(3).Infof("Deleting VPA %v", vpaID)
if err := feeder.clusterState.DeleteVpa(vpaID); err != nil {
klog.Errorf("Deleting VPA %v failed: %v", vpaID, err)
}
}
}
feeder.clusterState.ObservedVpas = vpaCRDs
}
// LoadPods loads pod into the cluster state.
func (feeder *clusterStateFeeder) LoadPods() {
podSpecs, err := feeder.specClient.GetPodSpecs()
if err != nil {
klog.Errorf("Cannot get SimplePodSpecs. Reason: %+v", err)
}
pods := make(map[model.PodID]*spec.BasicPodSpec)
for _, spec := range podSpecs {
pods[spec.ID] = spec
}
for key := range feeder.clusterState.Pods {
if _, exists := pods[key]; !exists {
klog.V(3).Infof("Deleting Pod %v", key)
feeder.clusterState.DeletePod(key)
}
}
for _, pod := range pods {
if feeder.memorySaveMode && !feeder.matchesVPA(pod) {
continue
}
feeder.clusterState.AddOrUpdatePod(pod.ID, pod.PodLabels, pod.Phase)
for _, container := range pod.Containers {
if err = feeder.clusterState.AddOrUpdateContainer(container.ID, container.Request); err != nil {
klog.Warningf("Failed to add container %+v. Reason: %+v", container.ID, err)
}
}
}
}
func (feeder *clusterStateFeeder) LoadRealTimeMetrics() {
containersMetrics, err := feeder.metricsClient.GetContainersMetrics()
if err != nil {
klog.Errorf("Cannot get ContainerMetricsSnapshot from MetricsClient. Reason: %+v", err)
}
sampleCount := 0
droppedSampleCount := 0
for _, containerMetrics := range containersMetrics {
for _, sample := range newContainerUsageSamplesWithKey(containerMetrics) {
if err := feeder.clusterState.AddSample(sample); err != nil {
// Not all pod states are tracked in memory saver mode
if _, isKeyError := err.(model.KeyError); isKeyError && feeder.memorySaveMode {
continue
}
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. Dropped #%v samples.", sampleCount, len(containersMetrics), droppedSampleCount)
Loop:
for {
select {
case oomInfo := <-feeder.oomChan:
klog.V(3).Infof("OOM detected %+v", oomInfo)
if err = feeder.clusterState.RecordOOM(oomInfo.ContainerID, oomInfo.Timestamp, oomInfo.Memory); err != nil {
klog.Warningf("Failed to record OOM %+v. Reason: %+v", oomInfo, err)
}
default:
break Loop
}
}
metrics_recommender.RecordAggregateContainerStatesCount(feeder.clusterState.StateMapSize())
}
func (feeder *clusterStateFeeder) matchesVPA(pod *spec.BasicPodSpec) bool {
for vpaKey, vpa := range feeder.clusterState.Vpas {
podLabels := labels.Set(pod.PodLabels)
if vpaKey.Namespace == pod.ID.Namespace && vpa.PodSelector.Matches(podLabels) {
return true
}
}
return false
}
func newContainerUsageSamplesWithKey(metrics *metrics.ContainerMetricsSnapshot) []*model.ContainerUsageSampleWithKey {
var samples []*model.ContainerUsageSampleWithKey
for metricName, resourceAmount := range metrics.Usage {
sample := &model.ContainerUsageSampleWithKey{
Container: metrics.ID,
ContainerUsageSample: model.ContainerUsageSample{
MeasureStart: metrics.SnapshotTime,
Resource: metricName,
Usage: resourceAmount,
},
}
samples = append(samples, sample)
}
return samples
}
type condition struct {
conditionType vpa_types.VerticalPodAutoscalerConditionType
delete bool
message string
}
func (feeder *clusterStateFeeder) validateTargetRef(vpa *vpa_types.VerticalPodAutoscaler) (bool, condition) {
//
if vpa.Spec.TargetRef == nil {
return false, condition{}
}
k := controllerfetcher.ControllerKeyWithAPIVersion{
ControllerKey: controllerfetcher.ControllerKey{
Namespace: vpa.Namespace,
Kind: vpa.Spec.TargetRef.Kind,
Name: vpa.Spec.TargetRef.Name,
},
ApiVersion: vpa.Spec.TargetRef.APIVersion,
}
top, err := feeder.controllerFetcher.FindTopMostWellKnownOrScalable(&k)
if err != nil {
return false, condition{conditionType: vpa_types.ConfigUnsupported, delete: false, message: fmt.Sprintf("Error checking if target is a topmost well-known or scalable controller: %s", err)}
}
if top == nil {
return false, condition{conditionType: vpa_types.ConfigUnsupported, delete: false, message: fmt.Sprintf("Unknown error during checking if target is a topmost well-known or scalable controller: %s", err)}
}
if *top != k {
return false, condition{conditionType: vpa_types.ConfigUnsupported, delete: false, message: "The targetRef controller has a parent but it should point to a topmost well-known or scalable controller"}
}
return true, condition{}
}
func (feeder *clusterStateFeeder) getSelector(vpa *vpa_types.VerticalPodAutoscaler) (labels.Selector, []condition) {
selector, fetchErr := feeder.selectorFetcher.Fetch(vpa)
if selector != nil {
validTargetRef, unsupportedCondition := feeder.validateTargetRef(vpa)
if !validTargetRef {
return labels.Nothing(), []condition{
unsupportedCondition,
{conditionType: vpa_types.ConfigDeprecated, delete: true},
}
}
return selector, []condition{
{conditionType: vpa_types.ConfigUnsupported, delete: true},
{conditionType: vpa_types.ConfigDeprecated, delete: true},
}
}
msg := "Cannot read targetRef"
if fetchErr != nil {
klog.Errorf("Cannot get target selector from VPA's targetRef. Reason: %+v", fetchErr)
msg = fmt.Sprintf("Cannot read targetRef. Reason: %s", fetchErr.Error())
}
return labels.Nothing(), []condition{
{conditionType: vpa_types.ConfigUnsupported, delete: false, message: msg},
{conditionType: vpa_types.ConfigDeprecated, delete: true},
}
}