Skip to content

[pull] main from coder:main #73

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
623dcd9
fix(cli): fix flakes related to context cancellation when establishin…
hugodutka Jun 5, 2025
04e4f2f
chore(agent): update agent proto client (#18242)
mafredri Jun 5, 2025
c54ef03
docs: update Smarter Device Manager link to new GitHub repository (#1…
blink-so[bot] Jun 5, 2025
2c0c58a
fix: improve copy for tasks "starting" page (#18247)
blink-so[bot] Jun 5, 2025
2f8b056
test(agent/agentcontainers): fix test data race due to list manipulat…
mafredri Jun 5, 2025
3f406c7
fix: improve sidebar chat loading UX in tasks (#18254)
hugodutka Jun 5, 2025
60595f3
chore: ignore `.git` directories in terraform modules (#18255)
Emyrk Jun 5, 2025
8a70b8d
chore: select the first workspace app to be active in tasks (#18256)
hugodutka Jun 5, 2025
0428c5e
chore: include 'everyone' group in template importing (#18257)
Emyrk Jun 5, 2025
c339066
chore: select the first embedded app on tasks page (#18260)
code-asher Jun 5, 2025
508fba8
feat: handle update build for dynamic params (#18226)
jaaydenh Jun 5, 2025
b4f71b7
fix: show preset parameters when they have diagnostics (#18258)
blink-so[bot] Jun 5, 2025
0076e84
chore(vpn): send ping results over tunnel (#18200)
ethanndickson Jun 6, 2025
628b81c
chore(vpn): send info, debug logs over tunnel (#18240)
ethanndickson Jun 6, 2025
08eff7f
chore: improve tailnet integration test (#18124)
spikecurtis Jun 6, 2025
7c2fb66
chore(provisionersdk): ignore io.EOF in Session.requestReader (#18234)
johnstcn Jun 6, 2025
533c6dc
fix: remove error log when notification manager is already closed (#1…
ethanndickson Jun 6, 2025
a12429e
feat(agent/agentcontainers): refactor Lister to ContainerCLI and impl…
mafredri Jun 6, 2025
709f374
feat(agent/agentcontainers): add Exec method to devcontainers CLI (#1…
mafredri Jun 6, 2025
d47a53d
fix: handle paths with spaces in Match exec clause of SSH config (#18…
spikecurtis Jun 6, 2025
348d19d
chore: use spaces over tabs in proto files (#18269)
Emyrk Jun 6, 2025
f569d9c
feat: add separate max token lifetime for administrators (#18267)
ThomasK33 Jun 6, 2025
8daa0aa
feat(coderd/agentapi): support adding display apps to a sub agent (#1…
DanielleMaywood Jun 6, 2025
7d8b994
chore(dogfood): group web editors together (#18143)
aslilac Jun 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func (t *trySingleflight) Do(key string, fn func()) {
fn()
}

func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
tickerDone := make(chan struct{})
collectDone := make(chan struct{})
ctx, cancel := context.WithCancel(ctx)
Expand Down Expand Up @@ -672,7 +672,7 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient24

// reportLifecycle reports the current lifecycle state once. All state
// changes are reported in order.
func (a *agent) reportLifecycle(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
func (a *agent) reportLifecycle(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
for {
select {
case <-a.lifecycleUpdate:
Expand Down Expand Up @@ -752,7 +752,7 @@ func (a *agent) setLifecycle(state codersdk.WorkspaceAgentLifecycle) {
}

// reportConnectionsLoop reports connections to the agent for auditing.
func (a *agent) reportConnectionsLoop(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
func (a *agent) reportConnectionsLoop(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
for {
select {
case <-a.reportConnectionsUpdate:
Expand Down Expand Up @@ -872,7 +872,7 @@ func (a *agent) reportConnection(id uuid.UUID, connectionType proto.Connection_T
// fetchServiceBannerLoop fetches the service banner on an interval. It will
// not be fetched immediately; the expectation is that it is primed elsewhere
// (and must be done before the session actually starts).
func (a *agent) fetchServiceBannerLoop(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
func (a *agent) fetchServiceBannerLoop(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
ticker := time.NewTicker(a.announcementBannersRefreshInterval)
defer ticker.Stop()
for {
Expand Down Expand Up @@ -925,7 +925,7 @@ func (a *agent) run() (retErr error) {
connMan := newAPIConnRoutineManager(a.gracefulCtx, a.hardCtx, a.logger, aAPI, tAPI)

connMan.startAgentAPI("init notification banners", gracefulShutdownBehaviorStop,
func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
func(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
bannersProto, err := aAPI.GetAnnouncementBanners(ctx, &proto.GetAnnouncementBannersRequest{})
if err != nil {
return xerrors.Errorf("fetch service banner: %w", err)
Expand All @@ -942,7 +942,7 @@ func (a *agent) run() (retErr error) {
// sending logs gets gracefulShutdownBehaviorRemain because we want to send logs generated by
// shutdown scripts.
connMan.startAgentAPI("send logs", gracefulShutdownBehaviorRemain,
func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
func(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
err := a.logSender.SendLoop(ctx, aAPI)
if xerrors.Is(err, agentsdk.ErrLogLimitExceeded) {
// we don't want this error to tear down the API connection and propagate to the
Expand All @@ -961,7 +961,7 @@ func (a *agent) run() (retErr error) {
connMan.startAgentAPI("report metadata", gracefulShutdownBehaviorStop, a.reportMetadata)

// resources monitor can cease as soon as we start gracefully shutting down.
connMan.startAgentAPI("resources monitor", gracefulShutdownBehaviorStop, func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
connMan.startAgentAPI("resources monitor", gracefulShutdownBehaviorStop, func(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
logger := a.logger.Named("resources_monitor")
clk := quartz.NewReal()
config, err := aAPI.GetResourcesMonitoringConfiguration(ctx, &proto.GetResourcesMonitoringConfigurationRequest{})
Expand Down Expand Up @@ -1008,7 +1008,7 @@ func (a *agent) run() (retErr error) {
connMan.startAgentAPI("handle manifest", gracefulShutdownBehaviorStop, a.handleManifest(manifestOK))

connMan.startAgentAPI("app health reporter", gracefulShutdownBehaviorStop,
func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
func(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
if err := manifestOK.wait(ctx); err != nil {
return xerrors.Errorf("no manifest: %w", err)
}
Expand Down Expand Up @@ -1041,7 +1041,7 @@ func (a *agent) run() (retErr error) {

connMan.startAgentAPI("fetch service banner loop", gracefulShutdownBehaviorStop, a.fetchServiceBannerLoop)

connMan.startAgentAPI("stats report loop", gracefulShutdownBehaviorStop, func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
connMan.startAgentAPI("stats report loop", gracefulShutdownBehaviorStop, func(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
if err := networkOK.wait(ctx); err != nil {
return xerrors.Errorf("no network: %w", err)
}
Expand All @@ -1056,8 +1056,8 @@ func (a *agent) run() (retErr error) {
}

// handleManifest returns a function that fetches and processes the manifest
func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
return func(ctx context.Context, aAPI proto.DRPCAgentClient24) error {
func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
return func(ctx context.Context, aAPI proto.DRPCAgentClient26) error {
var (
sentResult = false
err error
Expand Down Expand Up @@ -1187,8 +1187,8 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,

// createOrUpdateNetwork waits for the manifest to be set using manifestOK, then creates or updates
// the tailnet using the information in the manifest
func (a *agent) createOrUpdateNetwork(manifestOK, networkOK *checkpoint) func(context.Context, proto.DRPCAgentClient24) error {
return func(ctx context.Context, _ proto.DRPCAgentClient24) (retErr error) {
func (a *agent) createOrUpdateNetwork(manifestOK, networkOK *checkpoint) func(context.Context, proto.DRPCAgentClient26) error {
return func(ctx context.Context, _ proto.DRPCAgentClient26) (retErr error) {
if err := manifestOK.wait(ctx); err != nil {
return xerrors.Errorf("no manifest: %w", err)
}
Expand Down Expand Up @@ -1960,7 +1960,7 @@ const (

type apiConnRoutineManager struct {
logger slog.Logger
aAPI proto.DRPCAgentClient24
aAPI proto.DRPCAgentClient26
tAPI tailnetproto.DRPCTailnetClient24
eg *errgroup.Group
stopCtx context.Context
Expand All @@ -1969,7 +1969,7 @@ type apiConnRoutineManager struct {

func newAPIConnRoutineManager(
gracefulCtx, hardCtx context.Context, logger slog.Logger,
aAPI proto.DRPCAgentClient24, tAPI tailnetproto.DRPCTailnetClient24,
aAPI proto.DRPCAgentClient26, tAPI tailnetproto.DRPCTailnetClient24,
) *apiConnRoutineManager {
// routines that remain in operation during graceful shutdown use the remainCtx. They'll still
// exit if the errgroup hits an error, which usually means a problem with the conn.
Expand Down Expand Up @@ -2002,7 +2002,7 @@ func newAPIConnRoutineManager(
// but for Tailnet.
func (a *apiConnRoutineManager) startAgentAPI(
name string, behavior gracefulShutdownBehavior,
f func(context.Context, proto.DRPCAgentClient24) error,
f func(context.Context, proto.DRPCAgentClient26) error,
) {
logger := a.logger.With(slog.F("name", name))
var ctx context.Context
Expand Down
100 changes: 84 additions & 16 deletions agent/agentcontainers/acmock/acmock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion agent/agentcontainers/acmock/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package acmock contains a mock implementation of agentcontainers.Lister for use in tests.
package acmock

//go:generate mockgen -destination ./acmock.go -package acmock .. Lister,DevcontainerCLI
//go:generate mockgen -destination ./acmock.go -package acmock .. ContainerCLI,DevcontainerCLI
20 changes: 11 additions & 9 deletions agent/agentcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type API struct {
logger slog.Logger
watcher watcher.Watcher
execer agentexec.Execer
cl Lister
ccli ContainerCLI
dccli DevcontainerCLI
clock quartz.Clock
scriptLogger func(logSourceID uuid.UUID) ScriptLogger
Expand Down Expand Up @@ -80,11 +80,11 @@ func WithExecer(execer agentexec.Execer) Option {
}
}

// WithLister sets the agentcontainers.Lister implementation to use.
// The default implementation uses the Docker CLI to list containers.
func WithLister(cl Lister) Option {
// WithContainerCLI sets the agentcontainers.ContainerCLI implementation
// to use. The default implementation uses the Docker CLI.
func WithContainerCLI(ccli ContainerCLI) Option {
return func(api *API) {
api.cl = cl
api.ccli = ccli
}
}

Expand Down Expand Up @@ -186,8 +186,8 @@ func NewAPI(logger slog.Logger, options ...Option) *API {
for _, opt := range options {
opt(api)
}
if api.cl == nil {
api.cl = NewDocker(api.execer)
if api.ccli == nil {
api.ccli = NewDockerCLI(api.execer)
}
if api.dccli == nil {
api.dccli = NewDevcontainerCLI(logger.Named("devcontainer-cli"), api.execer)
Expand Down Expand Up @@ -363,7 +363,7 @@ func (api *API) updateContainers(ctx context.Context) error {
listCtx, listCancel := context.WithTimeout(ctx, listContainersTimeout)
defer listCancel()

updated, err := api.cl.List(listCtx)
updated, err := api.ccli.List(listCtx)
if err != nil {
// If the context was canceled, we hold off on clearing the
// containers cache. This is to avoid clearing the cache if
Expand All @@ -378,6 +378,8 @@ func (api *API) updateContainers(ctx context.Context) error {

return xerrors.Errorf("list containers failed: %w", err)
}
// Clone to avoid test flakes due to data manipulation.
updated.Containers = slices.Clone(updated.Containers)

api.mu.Lock()
defer api.mu.Unlock()
Expand Down Expand Up @@ -682,7 +684,7 @@ func (api *API) recreateDevcontainer(dc codersdk.WorkspaceAgentDevcontainer, con

logger.Debug(ctx, "starting devcontainer recreation")

_, err = api.dccli.Up(ctx, dc.WorkspaceFolder, configPath, WithOutput(infoW, errW), WithRemoveExistingContainer())
_, err = api.dccli.Up(ctx, dc.WorkspaceFolder, configPath, WithUpOutput(infoW, errW), WithRemoveExistingContainer())
if err != nil {
// No need to log if the API is closing (context canceled), as this
// is expected behavior when the API is shutting down.
Expand Down
Loading
Loading