Skip to content

Commit

Permalink
fix(region): container exited status checking (#21347)
Browse files Browse the repository at this point in the history
  • Loading branch information
zexi authored Oct 5, 2024
1 parent 2e7b443 commit 5a5631a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/compute/models/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ func (c *SContainer) StartCreateTask(ctx context.Context, userCred mcclient.Toke
}

func (c *SContainer) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input *api.ContainerUpdateInput) (*api.ContainerUpdateInput, error) {
if c.GetStatus() != api.CONTAINER_STATUS_EXITED {
return nil, httperrors.NewInvalidStatusError("current status %s is not %s", c.GetStatus(), api.CONTAINER_STATUS_EXITED)
if !api.ContainerExitedStatus.Has(c.GetStatus()) {
return nil, httperrors.NewInvalidStatusError("current status %s is not in %v", c.GetStatus(), api.ContainerExitedStatus.List())
}

baseInput, err := c.SVirtualResourceBase.ValidateUpdateData(ctx, userCred, query, input.VirtualResourceBaseUpdateInput)
Expand Down
2 changes: 1 addition & 1 deletion pkg/compute/tasks/pod_stop_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (t *PodStopTask) OnWaitContainerStopped(ctx context.Context, pod *models.SG
for i := range ctrs {
curCtr := ctrs[i]
log.Infof("========container status: %s", curCtr.GetStatus())
if curCtr.GetStatus() != api.CONTAINER_STATUS_EXITED {
if !api.ContainerExitedStatus.Has(curCtr.GetStatus()) {
isAllStopped = false
curCtr.StartStopTask(ctx, t.GetUserCred(), &api.ContainerStopInput{
Timeout: 1,
Expand Down

0 comments on commit 5a5631a

Please sign in to comment.