Skip to content

Commit 1c097ef

Browse files
committed
fix(agent/agentcontainers): remove deleted devcontainers
1 parent 4fd0312 commit 1c097ef

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

agent/agentcontainers/api.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,19 @@ func (api *API) processUpdatedContainersLocked(ctx context.Context, updated code
660660
}
661661

662662
case dc.Container == nil:
663-
if !api.devcontainerNames[dc.Name] {
664-
dc.Name = ""
663+
if !api.devcontainerNames[dc.Name] { // TODO(mafredri): Change this, not stable after https://github.com/coder/coder/pull/18513
664+
// If this is a runtime-detected container, check if we
665+
// should remove it.
666+
// TODO(mafredri): Consider using afero.
667+
if _, err := os.Stat(dc.WorkspaceFolder); errors.Is(err, os.ErrNotExist) {
668+
// If the workspace folder doesn't exist, we can assume
669+
// that the devcontainer is no longer valid and should be
670+
// removed.
671+
logger.Debug(ctx, "devcontainer workspace folder does not exist, removing devcontainer")
672+
delete(api.knownDevcontainers, dc.WorkspaceFolder)
673+
// TODO(mafredri): Delete the agent if it exists.
674+
continue
675+
}
665676
}
666677
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusStopped
667678
dc.Dirty = false

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy