@@ -47,7 +47,7 @@ func (c *Calcium) ReplaceContainer(ctx context.Context, opts *types.ReplaceOptio
47
47
)
48
48
}
49
49
// make sure container exists
50
- containerJSON , err := container .Inspect (ctx )
50
+ containerInfo , err := container .Inspect (ctx )
51
51
if err != nil {
52
52
return err
53
53
}
@@ -61,17 +61,17 @@ func (c *Calcium) ReplaceContainer(ctx context.Context, opts *types.ReplaceOptio
61
61
replaceOpts .Podname = container .Podname
62
62
// 继承网络配置
63
63
if replaceOpts .NetworkInherit {
64
- if ! containerJSON .Running {
64
+ if ! containerInfo .Running {
65
65
return types .NewDetailedErr (types .ErrNotSupport ,
66
66
fmt .Sprintf ("container %s not running, can not inherit" , container .ID ),
67
67
)
68
68
}
69
- log .Infof ("[ReplaceContainer] Inherit old container network configuration mode %v" , containerJSON .Networks )
69
+ log .Infof ("[ReplaceContainer] Inherit old container network configuration mode %v" , containerInfo .Networks )
70
70
replaceOpts .NetworkMode = ""
71
- replaceOpts .Networks = containerJSON .Networks
71
+ replaceOpts .Networks = containerInfo .Networks
72
72
}
73
73
74
- createMessage , removeMessage , err = c .doReplaceContainer (ctx , container , containerJSON , & replaceOpts , index )
74
+ createMessage , removeMessage , err = c .doReplaceContainer (ctx , container , containerInfo , & replaceOpts , index )
75
75
return err
76
76
}); err != nil {
77
77
log .Errorf ("[ReplaceContainer] Replace and remove failed %v, old container restarted" , err )
@@ -93,7 +93,7 @@ func (c *Calcium) ReplaceContainer(ctx context.Context, opts *types.ReplaceOptio
93
93
func (c * Calcium ) doReplaceContainer (
94
94
ctx context.Context ,
95
95
container * types.Container ,
96
- containerJSON * enginetypes.VirtualizationInfo ,
96
+ containerInfo * enginetypes.VirtualizationInfo ,
97
97
opts * types.ReplaceOptions ,
98
98
index int ,
99
99
) (* types.CreateContainerMessage , * types.RemoveContainerMessage , error ) {
@@ -103,7 +103,7 @@ func (c *Calcium) doReplaceContainer(
103
103
Hook : []* bytes.Buffer {},
104
104
}
105
105
// label filter
106
- if ! utils .FilterContainer (containerJSON .Labels , opts .FilterLabels ) {
106
+ if ! utils .FilterContainer (containerInfo .Labels , opts .FilterLabels ) {
107
107
return nil , removeMessage , types .ErrNotFitLabels
108
108
}
109
109
// get node
@@ -128,7 +128,7 @@ func (c *Calcium) doReplaceContainer(
128
128
opts .DeployOptions .Data [dst ] = fname
129
129
}
130
130
// 停止容器
131
- removeMessage .Hook , err = c .doStopContainer (ctx , container , containerJSON , opts .IgnoreHook )
131
+ removeMessage .Hook , err = c .doStopContainer (ctx , container , containerInfo , opts .IgnoreHook )
132
132
if err != nil {
133
133
return nil , removeMessage , err
134
134
}
@@ -137,8 +137,7 @@ func (c *Calcium) doReplaceContainer(
137
137
createMessage := c .doCreateAndStartContainer (ctx , index , node , & opts .DeployOptions , container .CPU )
138
138
if createMessage .Error != nil {
139
139
// 重启老容器
140
- // TODO consider this force?
141
- message , err := c .doStartContainer (ctx , container , containerJSON , opts .IgnoreHook )
140
+ message , err := c .doStartContainer (ctx , container , containerInfo , opts .IgnoreHook )
142
141
removeMessage .Hook = append (removeMessage .Hook , message ... )
143
142
if err != nil {
144
143
log .Errorf ("[replaceAndRemove] Old container %s restart failed %v" , container .ID , err )
0 commit comments