added cidr validation and made hook execs to command array with args
This commit is contained in:
parent
fd9f8fc1fd
commit
85a2e39a4b
6 changed files with 54 additions and 165 deletions
|
|
@ -19,9 +19,9 @@ func NewVIPController(cfg *config.Config) (callbacks cluster.Callbacks, err erro
|
|||
callbacks = cluster.Callbacks{
|
||||
Leader: func(ctx context.Context, cc cluster.CallbackContext) {
|
||||
t := time.NewTicker(time.Second * 10)
|
||||
if cfg.LeaderHook != "" {
|
||||
if len(cfg.LeaderHook) > 0 {
|
||||
go func() {
|
||||
err := exec.CommandContext(ctx, cfg.LeaderHook).Run()
|
||||
err := exec.CommandContext(ctx, cfg.LeaderHook[0], cfg.LeaderHook[1:]...).Run()
|
||||
if err != nil {
|
||||
cc.Error(err, "error running hook", "leaderHook", cfg.LeaderHook)
|
||||
}
|
||||
|
|
@ -42,9 +42,9 @@ func NewVIPController(cfg *config.Config) (callbacks cluster.Callbacks, err erro
|
|||
},
|
||||
Follower: func(ctx context.Context, cc cluster.CallbackContext) {
|
||||
t := time.NewTicker(time.Second * 10)
|
||||
if cfg.FollowerHook != "" {
|
||||
if len(cfg.FollowerHook) > 0 {
|
||||
go func() {
|
||||
err := exec.CommandContext(ctx, cfg.FollowerHook).Run()
|
||||
err := exec.CommandContext(ctx, cfg.FollowerHook[0], cfg.FollowerHook[1:]...).Run()
|
||||
if err != nil {
|
||||
cc.Error(err, "error running hook", "followerHook", cfg.FollowerHook)
|
||||
}
|
||||
|
|
@ -52,8 +52,7 @@ func NewVIPController(cfg *config.Config) (callbacks cluster.Callbacks, err erro
|
|||
}
|
||||
for {
|
||||
cc.Info("following", "id", cc.ID())
|
||||
//TODO
|
||||
//deleteIPs(cc, n, cfg.VirtualIPs)
|
||||
deleteIPs(cc, n, cfg.VirtualIPs)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
t.Stop()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue