From 026fc28ceb7dc212ad1ec9568af8dc07b31aa54c Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Thu, 23 Jan 2025 22:40:37 -0600 Subject: [PATCH 1/3] Fix scheduler-host-address for standalone runs Signed-off-by: Anton Troshin --- cmd/run.go | 5 ----- pkg/standalone/run.go | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 799952384..9111e25d9 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -232,11 +232,6 @@ dapr run --run-file /path/to/directory -k if (daprVer.RuntimeVersion != "edge") && (semver.Compare(fmt.Sprintf("v%v", daprVer.RuntimeVersion), "v1.14.0-rc.1") == -1) { print.InfoStatusEvent(os.Stdout, "The scheduler is only compatible with dapr runtime 1.14 onwards.") - for i, arg := range output.DaprCMD.Args { - if strings.HasPrefix(arg, "--scheduler-host-address") { - output.DaprCMD.Args[i] = "" - } - } } print.InfoStatusEvent(os.Stdout, startInfo) diff --git a/pkg/standalone/run.go b/pkg/standalone/run.go index 57781e4b5..f675f3f5b 100644 --- a/pkg/standalone/run.go +++ b/pkg/standalone/run.go @@ -141,7 +141,7 @@ func (config *RunConfig) validatePlacementHostAddr() error { func (config *RunConfig) validateSchedulerHostAddr() error { schedulerHostAddr := config.SchedulerHostAddress if len(schedulerHostAddr) == 0 { - return nil + schedulerHostAddr = "localhost" } if indx := strings.Index(schedulerHostAddr, ":"); indx == -1 { From fd465d565d24e23bbaf4c98f28c600579817bbdb Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Thu, 23 Jan 2025 23:21:04 -0600 Subject: [PATCH 2/3] revert and add dev version to check scheduler host Signed-off-by: Anton Troshin --- cmd/run.go | 9 +++++++-- pkg/standalone/run.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 9111e25d9..f61990062 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -230,8 +230,13 @@ dapr run --run-file /path/to/directory -k output.DaprGRPCPort) } - if (daprVer.RuntimeVersion != "edge") && (semver.Compare(fmt.Sprintf("v%v", daprVer.RuntimeVersion), "v1.14.0-rc.1") == -1) { + if (daprVer.RuntimeVersion != "edge") && (daprVer.RuntimeVersion != "dev") && (semver.Compare(fmt.Sprintf("v%v", daprVer.RuntimeVersion), "v1.14.0-rc.1") == -1) { print.InfoStatusEvent(os.Stdout, "The scheduler is only compatible with dapr runtime 1.14 onwards.") + for i, arg := range output.DaprCMD.Args { + if strings.HasPrefix(arg, "--scheduler-host-address") { + output.DaprCMD.Args[i] = "" + } + } } print.InfoStatusEvent(os.Stdout, startInfo) @@ -665,7 +670,7 @@ 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 version == "dev" || version == "edge" || semver.Compare(fmt.Sprintf("v%v", version), "v1.15.0-rc.0") == 1 { if address == "" { return "localhost:50006" } diff --git a/pkg/standalone/run.go b/pkg/standalone/run.go index f675f3f5b..57781e4b5 100644 --- a/pkg/standalone/run.go +++ b/pkg/standalone/run.go @@ -141,7 +141,7 @@ func (config *RunConfig) validatePlacementHostAddr() error { func (config *RunConfig) validateSchedulerHostAddr() error { schedulerHostAddr := config.SchedulerHostAddress if len(schedulerHostAddr) == 0 { - schedulerHostAddr = "localhost" + return nil } if indx := strings.Index(schedulerHostAddr, ":"); indx == -1 { From f4e92b1b8aefeafbd319b1c5f8fbc23006cac1a4 Mon Sep 17 00:00:00 2001 From: Anton Troshin Date: Fri, 24 Jan 2025 20:19:21 -0600 Subject: [PATCH 3/3] add support for override-broadcast-host scheduler flag Signed-off-by: Anton Troshin --- pkg/standalone/standalone.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pkg/standalone/standalone.go b/pkg/standalone/standalone.go index b7300eea3..344a70352 100644 --- a/pkg/standalone/standalone.go +++ b/pkg/standalone/standalone.go @@ -90,7 +90,8 @@ const ( schedulerMetricPort = 59091 schedulerEtcdPort = 52379 - daprVersionsWithScheduler = ">= 1.14.x" + daprVersionsWithScheduler = ">= 1.14.x" + schedulerVersionWithHostOverride = ">= 1.15.0-rc.6" ) var ( @@ -184,6 +185,22 @@ func isSchedulerIncluded(runtimeVersion string) (bool, error) { return c.Check(&vNoPrerelease), nil } +func isSchedulerHostOverrideSupported(runtimeVersion string) (bool, error) { + if runtimeVersion == "edge" || runtimeVersion == "dev" { + return true, nil + } + c, err := semver.NewConstraint(schedulerVersionWithHostOverride) + if err != nil { + return false, err + } + + v, err := semver.NewVersion(runtimeVersion) + if err != nil { + return false, err + } + return c.Check(v), nil +} + // Init installs Dapr on a local machine using the supplied runtimeVersion. func Init(runtimeVersion, dashboardVersion string, dockerNetwork string, slimMode bool, imageRegistryURL string, fromDir string, containerRuntime string, imageVariant string, daprInstallPath string, schedulerVolume *string) error { var err error @@ -683,6 +700,13 @@ func runSchedulerService(wg *sync.WaitGroup, errorChan chan<- error, info initIn args = append(args, image, "--etcd-data-dir=/var/lock/dapr/scheduler") } + hostOverrideSupported, err := isSchedulerHostOverrideSupported(info.runtimeVersion) + if err != nil { + errorChan <- err + } else if hostOverrideSupported { + args = append(args, "--override-broadcast-host", "localhost") + } + _, err = utils.RunCmdAndWait(runtimeCmd, args...) if err != nil { runError := isContainerRunError(err)