Skip to content

Commit

Permalink
add support for override-broadcast-host scheduler flag
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Troshin <anton@diagrid.io>
  • Loading branch information
antontroshin committed Jan 25, 2025
1 parent fd465d5 commit f4e92b1
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion pkg/standalone/standalone.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ const (
schedulerMetricPort = 59091
schedulerEtcdPort = 52379

daprVersionsWithScheduler = ">= 1.14.x"
daprVersionsWithScheduler = ">= 1.14.x"
schedulerVersionWithHostOverride = ">= 1.15.0-rc.6"
)

var (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f4e92b1

Please sign in to comment.