@@ -125,15 +125,16 @@ 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
137+ sm .ServiceInfo .Memo = types .MemoCreateContainerFailed
137138 db .ServiceUpdate (sm .ServiceInfo )
138139 return
139140 }
@@ -269,12 +270,11 @@ func (sm *ServiceManager) IsContainerAllReady() bool {
269270 version := parseVersionByContainerId (c .ContainerName )
270271 if version == sm .ServiceInfo .Version {
271272 if isContainerExited (c .State ) &&
272- (sm .ServiceInfo .Deployment .Type == types .DeployTypeSchedule ||
273- strings .EqualFold (sm .ServiceInfo .Action , types .ServiceActionStop )) {
273+ (sm .IsRunningWithSchedule () || strings .EqualFold (sm .ServiceInfo .Action , types .ServiceActionStop )) {
274274 continue
275275 }
276276
277- if isContainerStarting (c .State ) && sm .ServiceInfo . Deployment . Type == types . DeployTypeSchedule {
277+ if isContainerStarting (c .State ) && sm .IsRunningWithSchedule () {
278278 continue
279279 }
280280
@@ -320,6 +320,10 @@ func (sm *ServiceManager) HasFailedContainer() bool {
320320 return false
321321}
322322
323+ func (sm * ServiceManager ) IsRunningWithSchedule () bool {
324+ return sm .ServiceInfo .Deployment .Type == types .DeployTypeSchedule || sm .ServiceInfo .Deployment .ManualExec
325+ }
326+
323327func (sm * ServiceManager ) TryToDeleteOne () (* types.ContainerStatus , bool ) {
324328
325329 nodeDeployed := make (map [string ]bool )
@@ -329,10 +333,8 @@ func (sm *ServiceManager) TryToDeleteOne() (*types.ContainerStatus, bool) {
329333 if version != sm .ServiceInfo .Version {
330334 return c , true
331335 }
332- if isContainerExited (c .State ) {
333- if sm .ServiceInfo .Deployment .Type == types .DeployTypeBackground {
334- return c , true
335- }
336+ if isContainerExited (c .State ) && ! sm .IsRunningWithSchedule () {
337+ return c , true
336338 }
337339 if isContainerWarning (c .State ) || isContainerRemoved (c .State ) {
338340 return c , true
0 commit comments