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 scheduler standalone CLI address remove on certain versions, edge or dev #1479

Open
wants to merge 3 commits into
base: release-1.15
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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"
}
Expand Down
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
Loading