Ensure rsp plugins are only started once by the scheduling manager
@@ -30,6 +30,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
pkgruntime "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/runtime"
+ "k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/watch"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
@@ -52,6 +53,8 @@ type SchedulerController struct {
config *util.ControllerConfig
stopChan <-chan struct{}
+
+ runningPlugins sets.String
}
func StartSchedulerController(config *util.ControllerConfig, stopChan <-chan struct{}) {
@@ -72,6 +75,7 @@ func newController(config *util.ControllerConfig, client corev1alpha1client.Core
scheduler: make(map[string]schedulingtypes.Scheduler),
config: config,
stopChan: stopChan,
+ runningPlugins: sets.String{},
}
fedNamespace := config.FederationNamespace
@@ -115,6 +119,11 @@ func (c *SchedulerController) reconcile(qualifiedName util.QualifiedName) util.R
glog.Infof("Running reconcile FederatedTypeConfig for %q", key)
+ if c.runningPlugins.Has(qualifiedName.Name) {
+ // Scheduler and plugin are already running
+ return util.StatusAllOK
+ }
+
cachedObj, exist, err := c.store.GetByKey(key)
if err != nil {
runtime.HandleError(fmt.Errorf("Failed to query FederatedTypeConfig store for %q: %v", key, err))
@@ -160,6 +169,7 @@ func (c *SchedulerController) reconcile(qualifiedName util.QualifiedName) util.R
runtime.HandleError(fmt.Errorf("Error starting plugin for %q : %v", templateKind, err))
return util.StatusError
}
+ c.runningPlugins.Insert(qualifiedName.Name)
return util.StatusAllOK
}
