Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick of #85689: Export scheduler.Snapshot function #92376

Merged
merged 1 commit into from Jul 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/scheduler/core/generic_scheduler.go
Expand Up @@ -132,8 +132,12 @@ type ScheduleAlgorithm interface {
Extenders() []algorithm.SchedulerExtender
// GetPredicateMetadataProducer returns the predicate metadata producer. This is needed
// for cluster autoscaler integration.
// TODO(ahg-g): remove this once CA migrates to creating a Framework instead of a full scheduler.
// TODO(#85691): remove this once CA migrates to creating a Framework instead of a full scheduler.
PredicateMetadataProducer() predicates.MetadataProducer
// Snapshot snapshots scheduler cache and node infos. This is needed
// for cluster autoscaler integration.
// TODO(#85691): remove this once CA migrates to creating a Framework instead of a full scheduler.
Snapshot() error
}

// ScheduleResult represents the result of one pod scheduled. It will contain
Expand Down Expand Up @@ -169,7 +173,7 @@ type genericScheduler struct {

// snapshot snapshots scheduler cache and node infos for all fit and priority
// functions.
func (g *genericScheduler) snapshot() error {
func (g *genericScheduler) Snapshot() error {
// Used for all fit and priority funcs.
return g.cache.UpdateNodeInfoSnapshot(g.nodeInfoSnapshot)
}
Expand All @@ -192,7 +196,7 @@ func (g *genericScheduler) Schedule(ctx context.Context, state *framework.CycleS
}
trace.Step("Basic checks done")

if err := g.snapshot(); err != nil {
if err := g.Snapshot(); err != nil {
return result, err
}
trace.Step("Snapshoting scheduler cache and node infos done")
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/core/generic_scheduler_test.go
Expand Up @@ -2176,7 +2176,7 @@ func TestPreempt(t *testing.T) {
schedulerapi.DefaultPercentageOfNodesToScore,
true)
state := framework.NewCycleState()
scheduler.(*genericScheduler).snapshot()
scheduler.Snapshot()
// Call Preempt and check the expected results.
failedPredMap := defaultFailedPredMap
if test.failedPredMap != nil {
Expand Down
6 changes: 4 additions & 2 deletions pkg/scheduler/scheduler_test.go
Expand Up @@ -156,7 +156,6 @@ func (es mockScheduler) PredicateMetadataProducer() predicates.MetadataProducer
return nil

}

func (es mockScheduler) Schedule(ctx context.Context, state *framework.CycleState, pod *v1.Pod) (core.ScheduleResult, error) {
return es.result, es.err
}
Expand All @@ -170,10 +169,13 @@ func (es mockScheduler) Prioritizers() []priorities.PriorityConfig {
func (es mockScheduler) Extenders() []algorithm.SchedulerExtender {
return nil
}

func (es mockScheduler) Preempt(ctx context.Context, state *framework.CycleState, pod *v1.Pod, scheduleErr error) (*v1.Node, []*v1.Pod, []*v1.Pod, error) {
return nil, nil, nil, nil
}
func (es mockScheduler) Snapshot() error {
return nil

}

func TestSchedulerCreation(t *testing.T) {
client := clientsetfake.NewSimpleClientset()
Expand Down