- Notifications
You must be signed in to change notification settings - Fork948
fix(agent): disable dev container integration inside sub agents#18781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
801585a
12f3dc7
36c276f
15b38be
bb48815
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -336,18 +336,16 @@ func (a *agent) init() { | ||
// will not report anywhere. | ||
a.scriptRunner.RegisterMetrics(a.prometheusRegistry) | ||
containerAPIOpts := []agentcontainers.Option{ | ||
agentcontainers.WithExecer(a.execer), | ||
agentcontainers.WithCommandEnv(a.sshServer.CommandEnv), | ||
agentcontainers.WithScriptLogger(func(logSourceID uuid.UUID) agentcontainers.ScriptLogger { | ||
return a.logSender.GetScriptLogger(logSourceID) | ||
}), | ||
} | ||
containerAPIOpts = append(containerAPIOpts, a.containerAPIOptions...) | ||
a.containerAPI = agentcontainers.NewAPI(a.logger.Named("containers"), containerAPIOpts...) | ||
Comment on lines +339 to +348 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. We're going to create the API by default. This is fine as we only | ||
a.reconnectingPTYServer = reconnectingpty.NewServer( | ||
a.logger.Named("reconnecting-pty"), | ||
@@ -1162,7 +1160,7 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context, | ||
scripts = manifest.Scripts | ||
devcontainerScripts map[uuid.UUID]codersdk.WorkspaceAgentScript | ||
) | ||
if a.devcontainers { | ||
// Init the container API with the manifest and client so that | ||
// we can start accepting requests. The final start of the API | ||
// happens after the startup scripts have been executed to | ||
@@ -1197,7 +1195,7 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context, | ||
// autostarted devcontainer will be included in this time. | ||
err := a.scriptRunner.Execute(a.gracefulCtx, agentscripts.ExecuteStartScripts) | ||
if a.devcontainers { | ||
// Start the container API after the startup scripts have | ||
// been executed to ensure that the required tools can be | ||
// installed. | ||
@@ -1928,10 +1926,8 @@ func (a *agent) Close() error { | ||
a.logger.Error(a.hardCtx, "script runner close", slog.Error(err)) | ||
} | ||
if err := a.containerAPI.Close(); err != nil { | ||
a.logger.Error(a.hardCtx, "container API close", slog.Error(err)) | ||
} | ||
// Wait for the graceful shutdown to complete, but don't wait forever so | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2441,7 +2441,8 @@ func TestAgent_DevcontainersDisabledForSubAgent(t *testing.T) { | ||
// Setup the agent with devcontainers enabled initially. | ||
//nolint:dogsled | ||
conn, _, _, _, _ := setupAgent(t, manifest, 0, func(_ *agenttest.Client, o *agent.Options) { | ||
o.Devcontainers = true | ||
ContributorAuthor
| ||
}) | ||
// Query the containers API endpoint. This should fail because | ||
@@ -2453,8 +2454,8 @@ func TestAgent_DevcontainersDisabledForSubAgent(t *testing.T) { | ||
require.Error(t, err) | ||
// Verify the error message contains the expected text. | ||
require.Contains(t, err.Error(), "Dev Containerfeature notsupported.") | ||
require.Contains(t, err.Error(), "Dev Container integration inside other Dev Containers is explicitly not supported.") | ||
Comment on lines +2457 to +2458 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Reminder to run | ||
} | ||
func TestAgent_Dial(t *testing.T) { | ||
Uh oh!
There was an error while loading.Please reload this page.