mitdesai commented on code in PR #579:
URL: https://github.com/apache/yunikorn-core/pull/579#discussion_r1239967446
##########
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:
I initially agreed on storing the serialized YAML. But I think if we do that
we have to re-introduce the `DefaultConfigString` which I got rid of as part of
this change. If we bring that back, I think we should just have the
`DefaultConfigString` and completely remove `GetDefaultConfig()`
When adding new configs, there are more chances of missing out on updating
`DefaultConfigString` if we have to update default values in multiple places.
We might end up in inconsistent default config in this case.
I'd like to go the previous behavior or calling `panic()` on error. Let's
see what others think before jumping on the solution.
--
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]