Snapshot cluster state for scheduler every loop
Change-Id: If9d162b83ccc914fe1b02e4689bfe1f4b264407f
This commit is contained in:
parent
247111eaf1
commit
b67854e800
|
|
@ -194,6 +194,10 @@ func (a *StaticAutoscaler) RunOnce(currentTime time.Time) errors.AutoscalerError
|
|||
klog.V(4).Info("Starting main loop")
|
||||
|
||||
stateUpdateStart := time.Now()
|
||||
if err := a.PredicateChecker.SnapshotClusterState(); err != nil {
|
||||
return errors.ToAutoscalerError(errors.ApiCallError, fmt.Errorf("could not snapshot cluster state in scheduler; %v", err))
|
||||
}
|
||||
|
||||
allNodes, readyNodes, typedErr := a.obtainNodeLists(a.CloudProvider)
|
||||
if typedErr != nil {
|
||||
klog.Errorf("Failed to get node list: %v", typedErr)
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ type PredicateChecker struct {
|
|||
predicates []PredicateInfo
|
||||
predicateMetadataProducer predicates.MetadataProducer
|
||||
enableAffinityPredicate bool
|
||||
scheduler *scheduler.Scheduler
|
||||
}
|
||||
|
||||
// We run some predicates first as they are cheap to check and they should be enough
|
||||
|
|
@ -162,6 +163,7 @@ func NewPredicateChecker(kubeClient kube_client.Interface, stop <-chan struct{})
|
|||
predicates: predicateList,
|
||||
predicateMetadataProducer: sched.Algorithm.PredicateMetadataProducer(),
|
||||
enableAffinityPredicate: true,
|
||||
scheduler: sched,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -199,6 +201,15 @@ func NewCustomTestPredicateChecker(predicateInfos []PredicateInfo) *PredicateChe
|
|||
}
|
||||
}
|
||||
|
||||
// SnapshotClusterState updates cluster snapshot used by the predicate checker.
|
||||
// It should be called every CA loop iteration.
|
||||
func (p *PredicateChecker) SnapshotClusterState() error {
|
||||
if p.scheduler != nil {
|
||||
return p.scheduler.Algorithm.Snapshot()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetAffinityPredicateEnabled can be used to enable or disable checking MatchInterPodAffinity
|
||||
// predicate. This will cause incorrect CA behavior if there is at least a single pod in
|
||||
// cluster using affinity/antiaffinity. However, checking affinity predicate is extremely
|
||||
|
|
|
|||
Loading…
Reference in New Issue