From 6d54b36de754d253a013fd9fff7c91a4f002c792 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Tue, 15 Apr 2025 18:27:28 +0800 Subject: [PATCH] fix(region): check status when container exec command (#22422) --- pkg/compute/models/containers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/compute/models/containers.go b/pkg/compute/models/containers.go index 841c7c5b63..97e11f6cea 100644 --- a/pkg/compute/models/containers.go +++ b/pkg/compute/models/containers.go @@ -859,7 +859,10 @@ func (c *SContainer) GetDetailsExecInfo(ctx context.Context, userCred mcclient.T } func (c *SContainer) PerformExecSync(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input *api.ContainerExecSyncInput) (jsonutils.JSONObject, error) { - if !api.ContainerRunningStatus.Has(c.GetStatus()) { + if sets.NewString( + api.CONTAINER_STATUS_EXITED, + api.CONTAINER_STATUS_CREATED, + ).Has(c.GetStatus()) { return nil, httperrors.NewInvalidStatusError("Can't exec container in status %s", c.Status) } return c.GetPodDriver().RequestExecSyncContainer(ctx, userCred, c, input)