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 <hey@mike.ee>

* chore: lint

Signed-off-by: mikeee <hey@mike.ee>

---------

Signed-off-by: mikeee <hey@mike.ee>
Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
This commit is contained in:
Mike Nguyen 2025-01-20 22:18:31 +00:00 committed by GitHub
parent 104849bc74
commit 3acfa7d7e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View File

@ -524,6 +524,9 @@ func executeRun(runTemplateName, runFilePath string, apps []runfileconfig.App) (
exitWithError = true
break
}
runConfig.SchedulerHostAddress = validateSchedulerHostAddress(daprVer.RuntimeVersion, runConfig.SchedulerHostAddress)
// Combined multiwriter for logs.
var appDaprdWriter io.Writer
// appLogWriter is used when app command is present.
@ -664,6 +667,17 @@ func executeRunWithAppsConfigFile(runFilePath string, k8sEnabled bool) {
}
}
// populate the scheduler host address based on the dapr version.
func validateSchedulerHostAddress(version, address string) string {
// If no SchedulerHostAddress is supplied, set it to default value.
if semver.Compare(fmt.Sprintf("v%v", version), "v1.15.0-rc.0") == 1 {
if address == "" {
return "localhost:50006"
}
}
return address
}
func getRunConfigFromRunFile(runFilePath string) (runfileconfig.RunFileConfig, []runfileconfig.App, error) {
config := runfileconfig.RunFileConfig{}
apps, err := config.GetApps(runFilePath)

19
cmd/run_test.go Normal file
View File

@ -0,0 +1,19 @@
package cmd
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestValidateSchedulerHostAddress(t *testing.T) {
t.Run("test scheduler host address - v1.14.0-rc.0", func(t *testing.T) {
address := validateSchedulerHostAddress("1.14.0-rc.0", "")
assert.Equal(t, "", address)
})
t.Run("test scheduler host address - v1.15.0-rc.0", func(t *testing.T) {
address := validateSchedulerHostAddress("1.15.0", "")
assert.Equal(t, "localhost:50006", address)
})
}