diff --git a/cmd/run.go b/cmd/run.go index 799952384..f61990062 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -230,7 +230,7 @@ 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") { @@ -670,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/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)