diff --git a/pkg/capacityscheduling/capacity_scheduling.go b/pkg/capacityscheduling/capacity_scheduling.go index 41b678322..40980ad9c 100644 --- a/pkg/capacityscheduling/capacity_scheduling.go +++ b/pkg/capacityscheduling/capacity_scheduling.go @@ -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" @@ -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}, } } diff --git a/pkg/coscheduling/coscheduling.go b/pkg/coscheduling/coscheduling.go index 5ce30dab4..69c8a466d 100644 --- a/pkg/coscheduling/coscheduling.go +++ b/pkg/coscheduling/coscheduling.go @@ -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" @@ -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}, } } diff --git a/pkg/noderesourcetopology/plugin.go b/pkg/noderesourcetopology/plugin.go index f804a6992..3cbcf8c4e 100644 --- a/pkg/noderesourcetopology/plugin.go +++ b/pkg/noderesourcetopology/plugin.go @@ -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" ) @@ -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}, } }