@@ -35,6 +35,33 @@ const (
35
35
RecommendationMissingMaxDuration = 30 * time .Minute
36
36
)
37
37
38
+ // ClusterState holds all runtime information about the cluster required for the
39
+ // VPA operations, i.e. configuration of resources (pods, containers,
40
+ // VPA objects), aggregated utilization of compute resources (CPU, memory) and
41
+ // events (container OOMs).
42
+ // All input to the VPA Recommender algorithm lives in this structure.
43
+ type ClusterState interface {
44
+ StateMapSize () int
45
+ AddOrUpdatePod (podID PodID , newLabels labels.Set , phase apiv1.PodPhase )
46
+ GetContainer (containerID ContainerID ) * ContainerState
47
+ DeletePod (podID PodID )
48
+ AddOrUpdateContainer (containerID ContainerID , request Resources ) error
49
+ AddSample (sample * ContainerUsageSampleWithKey ) error
50
+ RecordOOM (containerID ContainerID , timestamp time.Time , requestedMemory ResourceAmount ) error
51
+ AddOrUpdateVpa (apiObject * vpa_types.VerticalPodAutoscaler , selector labels.Selector ) error
52
+ DeleteVpa (vpaID VpaID ) error
53
+ MakeAggregateStateKey (pod * PodState , containerName string ) AggregateStateKey
54
+ RateLimitedGarbageCollectAggregateCollectionStates (ctx context.Context , now time.Time , controllerFetcher controllerfetcher.ControllerFetcher )
55
+ RecordRecommendation (vpa * Vpa , now time.Time ) error
56
+ GetMatchingPods (vpa * Vpa ) []PodID
57
+ GetControllerForPodUnderVPA (ctx context.Context , pod * PodState , controllerFetcher controllerfetcher.ControllerFetcher ) * controllerfetcher.ControllerKeyWithAPIVersion
58
+ GetControllingVPA (pod * PodState ) * Vpa
59
+ VPAs () map [VpaID ]* Vpa
60
+ SetObservedVPAs ([]* vpa_types.VerticalPodAutoscaler )
61
+ ObservedVPAs () []* vpa_types.VerticalPodAutoscaler
62
+ Pods () map [PodID ]* PodState
63
+ }
64
+
38
65
type clusterState struct {
39
66
// Pods in the cluster.
40
67
pods map [PodID ]* PodState
@@ -45,7 +72,7 @@ type clusterState struct {
45
72
// a warning about it.
46
73
emptyVPAs map [VpaID ]time.Time
47
74
// Observed VPAs. Used to check if there are updates needed.
48
- observedVpas []* vpa_types.VerticalPodAutoscaler
75
+ observedVPAs []* vpa_types.VerticalPodAutoscaler
49
76
50
77
// All container aggregations where the usage samples are stored.
51
78
aggregateStateMap aggregateContainerStatesMap
@@ -305,11 +332,11 @@ func (cluster *clusterState) Pods() map[PodID]*PodState {
305
332
}
306
333
307
334
func (cluster * clusterState ) SetObservedVPAs (observedVPAs []* vpa_types.VerticalPodAutoscaler ) {
308
- cluster .observedVpas = observedVPAs
335
+ cluster .observedVPAs = observedVPAs
309
336
}
310
337
311
338
func (cluster * clusterState ) ObservedVPAs () []* vpa_types.VerticalPodAutoscaler {
312
- return cluster .observedVpas
339
+ return cluster .observedVPAs
313
340
}
314
341
315
342
func newPod (id PodID ) * PodState {
@@ -522,30 +549,3 @@ func (k aggregateStateKey) Labels() labels.Labels {
522
549
}
523
550
return (* k .labelSetMap )[k .labelSetKey ]
524
551
}
525
-
526
- // ClusterState holds all runtime information about the cluster required for the
527
- // VPA operations, i.e. configuration of resources (pods, containers,
528
- // VPA objects), aggregated utilization of compute resources (CPU, memory) and
529
- // events (container OOMs).
530
- // All input to the VPA Recommender algorithm lives in this structure.
531
- type ClusterState interface {
532
- StateMapSize () int
533
- AddOrUpdatePod (podID PodID , newLabels labels.Set , phase apiv1.PodPhase )
534
- GetContainer (containerID ContainerID ) * ContainerState
535
- DeletePod (podID PodID )
536
- AddOrUpdateContainer (containerID ContainerID , request Resources ) error
537
- AddSample (sample * ContainerUsageSampleWithKey ) error
538
- RecordOOM (containerID ContainerID , timestamp time.Time , requestedMemory ResourceAmount ) error
539
- AddOrUpdateVpa (apiObject * vpa_types.VerticalPodAutoscaler , selector labels.Selector ) error
540
- DeleteVpa (vpaID VpaID ) error
541
- MakeAggregateStateKey (pod * PodState , containerName string ) AggregateStateKey
542
- RateLimitedGarbageCollectAggregateCollectionStates (ctx context.Context , now time.Time , controllerFetcher controllerfetcher.ControllerFetcher )
543
- RecordRecommendation (vpa * Vpa , now time.Time ) error
544
- GetMatchingPods (vpa * Vpa ) []PodID
545
- GetControllerForPodUnderVPA (ctx context.Context , pod * PodState , controllerFetcher controllerfetcher.ControllerFetcher ) * controllerfetcher.ControllerKeyWithAPIVersion
546
- GetControllingVPA (pod * PodState ) * Vpa
547
- VPAs () map [VpaID ]* Vpa
548
- SetObservedVPAs ([]* vpa_types.VerticalPodAutoscaler )
549
- ObservedVPAs () []* vpa_types.VerticalPodAutoscaler
550
- Pods () map [PodID ]* PodState
551
- }
0 commit comments