Skip to content

Commit a59c60b

Browse files
committed
1- Publish the pod-grouper DefaultPluginsHub as a DefaultPluginsHub object instead of a PluginsHub interface
2- Allow the DefaultPluginsHub to publish it's default plugin and a HasMatchingPlugin function
1 parent 2259f01 commit a59c60b

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

cmd/podgrouper/app/app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
2525
"sigs.k8s.io/controller-runtime/pkg/webhook"
2626

27-
"github.com/NVIDIA/KAI-scheduler/pkg/apis/scheduling/v2"
27+
v2 "github.com/NVIDIA/KAI-scheduler/pkg/apis/scheduling/v2"
2828
kubeAiSchedulerV2alpha2 "github.com/NVIDIA/KAI-scheduler/pkg/apis/scheduling/v2alpha2"
2929
controllers "github.com/NVIDIA/KAI-scheduler/pkg/podgrouper"
3030
pluginshub "github.com/NVIDIA/KAI-scheduler/pkg/podgrouper/podgrouper/hub"
@@ -51,7 +51,7 @@ func init() {
5151

5252
type App struct {
5353
Mgr manager.Manager
54-
DefaultPluginsHub pluginshub.PluginsHub
54+
DefaultPluginsHub *pluginshub.DefaultPluginsHub
5555

5656
configs controllers.Configs
5757
pluginsHub pluginshub.PluginsHub

pkg/podgrouper/podgrouper/hub/hub.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ func (ph *DefaultPluginsHub) GetPodGrouperPlugin(gvk metav1.GroupVersionKind) gr
7777
return ph.defaultPlugin
7878
}
7979

80+
func (ph *DefaultPluginsHub) GetDefaultPlugin() grouper.Grouper {
81+
return ph.defaultPlugin
82+
}
83+
84+
func (ph *DefaultPluginsHub) HasMatchingPlugin(gvk metav1.GroupVersionKind) bool {
85+
// search using wildcard version - this hub will return a plugin even if the version is not exact match
86+
gvk.Version = "*"
87+
if _, found := ph.customPlugins[gvk]; found {
88+
return true
89+
}
90+
return false
91+
}
92+
8093
func NewDefaultPluginsHub(kubeClient client.Client, searchForLegacyPodGroups,
8194
gangScheduleKnative bool, queueLabelKey, nodePoolLabelKey string,
8295
defaultPrioritiesConfigMapName, defaultPrioritiesConfigMapNamespace string) *DefaultPluginsHub {

0 commit comments

Comments
 (0)