feat: move probe interval from scheduler config to client config (#2462)
Signed-off-by: XZ <834756128@qq.com>
This commit is contained in:
parent
b2cb2ed024
commit
8a8d6abaae
|
|
@ -111,3 +111,8 @@ var (
|
|||
// DefaultAnnouncerSchedulerInterval is default interface of announcing scheduler.
|
||||
DefaultAnnouncerSchedulerInterval = 30 * time.Second
|
||||
)
|
||||
|
||||
const (
|
||||
// DefaultProbeInterval is the default interval of probing host.
|
||||
DefaultProbeInterval = 20 * time.Minute
|
||||
)
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ type DaemonOption struct {
|
|||
Reload ReloadOption `mapstructure:"reload" yaml:"reload"`
|
||||
Network *NetworkOption `mapstructure:"network" yaml:"network"`
|
||||
Announcer AnnouncerOption `mapstructure:"announcer" yaml:"announcer"`
|
||||
NetworkTopology NetworkTopologyOption `mapstructure:"networkTopology" yaml:"networkTopology"`
|
||||
}
|
||||
|
||||
func NewDaemonConfig() *DaemonOption {
|
||||
|
|
@ -216,6 +217,12 @@ func (p *DaemonOption) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if p.NetworkTopology.Enable {
|
||||
if p.NetworkTopology.Probe.Interval <= 0 {
|
||||
return errors.New("probe requires parameter interval")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -938,3 +945,16 @@ type AnnouncerOption struct {
|
|||
// SchedulerInterval is the interval of announcing scheduler.
|
||||
SchedulerInterval time.Duration `mapstructure:"schedulerInterval" yaml:"schedulerInterval"`
|
||||
}
|
||||
|
||||
type NetworkTopologyOption struct {
|
||||
// Enable network topology service.
|
||||
Enable bool `mapstructure:"enable" yaml:"enable"`
|
||||
|
||||
// Probe is the configuration of probe.
|
||||
Probe ProbeOption `mapstructure:"probe" yaml:"probe"`
|
||||
}
|
||||
|
||||
type ProbeOption struct {
|
||||
// Interval is the interval of probing hosts.
|
||||
Interval time.Duration `mapstructure:"interval" yaml:"interval"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,5 +179,11 @@ var peerHostConfig = func() *DaemonOption {
|
|||
Announcer: AnnouncerOption{
|
||||
SchedulerInterval: DefaultAnnouncerSchedulerInterval,
|
||||
},
|
||||
NetworkTopology: NetworkTopologyOption{
|
||||
Enable: false,
|
||||
Probe: ProbeOption{
|
||||
Interval: DefaultProbeInterval,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,5 +179,11 @@ var peerHostConfig = func() *DaemonOption {
|
|||
Announcer: AnnouncerOption{
|
||||
SchedulerInterval: DefaultAnnouncerSchedulerInterval,
|
||||
},
|
||||
NetworkTopology: NetworkTopologyOption{
|
||||
Enable: false,
|
||||
Probe: ProbeOption{
|
||||
Interval: DefaultProbeInterval,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -515,6 +515,12 @@ func TestPeerHostOption_Load(t *testing.T) {
|
|||
Announcer: AnnouncerOption{
|
||||
SchedulerInterval: 1000000000,
|
||||
},
|
||||
NetworkTopology: NetworkTopologyOption{
|
||||
Enable: true,
|
||||
Probe: ProbeOption{
|
||||
Interval: 20 * time.Minute,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
peerHostOptionYAML := &DaemonOption{}
|
||||
|
|
@ -754,6 +760,24 @@ func TestPeerHostOption_Validate(t *testing.T) {
|
|||
assert.EqualError(err, "certSpec requires parameter validityPeriod")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "probe requires parameter interval",
|
||||
config: NewDaemonConfig(),
|
||||
mock: func(cfg *DaemonConfig) {
|
||||
cfg.Scheduler.NetAddrs = []dfnet.NetAddr{
|
||||
{
|
||||
Type: dfnet.TCP,
|
||||
Addr: "127.0.0.1:8002",
|
||||
},
|
||||
}
|
||||
cfg.NetworkTopology.Enable = true
|
||||
cfg.NetworkTopology.Probe.Interval = 0
|
||||
},
|
||||
expect: func(t *testing.T, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.EqualError(err, "probe requires parameter interval")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
|
|
|||
|
|
@ -189,3 +189,8 @@ network:
|
|||
|
||||
announcer:
|
||||
schedulerInterval: 1s
|
||||
|
||||
networkTopology:
|
||||
enable: true
|
||||
probe:
|
||||
interval: 20m
|
||||
|
|
|
|||
|
|
@ -312,9 +312,6 @@ type ProbeConfig struct {
|
|||
// QueueLength is the length of probe queue.
|
||||
QueueLength int `mapstructure:"queueLength" yaml:"queueLength"`
|
||||
|
||||
// Interval is the interval of probing hosts.
|
||||
Interval time.Duration `mapstructure:"interval" yaml:"interval"`
|
||||
|
||||
// Count is the number of probing hosts.
|
||||
Count int `mapstructure:"count" yaml:"count"`
|
||||
}
|
||||
|
|
@ -410,7 +407,6 @@ func New() *Config {
|
|||
CollectInterval: DefaultNetworkTopologyCollectInterval,
|
||||
Probe: ProbeConfig{
|
||||
QueueLength: DefaultProbeQueueLength,
|
||||
Interval: DefaultProbeInterval,
|
||||
Count: DefaultProbeCount,
|
||||
},
|
||||
},
|
||||
|
|
@ -579,10 +575,6 @@ func (cfg *Config) Validate() error {
|
|||
return errors.New("probe requires parameter queueLength")
|
||||
}
|
||||
|
||||
if cfg.NetworkTopology.Probe.Interval <= 0 {
|
||||
return errors.New("probe requires parameter interval")
|
||||
}
|
||||
|
||||
if cfg.NetworkTopology.Probe.Count <= 0 {
|
||||
return errors.New("probe requires parameter count")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,6 @@ func TestConfig_Load(t *testing.T) {
|
|||
CollectInterval: 60 * time.Second,
|
||||
Probe: ProbeConfig{
|
||||
QueueLength: 5,
|
||||
Interval: 30 * time.Second,
|
||||
Count: 10,
|
||||
},
|
||||
},
|
||||
|
|
@ -710,20 +709,6 @@ func TestConfig_Validate(t *testing.T) {
|
|||
assert.EqualError(err, "probe requires parameter queueLength")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "probe requires parameter interval",
|
||||
config: New(),
|
||||
mock: func(cfg *Config) {
|
||||
cfg.Manager = mockManagerConfig
|
||||
cfg.Database.Redis = mockRedisConfig
|
||||
cfg.Job = mockJobConfig
|
||||
cfg.NetworkTopology.Probe.Interval = 0
|
||||
},
|
||||
expect: func(t *testing.T, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.EqualError(err, "probe requires parameter interval")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "probe requires parameter count",
|
||||
config: New(),
|
||||
|
|
|
|||
|
|
@ -169,9 +169,6 @@ const (
|
|||
// DefaultProbeQueueLength is the default length of probe queue.
|
||||
DefaultProbeQueueLength = 5
|
||||
|
||||
// DefaultProbeInterval is the default interval of probing host.
|
||||
DefaultProbeInterval = 20 * time.Minute
|
||||
|
||||
// DefaultProbeCount is the default number of probing hosts.
|
||||
DefaultProbeCount = 5
|
||||
)
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ networkTopology:
|
|||
collectInterval: 60s
|
||||
probe:
|
||||
queueLength: 5
|
||||
interval: 30s
|
||||
count: 10
|
||||
|
||||
trainer:
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ var (
|
|||
CollectInterval: 2 * time.Hour,
|
||||
Probe: config.ProbeConfig{
|
||||
QueueLength: 5,
|
||||
Interval: 15 * time.Minute,
|
||||
Count: 10,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ var (
|
|||
CollectInterval: 2 * time.Hour,
|
||||
Probe: config.ProbeConfig{
|
||||
QueueLength: 5,
|
||||
Interval: 15 * time.Minute,
|
||||
Count: 10,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue