Skip to content

Commit 3acfa7d

Browse files
mikeeeyaron2
andauthored
fix: population of the schedulerhostaddress in self-hosted mode (#1475)
* fix: population of the schedulerhostaddress in self-hosted mode The scheduler host address is pre-populated when using the self-hosted mode multi-app run similarly to the single app run. Kubernetes multi-app run is not affected and you will still need to specify a scheduler host address. Signed-off-by: mikeee <[email protected]> * chore: lint Signed-off-by: mikeee <[email protected]> --------- Signed-off-by: mikeee <[email protected]> Co-authored-by: Yaron Schneider <[email protected]>
1 parent 104849b commit 3acfa7d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

cmd/run.go

+14
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ func executeRun(runTemplateName, runFilePath string, apps []runfileconfig.App) (
524524
exitWithError = true
525525
break
526526
}
527+
528+
runConfig.SchedulerHostAddress = validateSchedulerHostAddress(daprVer.RuntimeVersion, runConfig.SchedulerHostAddress)
529+
527530
// Combined multiwriter for logs.
528531
var appDaprdWriter io.Writer
529532
// appLogWriter is used when app command is present.
@@ -664,6 +667,17 @@ func executeRunWithAppsConfigFile(runFilePath string, k8sEnabled bool) {
664667
}
665668
}
666669

670+
// populate the scheduler host address based on the dapr version.
671+
func validateSchedulerHostAddress(version, address string) string {
672+
// If no SchedulerHostAddress is supplied, set it to default value.
673+
if semver.Compare(fmt.Sprintf("v%v", version), "v1.15.0-rc.0") == 1 {
674+
if address == "" {
675+
return "localhost:50006"
676+
}
677+
}
678+
return address
679+
}
680+
667681
func getRunConfigFromRunFile(runFilePath string) (runfileconfig.RunFileConfig, []runfileconfig.App, error) {
668682
config := runfileconfig.RunFileConfig{}
669683
apps, err := config.GetApps(runFilePath)

cmd/run_test.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cmd
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestValidateSchedulerHostAddress(t *testing.T) {
10+
t.Run("test scheduler host address - v1.14.0-rc.0", func(t *testing.T) {
11+
address := validateSchedulerHostAddress("1.14.0-rc.0", "")
12+
assert.Equal(t, "", address)
13+
})
14+
15+
t.Run("test scheduler host address - v1.15.0-rc.0", func(t *testing.T) {
16+
address := validateSchedulerHostAddress("1.15.0", "")
17+
assert.Equal(t, "localhost:50006", address)
18+
})
19+
}

0 commit comments

Comments
 (0)