This is an automated email from the ASF dual-hosted git repository.
pbacsko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git
The following commit(s) were added to refs/heads/master by this push:
new f025f071 [YUNIKORN-2376] Remove dummy state dump plugin (#783)
f025f071 is described below
commit f025f071ab2f729e167da21ce3188f719246e5a0
Author: Wilfred Spiegelenburg <[email protected]>
AuthorDate: Sat Feb 3 06:19:13 2024 +0100
[YUNIKORN-2376] Remove dummy state dump plugin (#783)
Do not register a dummy state dump plugin during init. Handle the fact
that a resource manager does not have to register a state dump plugin in
the state dump creation.
Closes: #783
Signed-off-by: Peter Bacsko <[email protected]>
---
pkg/plugins/plugins.go | 19 +++++++------------
pkg/webservice/handlers.go | 7 ++++++-
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/pkg/plugins/plugins.go b/pkg/plugins/plugins.go
index 88f2601f..7ba81310 100644
--- a/pkg/plugins/plugins.go
+++ b/pkg/plugins/plugins.go
@@ -26,19 +26,11 @@ import (
var plugins SchedulerPlugins
func init() {
- plugins = SchedulerPlugins{
- StateDumpPlugin: dummyStateDumpPlugin{},
- }
-}
-
-type dummyStateDumpPlugin struct{}
-
-var _ api.StateDumpPlugin = dummyStateDumpPlugin{}
-
-func (d dummyStateDumpPlugin) GetStateDump() (string, error) {
- return "{}", nil
+ plugins = SchedulerPlugins{}
}
+// RegisterSchedulerPlugin registers the plugin based on the interfaces(s) it
implements.
+// The known interfaces are defined in yunikorn-scheduler-interface/lib/go/api
func RegisterSchedulerPlugin(plugin interface{}) {
plugins.Lock()
defer plugins.Unlock()
@@ -52,7 +44,8 @@ func RegisterSchedulerPlugin(plugin interface{}) {
}
}
-// visible for testing
+// UnregisterSchedulerPlugins removes all earlier set plugins
+// visible for testing only
func UnregisterSchedulerPlugins() {
plugins.Lock()
defer plugins.Unlock()
@@ -60,12 +53,14 @@ func UnregisterSchedulerPlugins() {
plugins.StateDumpPlugin = nil
}
+// GetResourceManagerCallbackPlugin returns the registered callback plugin or
nil if none was registered.
func GetResourceManagerCallbackPlugin() api.ResourceManagerCallback {
plugins.RLock()
defer plugins.RUnlock()
return plugins.ResourceManagerCallbackPlugin
}
+// GetStateDumpPlugin returns the registered state dump plugin or nil if none
was registered.
func GetStateDumpPlugin() api.StateDumpPlugin {
plugins.RLock()
defer plugins.RUnlock()
diff --git a/pkg/webservice/handlers.go b/pkg/webservice/handlers.go
index 809b49a6..6f4f7105 100644
--- a/pkg/webservice/handlers.go
+++ b/pkg/webservice/handlers.go
@@ -947,9 +947,14 @@ func getRMBuildInformation(lists
map[string]*scheduler.RMInformation) []map[stri
}
func getResourceManagerDiagnostics() map[string]interface{} {
- result := make(map[string]interface{}, 0)
+ result := make(map[string]interface{})
+ // if the RM has not registered state dump the plugin will be nil
plugin := plugins.GetStateDumpPlugin()
+ if plugin == nil {
+ result["empty"] = "Resource Manager did not register callback"
+ return result
+ }
// get state dump from RM
dumpStr, err := plugin.GetStateDump()
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]