Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: population of the schedulerhostaddress in self-hosted mode #1475

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 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 @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
@@ -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)
})
}
Loading