Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0731304

Browse files
authored
feat(agent/agentcontainers): recreate devcontainers concurrently (#18042)
This change introduces a refactor of the devcontainers recreation logicwhich is now handled asynchronously rather than being request scoped.The response was consequently changed from "No Content" to "Accepted" toreflect this.A new `Status` field was introduced to the devcontainer struct whichreplaces `Running` (bool). This reflects that the devcontainer can nowbe in various states (starting, running, stopped or errored).The status field also protects against multiple concurrent recrations,as long as they are initiated via the API.Updates#16424
1 parent60fd03d commit0731304

File tree

10 files changed

+414
-157
lines changed

10 files changed

+414
-157
lines changed

‎agent/agent_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2188,14 +2188,14 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
21882188

21892189
t.Logf("Looking for container with label: devcontainer.local_folder=%s",workspaceFolder)
21902190

2191-
varcontainerdocker.APIContainers
2191+
varcontainercodersdk.WorkspaceAgentContainer
21922192
testutil.Eventually(ctx,t,func(context.Context)bool {
2193-
containers,err:=pool.Client.ListContainers(docker.ListContainersOptions{All:true})
2193+
resp,err:=conn.ListContainers(ctx)
21942194
iferr!=nil {
21952195
t.Logf("Error listing containers: %v",err)
21962196
returnfalse
21972197
}
2198-
for_,c:=rangecontainers {
2198+
for_,c:=rangeresp.Containers {
21992199
t.Logf("Found container: %s with labels: %v",c.ID[:12],c.Labels)
22002200
ifv,ok:=c.Labels["devcontainer.local_folder"];ok&&v==workspaceFolder {
22012201
t.Logf("Found matching container: %s",c.ID[:12])
@@ -2205,7 +2205,7 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
22052205
}
22062206
returnfalse
22072207
},testutil.IntervalMedium,"no container with workspace folder label found")
2208-
deferfunc(containerdocker.APIContainers) {
2208+
deferfunc(containercodersdk.WorkspaceAgentContainer) {
22092209
// We can't rely on pool here because the container is not
22102210
// managed by it (it is managed by @devcontainer/cli).
22112211
err:=pool.Client.RemoveContainer(docker.RemoveContainerOptions{
@@ -2225,7 +2225,7 @@ func TestAgent_DevcontainerRecreate(t *testing.T) {
22252225
// Invoke recreate to trigger the destruction and recreation of the
22262226
// devcontainer, we do it in a goroutine so we can process logs
22272227
// concurrently.
2228-
gofunc(containerdocker.APIContainers) {
2228+
gofunc(containercodersdk.WorkspaceAgentContainer) {
22292229
err:=conn.RecreateDevcontainer(ctx,container.ID)
22302230
assert.NoError(t,err,"recreate devcontainer should succeed")
22312231
}(container)
@@ -2253,12 +2253,12 @@ waitForOutcomeLoop:
22532253

22542254
// Make sure the container exists and isn't the same as the old one.
22552255
testutil.Eventually(ctx,t,func(context.Context)bool {
2256-
containers,err:=pool.Client.ListContainers(docker.ListContainersOptions{All:true})
2256+
resp,err:=conn.ListContainers(ctx)
22572257
iferr!=nil {
22582258
t.Logf("Error listing containers: %v",err)
22592259
returnfalse
22602260
}
2261-
for_,c:=rangecontainers {
2261+
for_,c:=rangeresp.Containers {
22622262
t.Logf("Found container: %s with labels: %v",c.ID[:12],c.Labels)
22632263
ifv,ok:=c.Labels["devcontainer.local_folder"];ok&&v==workspaceFolder {
22642264
ifc.ID==container.ID {
@@ -2272,7 +2272,7 @@ waitForOutcomeLoop:
22722272
}
22732273
returnfalse
22742274
},testutil.IntervalMedium,"new devcontainer not found")
2275-
deferfunc(containerdocker.APIContainers) {
2275+
deferfunc(containercodersdk.WorkspaceAgentContainer) {
22762276
// We can't rely on pool here because the container is not
22772277
// managed by it (it is managed by @devcontainer/cli).
22782278
err:=pool.Client.RemoveContainer(docker.RemoveContainerOptions{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp