...
1
16
17 package schedulinggates
18
19 import (
20 "context"
21 "fmt"
22
23 v1 "k8s.io/api/core/v1"
24 "k8s.io/apimachinery/pkg/runtime"
25 "k8s.io/kubernetes/pkg/scheduler/framework"
26 "k8s.io/kubernetes/pkg/scheduler/framework/plugins/names"
27 )
28
29
30 const Name = names.SchedulingGates
31
32
33 type SchedulingGates struct{}
34
35 var _ framework.PreEnqueuePlugin = &SchedulingGates{}
36 var _ framework.EnqueueExtensions = &SchedulingGates{}
37
38 func (pl *SchedulingGates) Name() string {
39 return Name
40 }
41
42 func (pl *SchedulingGates) PreEnqueue(ctx context.Context, p *v1.Pod) *framework.Status {
43 if len(p.Spec.SchedulingGates) == 0 {
44 return nil
45 }
46 gates := make([]string, 0, len(p.Spec.SchedulingGates))
47 for _, gate := range p.Spec.SchedulingGates {
48 gates = append(gates, gate.Name)
49 }
50 return framework.NewStatus(framework.UnschedulableAndUnresolvable, fmt.Sprintf("waiting for scheduling gates: %v", gates))
51 }
52
53
54
55 func (pl *SchedulingGates) EventsToRegister() []framework.ClusterEventWithHint {
56 return nil
57 }
58
59
60 func New(_ context.Context, _ runtime.Object, _ framework.Handle) (framework.Plugin, error) {
61 return &SchedulingGates{}, nil
62 }
63
View as plain text