Skip to content

Commit

Permalink
fix daemon scheduler option validate bug (#1152)
Browse files Browse the repository at this point in the history
Signed-off-by: sunwp <[email protected]>
  • Loading branch information
244372610 authored Mar 11, 2022
1 parent 843b800 commit 3b39cea
Showing 1 changed file with 12 additions and 15 deletions.
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

0 comments on commit 3b39cea

Please sign in to comment.