Repository: dragonflyoss/Dragonfly2
Pull request #1493 (2022-07-27 10:58:58)

feat: scheduler sets workhome
Signed-off-by: Gaius <gaius.qi@gmail.com>

<!--- Provide a general summary of your changes in the Title above -->

## Description
- Scheduler sets workhome.
<!--- Describe your changes in detail -->

## Related Issue

<!--- This project only accepts pull requests related to open issues -->
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
<!--- Please link to the issue here: -->

## Motivation and Context

<!--- Why is this change required? What problem does it solve? -->

## Screenshots (if appropriate)

## Types of changes

<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation Update (if none of the other choices apply)

## Checklist

<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->

- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [x] I have read the **CONTRIBUTING** document.
- [ ] I have added tests to cover my changes.



Patch:
diff --git a/cmd/scheduler/cmd/root.go b/cmd/scheduler/cmd/root.go
index 6ddaa390..13c52c66 100644
--- a/cmd/scheduler/cmd/root.go
+++ b/cmd/scheduler/cmd/root.go
@@ -89,6 +89,10 @@ func init() {
 
 func initDfpath(cfg *config.ServerConfig) (dfpath.Dfpath, error) {
 	var options []dfpath.Option
+	if cfg.WorkHome != "" {
+		options = append(options, dfpath.WithWorkHome(cfg.WorkHome))
+	}
+
 	if cfg.LogDir != "" {
 		options = append(options, dfpath.WithLogDir(cfg.LogDir))
 	}
diff --git a/scheduler/config/config.go b/scheduler/config/config.go
index 1e80e79a..60e84123 100644
--- a/scheduler/config/config.go
+++ b/scheduler/config/config.go
@@ -272,6 +272,9 @@ type ServerConfig struct {
 	// Server port.
 	Port int `yaml:"port" mapstructure:"port"`
 
+	// Server work directory.
+	WorkHome string `yaml:"workHome" mapstructure:"workHome"`
+
 	// Server dynamic config cache directory.
 	CacheDir string `yaml:"cacheDir" mapstructure:"cacheDir"`
 


Test patch:
diff --git a/scheduler/config/config_test.go b/scheduler/config/config_test.go
index 49ef5034..7c8b3779 100644
--- a/scheduler/config/config_test.go
+++ b/scheduler/config/config_test.go
@@ -60,6 +60,7 @@ func TestConfig_Load(t *testing.T) {
 			Host:     "foo",
 			Listen:   "0.0.0.0",
 			Port:     8002,
+			WorkHome: "home",
 			CacheDir: "foo",
 			LogDir:   "bar",
 			DataDir:  "baz",
diff --git a/scheduler/config/testdata/scheduler.yaml b/scheduler/config/testdata/scheduler.yaml
index d8431a9b..b6c2ee31 100644
--- a/scheduler/config/testdata/scheduler.yaml
+++ b/scheduler/config/testdata/scheduler.yaml
@@ -3,6 +3,7 @@ server:
   host: foo
   listen: 0.0.0.0
   port: 8002
+  workHome: home
   cacheDir: foo
   logDir: bar
   dataDir: baz