-
Notifications
You must be signed in to change notification settings - Fork 5
/
driveradminlocal.go
executable file
·56 lines (42 loc) · 1.23 KB
/
driveradminlocal.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
46
47
48
49
50
51
52
53
54
55
56
package driveradminlocal
import (
"os"
"code.cloudfoundry.org/dockerdriver"
"code.cloudfoundry.org/smbdriver/driveradmin"
"github.com/tedsuo/ifrit"
)
type DriverAdminLocal struct {
serverProcess ifrit.Process
drainables []driveradmin.Drainable
}
func NewDriverAdminLocal() *DriverAdminLocal {
d := &DriverAdminLocal{}
return d
}
func (d *DriverAdminLocal) SetServerProc(p ifrit.Process) {
d.serverProcess = p
}
func (d *DriverAdminLocal) RegisterDrainable(rhs driveradmin.Drainable) {
d.drainables = append(d.drainables, rhs)
}
func (d *DriverAdminLocal) Evacuate(env dockerdriver.Env) driveradmin.ErrorResponse {
logger := env.Logger().Session("evacuate")
logger.Info("start")
defer logger.Info("end")
if d.serverProcess == nil {
return driveradmin.ErrorResponse{Err: "unexpected error: server process not found"}
}
for _, svr := range d.drainables {
if err := svr.Drain(env); err != nil {
logger.Error("failed-draining", err)
}
}
d.serverProcess.Signal(os.Interrupt)
return driveradmin.ErrorResponse{}
}
func (d *DriverAdminLocal) Ping(env dockerdriver.Env) driveradmin.ErrorResponse {
logger := env.Logger().Session("ping")
logger.Info("start")
defer logger.Info("end")
return driveradmin.ErrorResponse{}
}