mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(agent/agentcontainers): update containers periodically (#17972)
This change introduces a significant refactor to the agentcontainers API and enables periodic updates of Docker containers rather than on-demand. Consequently this change also allows us to move away from using a locking channel and replace it with a mutex, which simplifies usage. Additionally a previous oversight was fixed, and testing added, to clear devcontainer running/dirty status when the container has been removed. Updates coder/coder#16424 Updates coder/internal#621
This commit is contained in:
+2
-2
@@ -326,7 +326,7 @@ func TestOpenVSCodeDevContainer(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}, nil,
|
||||
)
|
||||
).AnyTimes()
|
||||
|
||||
client, workspace, agentToken := setupWorkspaceForAgent(t, func(agents []*proto.Agent) []*proto.Agent {
|
||||
agents[0].Directory = agentDir
|
||||
@@ -501,7 +501,7 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}, nil,
|
||||
)
|
||||
).AnyTimes()
|
||||
|
||||
client, workspace, agentToken := setupWorkspaceForAgent(t, func(agents []*proto.Agent) []*proto.Agent {
|
||||
agents[0].Name = agentName
|
||||
|
||||
+6
-7
@@ -2056,12 +2056,6 @@ func TestSSH_Container(t *testing.T) {
|
||||
client, workspace, agentToken := setupWorkspaceForAgent(t)
|
||||
ctrl := gomock.NewController(t)
|
||||
mLister := acmock.NewMockLister(ctrl)
|
||||
_ = agenttest.New(t, client.URL, agentToken, func(o *agent.Options) {
|
||||
o.ExperimentalDevcontainersEnabled = true
|
||||
o.ContainerAPIOptions = append(o.ContainerAPIOptions, agentcontainers.WithLister(mLister))
|
||||
})
|
||||
_ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
|
||||
|
||||
mLister.EXPECT().List(gomock.Any()).Return(codersdk.WorkspaceAgentListContainersResponse{
|
||||
Containers: []codersdk.WorkspaceAgentContainer{
|
||||
{
|
||||
@@ -2070,7 +2064,12 @@ func TestSSH_Container(t *testing.T) {
|
||||
},
|
||||
},
|
||||
Warnings: nil,
|
||||
}, nil)
|
||||
}, nil).AnyTimes()
|
||||
_ = agenttest.New(t, client.URL, agentToken, func(o *agent.Options) {
|
||||
o.ExperimentalDevcontainersEnabled = true
|
||||
o.ContainerAPIOptions = append(o.ContainerAPIOptions, agentcontainers.WithLister(mLister))
|
||||
})
|
||||
_ = coderdtest.NewWorkspaceAgentWaiter(t, client, workspace.ID).Wait()
|
||||
|
||||
cID := uuid.NewString()
|
||||
inv, root := clitest.New(t, "ssh", workspace.Name, "-c", cID)
|
||||
|
||||
Reference in New Issue
Block a user