Skip to content

Commit

Permalink
[YUNIKORN-1983] Add config to statedump
Browse files Browse the repository at this point in the history
  • Loading branch information
brandboat committed Oct 3, 2023
1 parent af8e705 commit 54eb5ec
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
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

0 comments on commit 54eb5ec

Please sign in to comment.