88 "time"
99
1010 "github.com/laincloud/deployd/cluster"
11+ "github.com/laincloud/deployd/utils/util"
1112 "github.com/mijia/adoc"
1213 "github.com/mijia/go-generics"
1314 "github.com/mijia/sweb/log"
@@ -69,14 +70,18 @@ func (pc *podController) Deploy(cluster cluster.Cluster) {
6970 id , err := pc .createContainer (cluster , filters , i )
7071 if err != nil {
7172 log .Warnf ("%s Cannot create container, error=%q, spec=%+v" , pc , err , cSpec )
72- pc .pod .State = RunStateFail
73+ if ! util .IsConnectionError (err ) {
74+ pc .pod .State = RunStateFail
75+ }
7376 pc .pod .LastError = fmt .Sprintf ("Cannot create container, %s" , err )
7477 return
7578 }
7679
7780 if err := cluster .StartContainer (id ); err != nil {
7881 log .Warnf ("%s Cannot start container %s, %s" , pc , id , err )
79- pc .pod .State = RunStateFail
82+ if ! util .IsConnectionError (err ) {
83+ pc .pod .State = RunStateFail
84+ }
8085 pc .pod .LastError = fmt .Sprintf ("Cannot start container, %s" , err )
8186 }
8287
@@ -177,7 +182,9 @@ func (pc *podController) Stop(cluster cluster.Cluster) {
177182 for i , container := range pc .pod .Containers {
178183 if err := cluster .StopContainer (container .Id , pc .spec .GetKillTimeout ()); err != nil {
179184 log .Warnf ("%s Cannot stop the container %s, %s" , pc , container .Id , err )
180- pc .pod .State = RunStateFail
185+ if ! util .IsConnectionError (err ) {
186+ pc .pod .State = RunStateFail
187+ }
181188 pc .pod .LastError = fmt .Sprintf ("Cannot stop container, %s" , err )
182189 } else {
183190 pc .refreshContainer (cluster , i )
@@ -200,7 +207,9 @@ func (pc *podController) Start(cluster cluster.Cluster) {
200207 for i , container := range pc .pod .Containers {
201208 if err := cluster .StartContainer (container .Id ); err != nil {
202209 log .Warnf ("%s Cannot start the container %s, %s" , pc , container .Id , err )
203- pc .pod .State = RunStateFail
210+ if ! util .IsConnectionError (err ) {
211+ pc .pod .State = RunStateFail
212+ }
204213 pc .pod .LastError = fmt .Sprintf ("Cannot start container, %s" , err )
205214 } else {
206215 pc .refreshContainer (cluster , i )
@@ -273,7 +282,9 @@ func (pc *podController) refreshContainer(kluster cluster.Cluster, index int) {
273282 pc .pod .LastError = fmt .Sprintf ("Missing container %q, %s" , id , err )
274283 } else {
275284 log .Warnf ("%s Failed to inspect container %s, %s" , pc , id , err )
276- pc .pod .State = RunStateFail
285+ if ! util .IsConnectionError (err ) {
286+ pc .pod .State = RunStateFail
287+ }
277288 pc .pod .LastError = fmt .Sprintf ("Cannot inspect the container, %s" , err )
278289 }
279290 } else {
@@ -282,7 +293,6 @@ func (pc *podController) refreshContainer(kluster cluster.Cluster, index int) {
282293 network = pc .spec .Namespace
283294 }
284295 prevIP , nowIP := pc .spec .PrevState .IPs [index ], info .NetworkSettings .Networks [network ].IPAddress
285-
286296 // NOTE: if the container's ip is not equal to prev ip, try to correct it; if failed, accpet new ip
287297 if prevIP != "" && prevIP != nowIP {
288298 log .Warnf ("%s find the IP changed, prev is %s, but now is %s, try to correct it" , pc , prevIP , nowIP )
0 commit comments