Skip to content

Commit

Permalink
fix: population of the schedulerhostaddress in self-hosted mode
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
mikeee committed Jan 15, 2025
1 parent 6d5e64d commit d3417b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -649,6 +652,9 @@ func executeRunWithAppsConfigFile(runFilePath string, k8sEnabled bool) {
print.StatusEvent(os.Stdout, print.LogFailure, "No apps to run")
os.Exit(1)
}

fmt.Println("debug: runtimever:", daprVer.RuntimeVersion)

var exitWithError bool
var closeErr error
if !k8sEnabled {
Expand All @@ -664,6 +670,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)
Expand Down
18 changes: 18 additions & 0 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (

Check failure on line 3 in cmd/run_test.go

View workflow job for this annotation

GitHub Actions / Build linux_amd64 binaries

File is not `gofumpt`-ed (gofumpt)
"github.com/stretchr/testify/assert"

Check failure on line 4 in cmd/run_test.go

View workflow job for this annotation

GitHub Actions / Build linux_amd64 binaries

File is not `goimports`-ed with -local github.com/dapr/ (goimports)
"testing"

Check failure on line 5 in cmd/run_test.go

View workflow job for this annotation

GitHub Actions / Build linux_amd64 binaries

File is not `gofumpt`-ed (gofumpt)
)

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)
})
}

0 comments on commit d3417b7

Please sign in to comment.