-
Notifications
You must be signed in to change notification settings - Fork 14
/
rivers_restart.go
45 lines (38 loc) · 975 Bytes
/
rivers_restart.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package k8s
import (
"github.com/cybozu-go/cke"
"github.com/cybozu-go/cke/op"
"github.com/cybozu-go/cke/op/common"
)
type riversRestartOp struct {
nodes []*cke.Node
upstreams []*cke.Node
params cke.ServiceParams
pulled bool
finished bool
}
// RiversRestartOp returns an Operator to restart rivers.
func RiversRestartOp(nodes, upstreams []*cke.Node, params cke.ServiceParams) cke.Operator {
return &riversRestartOp{
nodes: nodes,
upstreams: upstreams,
params: params,
}
}
func (o *riversRestartOp) Name() string {
return "rivers-restart"
}
func (o *riversRestartOp) NextCommand() cke.Commander {
if !o.pulled {
o.pulled = true
return common.ImagePullCommand(o.nodes, cke.ToolsImage)
}
if !o.finished {
o.finished = true
return common.RunContainerCommand(o.nodes, op.RiversContainerName, cke.ToolsImage,
common.WithParams(RiversParams(o.upstreams)),
common.WithExtra(o.params),
common.WithRestart())
}
return nil
}