Merge pull request #86218 from ahg-g/ahg-framework

Add an interface to return scheduler framework instance
This commit is contained in:
Kubernetes Prow Robot 2019-12-12 11:06:32 -08:00 committed by GitHub
commit bb03061010
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -141,6 +141,9 @@ type ScheduleAlgorithm interface {
// for cluster autoscaler integration.
// TODO(#85691): remove this once CA migrates to creating a Framework instead of a full scheduler.
Snapshot() error
// Framework returns the scheduler framework instance. This is needed for cluster autoscaler integration.
// TODO(#85691): remove this once CA migrates to creating a Framework instead of a full scheduler.
Framework() framework.Framework
}
// ScheduleResult represents the result of one pod scheduled. It will contain
@ -174,14 +177,20 @@ type genericScheduler struct {
nextStartNodeIndex int
}
// snapshot snapshots scheduler cache and node infos for all fit and priority
// Snapshot snapshots scheduler cache and node infos for all fit and priority
// functions.
func (g *genericScheduler) Snapshot() error {
// Used for all fit and priority funcs.
return g.cache.UpdateNodeInfoSnapshot(g.nodeInfoSnapshot)
}
// GetPredicateMetadataProducer returns the predicate metadata producer. This is needed
// Framework returns the framework instance.
func (g *genericScheduler) Framework() framework.Framework {
// Used for all fit and priority funcs.
return g.framework
}
// PredicateMetadataProducer returns the predicate metadata producer. This is needed
// for cluster autoscaler integration.
func (g *genericScheduler) PredicateMetadataProducer() predicates.MetadataProducer {
return g.predicateMetaProducer

View File

@ -179,6 +179,10 @@ func (es mockScheduler) Preempt(ctx context.Context, state *framework.CycleState
func (es mockScheduler) Snapshot() error {
return nil
}
func (es mockScheduler) Framework() framework.Framework {
return nil
}
func TestSchedulerCreation(t *testing.T) {