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 daemon scheduler option validate bug #1152

Merged
merged 1 commit into from
Mar 11, 2022
Merged
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
27 changes: 12 additions & 15 deletions client/config/peerhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"d7y.io/dragonfly/v2/internal/dfnet"
"d7y.io/dragonfly/v2/pkg/unit"
"d7y.io/dragonfly/v2/pkg/util/net/iputils"
"d7y.io/dragonfly/v2/pkg/util/stringutils"
)

type DaemonConfig = DaemonOption
Expand All @@ -57,14 +56,13 @@ type DaemonOption struct {
DataDir string `mapstructure:"dataDir" yaml:"dataDir"`
KeepStorage bool `mapstructure:"keepStorage" yaml:"keepStorage"`

Scheduler SchedulerOption `mapstructure:"scheduler" yaml:"scheduler"`
Host HostOption `mapstructure:"host" yaml:"host"`
Download DownloadOption `mapstructure:"download" yaml:"download"`
Proxy *ProxyOption `mapstructure:"proxy" yaml:"proxy"`
Upload UploadOption `mapstructure:"upload" yaml:"upload"`
Storage StorageOption `mapstructure:"storage" yaml:"storage"`
ConfigServer string `mapstructure:"configServer" yaml:"configServer"`
Health *HealthOption `mapstructure:"health" yaml:"health"`
Scheduler SchedulerOption `mapstructure:"scheduler" yaml:"scheduler"`
Host HostOption `mapstructure:"host" yaml:"host"`
Download DownloadOption `mapstructure:"download" yaml:"download"`
Proxy *ProxyOption `mapstructure:"proxy" yaml:"proxy"`
Upload UploadOption `mapstructure:"upload" yaml:"upload"`
Storage StorageOption `mapstructure:"storage" yaml:"storage"`
Health *HealthOption `mapstructure:"health" yaml:"health"`
// TODO WIP, did not use
Reload ReloadOption `mapstructure:"reloadOption" yaml:"reloadOption"`
}
Expand Down Expand Up @@ -115,20 +113,19 @@ func (p *DaemonOption) Convert() error {
}

func (p *DaemonOption) Validate() error {
if len(p.Scheduler.NetAddrs) == 0 && stringutils.IsBlank(p.ConfigServer) {
return errors.New("empty schedulers and config server is not specified")
}

if p.Scheduler.Manager.Enable {
if len(p.Scheduler.NetAddrs) == 0 {
if len(p.Scheduler.Manager.NetAddrs) == 0 {
return errors.New("manager addr is not specified")
}

if p.Scheduler.Manager.RefreshInterval == 0 {
return errors.New("manager refreshInterval is not specified")
}
return nil
}
if len(p.Scheduler.NetAddrs) == 0 {
return errors.New("empty schedulers and config server is not specified")
}

return nil
}

Expand Down