@@ -125,13 +125,13 @@ func (sm *ServiceManager) Reconcile() {
125125 if sm .ServiceInfo .Status == types .ServiceStatusNotReady {
126126
127127 // 如果有容器正在启动,就不再继续
128- if sm .ServiceInfo . Deployment . Type != types . DeployTypeSchedule && sm .HasPendingContainer () {
128+ if ! sm .IsRunningWithSchedule () && sm .HasPendingContainer () {
129129 slog .Info ("[Service Manager] Wait pending container......" , "ServiceId" , sm .ServiceInfo .ServiceId )
130130 return
131131 }
132132
133133 // 如果有容器失败,就不再继续
134- if sm .ServiceInfo . Deployment . Type != types . DeployTypeSchedule && sm .HasFailedContainer () {
134+ if ! sm .IsRunningWithSchedule () && sm .HasFailedContainer () {
135135 slog .Info ("[Service Manager] container failed, stop dispatch......" , "ServiceId" , sm .ServiceInfo .ServiceId )
136136 sm .ServiceInfo .Status = types .ServiceStatusFailed
137137 sm .ServiceInfo .Memo = types .MemoCreateContainerFailed
@@ -270,12 +270,11 @@ func (sm *ServiceManager) IsContainerAllReady() bool {
270270 version := parseVersionByContainerId (c .ContainerName )
271271 if version == sm .ServiceInfo .Version {
272272 if isContainerExited (c .State ) &&
273- (sm .ServiceInfo .Deployment .Type == types .DeployTypeSchedule ||
274- strings .EqualFold (sm .ServiceInfo .Action , types .ServiceActionStop )) {
273+ (sm .IsRunningWithSchedule () || strings .EqualFold (sm .ServiceInfo .Action , types .ServiceActionStop )) {
275274 continue
276275 }
277276
278- if isContainerStarting (c .State ) && sm .ServiceInfo . Deployment . Type == types . DeployTypeSchedule {
277+ if isContainerStarting (c .State ) && sm .IsRunningWithSchedule () {
279278 continue
280279 }
281280
@@ -321,6 +320,10 @@ func (sm *ServiceManager) HasFailedContainer() bool {
321320 return false
322321}
323322
323+ func (sm * ServiceManager ) IsRunningWithSchedule () bool {
324+ return sm .ServiceInfo .Deployment .Type == types .DeployTypeSchedule || sm .ServiceInfo .Deployment .ManualExec
325+ }
326+
324327func (sm * ServiceManager ) TryToDeleteOne () (* types.ContainerStatus , bool ) {
325328
326329 nodeDeployed := make (map [string ]bool )
@@ -330,10 +333,8 @@ func (sm *ServiceManager) TryToDeleteOne() (*types.ContainerStatus, bool) {
330333 if version != sm .ServiceInfo .Version {
331334 return c , true
332335 }
333- if isContainerExited (c .State ) {
334- if sm .ServiceInfo .Deployment .Type == types .DeployTypeBackground {
335- return c , true
336- }
336+ if isContainerExited (c .State ) && ! sm .IsRunningWithSchedule () {
337+ return c , true
337338 }
338339 if isContainerWarning (c .State ) || isContainerRemoved (c .State ) {
339340 return c , true
0 commit comments