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

register custom resource events for efficient pod enqueuing #317

Merged
merged 1 commit into from
Jan 27, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/capacityscheduling/capacity_scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpreemption"
schedutil "k8s.io/kubernetes/pkg/scheduler/util"

"sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling"
"sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1"
"sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned"
schedinformer "sigs.k8s.io/scheduler-plugins/pkg/generated/informers/externalversions"
Expand Down Expand Up @@ -184,9 +185,12 @@ func New(obj runtime.Object, handle framework.Handle) (framework.Plugin, error)
}

func (c *CapacityScheduling) EventsToRegister() []framework.ClusterEvent {
// To register a custom event, follow the naming convention at:
// https://git.k8s.io/kubernetes/pkg/scheduler/eventhandlers.go#L403-L410
eqGVK := fmt.Sprintf("elasticquotas.v1alpha1.%v", scheduling.GroupName)
return []framework.ClusterEvent{
{Resource: framework.Pod, ActionType: framework.Delete},
// TODO: once bump the dependency to k8s 1.22, addd custom object events.
{Resource: framework.GVK(eqGVK), ActionType: framework.All},
}
}

Expand Down
6 changes: 5 additions & 1 deletion pkg/coscheduling/coscheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/framework"

"sigs.k8s.io/scheduler-plugins/pkg/apis/config"
"sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling"
"sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1"
"sigs.k8s.io/scheduler-plugins/pkg/coscheduling/core"
pgclientset "sigs.k8s.io/scheduler-plugins/pkg/generated/clientset/versioned"
Expand Down Expand Up @@ -90,9 +91,12 @@ func New(obj runtime.Object, handle framework.Handle) (framework.Plugin, error)
}

func (cs *Coscheduling) EventsToRegister() []framework.ClusterEvent {
// To register a custom event, follow the naming convention at:
// https://git.k8s.io/kubernetes/pkg/scheduler/eventhandlers.go#L403-L410
pgGVK := fmt.Sprintf("podgroups.v1alpha1.%v", scheduling.GroupName)
return []framework.ClusterEvent{
{Resource: framework.Pod, ActionType: framework.Add},
// TODO: once bump the dependency to k8s 1.22, addd custom object events.
{Resource: framework.GVK(pgGVK), ActionType: framework.Add | framework.Update},
}
}

Expand Down
5 changes: 5 additions & 0 deletions pkg/noderesourcetopology/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"k8s.io/kubernetes/pkg/scheduler/framework"
apiconfig "sigs.k8s.io/scheduler-plugins/pkg/apis/config"

"github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology"
topologyv1alpha1 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha1"
listerv1alpha1 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/generated/listers/topology/v1alpha1"
)
Expand Down Expand Up @@ -117,8 +118,12 @@ func New(args runtime.Object, handle framework.Handle) (framework.Plugin, error)
// should be registered for this plugin since a Pod update may free up resources
// that make other Pods schedulable.
func (tm *TopologyMatch) EventsToRegister() []framework.ClusterEvent {
// To register a custom event, follow the naming convention at:
// https://git.k8s.io/kubernetes/pkg/scheduler/eventhandlers.go#L403-L410
nrtGVK := fmt.Sprintf("noderesourcetopologies.v1alpha1.%v", topologyapi.GroupName)
return []framework.ClusterEvent{
{Resource: framework.Pod, ActionType: framework.Delete},
{Resource: framework.Node, ActionType: framework.Add | framework.UpdateNodeAllocatable},
{Resource: framework.GVK(nrtGVK), ActionType: framework.Add | framework.Update},
Copy link
Contributor Author

@Huang-Wei Huang-Wei Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: @swatisehgal @AlexeyPerevalov: this change is an optimization to give a pod failed by NRT filter plugin higher chance to be retried immediately. Here I think only NRT's add and update events are correlated.

}
}