Skip to content

Commit 33871fa

Browse files
committed
Address review feedback
1 parent 3c7689f commit 33871fa

File tree

1 file changed

+30
-30
lines changed
  • vertical-pod-autoscaler/pkg/recommender/model

1 file changed

+30
-30
lines changed

vertical-pod-autoscaler/pkg/recommender/model/cluster.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,33 @@ const (
3535
RecommendationMissingMaxDuration = 30 * time.Minute
3636
)
3737

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+
3865
type clusterState struct {
3966
// Pods in the cluster.
4067
pods map[PodID]*PodState
@@ -45,7 +72,7 @@ type clusterState struct {
4572
// a warning about it.
4673
emptyVPAs map[VpaID]time.Time
4774
// Observed VPAs. Used to check if there are updates needed.
48-
observedVpas []*vpa_types.VerticalPodAutoscaler
75+
observedVPAs []*vpa_types.VerticalPodAutoscaler
4976

5077
// All container aggregations where the usage samples are stored.
5178
aggregateStateMap aggregateContainerStatesMap
@@ -305,11 +332,11 @@ func (cluster *clusterState) Pods() map[PodID]*PodState {
305332
}
306333

307334
func (cluster *clusterState) SetObservedVPAs(observedVPAs []*vpa_types.VerticalPodAutoscaler) {
308-
cluster.observedVpas = observedVPAs
335+
cluster.observedVPAs = observedVPAs
309336
}
310337

311338
func (cluster *clusterState) ObservedVPAs() []*vpa_types.VerticalPodAutoscaler {
312-
return cluster.observedVpas
339+
return cluster.observedVPAs
313340
}
314341

315342
func newPod(id PodID) *PodState {
@@ -522,30 +549,3 @@ func (k aggregateStateKey) Labels() labels.Labels {
522549
}
523550
return (*k.labelSetMap)[k.labelSetKey]
524551
}
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

Comments
 (0)