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

[YUNIKORN-1983] Add config to statedump #664

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 11 additions & 7 deletions pkg/webservice/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,7 @@ func getClusterConfig(w http.ResponseWriter, r *http.Request) {
var marshalledConf []byte
var err error

// merge core config with extra config
schedulerConf := configs.ConfigContext.Get(schedulerContext.GetPolicyGroup())
extraConfig := configs.GetConfigMap()
conf := dao.ConfigDAOInfo{
SchedulerConfig: schedulerConf,
Extra: extraConfig,
}
conf := getClusterConfigDAO()

// check if we have a request for json output
if r.Header.Get("Accept") == "application/json" {
Expand All @@ -450,6 +444,16 @@ func getClusterConfig(w http.ResponseWriter, r *http.Request) {
}
}

func getClusterConfigDAO() *dao.ConfigDAOInfo {
// merge core config with extra config
conf := dao.ConfigDAOInfo{
SchedulerConfig: configs.ConfigContext.Get(schedulerContext.GetPolicyGroup()),
Extra: configs.GetConfigMap(),
}

return &conf
}

func checkHealthStatus(w http.ResponseWriter, r *http.Request) {
writeHeaders(w)

Expand Down
11 changes: 11 additions & 0 deletions pkg/webservice/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,15 @@ func TestValidateQueue(t *testing.T) {
}

func TestFullStateDumpPath(t *testing.T) {
original := configs.GetConfigMap()
defer func() {
configs.SetConfigMap(original)
}()
configMap := map[string]string{
"log.level": "WARN",
}
configs.SetConfigMap(configMap)

schedulerContext = prepareSchedulerContext(t, false)

partitionContext := schedulerContext.GetPartitionMapClone()
Expand Down Expand Up @@ -1622,4 +1631,6 @@ func verifyStateDumpJSON(t *testing.T, aggregated *AggregatedStateInfo) {
assert.Check(t, len(aggregated.ClusterInfo) > 0)
assert.Check(t, len(aggregated.Queues) > 0)
assert.Check(t, len(aggregated.LogLevel) > 0)
assert.Check(t, len(aggregated.Config.SchedulerConfig.Partitions) > 0)
assert.Check(t, len(aggregated.Config.Extra) > 0)
}
2 changes: 2 additions & 0 deletions pkg/webservice/state_dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type AggregatedStateInfo struct {
Queues []dao.PartitionQueueDAOInfo `json:"queues,omitempty"`
RMDiagnostics map[string]interface{} `json:"rmDiagnostics,omitempty"`
LogLevel string `json:"logLevel,omitempty"`
Config *dao.ConfigDAOInfo `json:"config,omitempty"`
}

func getFullStateDump(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -80,6 +81,7 @@ func doStateDump(w io.Writer) error {
Queues: getPartitionQueuesDAO(partitionContext),
RMDiagnostics: getResourceManagerDiagnostics(),
LogLevel: zapConfig.Level.Level().String(),
Config: getClusterConfigDAO(),
}

var prettyJSON []byte
Expand Down