pbacsko commented on code in PR #579:
URL: https://github.com/apache/yunikorn-core/pull/579#discussion_r1239787946


##########
pkg/common/configs/config.go:
##########
@@ -194,15 +199,53 @@ func GetConfigurationString(requestBytes []byte) string {
        return strings.ReplaceAll(conf, checksum, "")
 }
 
-// DefaultSchedulerConfig contains the default scheduler configuration; used 
if no other is provided
-var DefaultSchedulerConfig = `
-partitions:
-  - name: default
-    placementrules:
-      - name: tag
-        value: namespace
-        create: true
-    queues:
-      - name: root
-        submitacl: '*'
-`
+// GetDefaultConfig creates default scheduler configuration; used if no other 
is provided
+func GetDefaultConfig() (string, error) {
+       config := &SchedulerConfig{
+               Partitions:           GetDefaultPartitionConfig(),
+               EventRequestsEnabled: DefaultEventRequestsEnabled,
+               EventTrackingEnabled: DefaultEventTrackingEnabled,
+               EventRequestCapacity: DefaultEventRequestCapacity,
+               EventBufferCapacity:  DefaultEventBufferCapacity,
+               EventResponseSize:    DefaultEventResponseSize,
+       }
+
+       // ideally err will always be nil as we are now building the conf 
programatically
+       content, err := yaml.Marshal(config)
+       if err != nil {
+               log.Log(log.Config).Error("failed to marshal config object",
+                       zap.Error(err))
+               return "", err

Review Comment:
   We should definitely not return an empty config here. I can imagine two 
solutions: you either store the serialized YAML again (which you validate in 
the unit tests) or just simply call `panic()`. I vote for storing the YAML as a 
string literal, I think it's perfectly fine for a default config.
   I just checked there is no test case for it, but you can add one which makes 
sure that it's a valid one.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to