Skip to content

Commit 1ac349e

Browse files
Merge branch 'coder:main' into main
2 parents 8a8c7fc + 7d8b994 commit 1ac349e

File tree

110 files changed

+6302
-2106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+6302
-2106
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ jobs:
15261526
uses: google-github-actions/setup-gcloud@77e7a554d41e2ee56fc945c52dfd3f33d12def9a # v2.1.4
15271527

15281528
- name: Set up Flux CLI
1529-
uses: fluxcd/flux2/action@8d5f40dca5aa5d3c0fc3414457dda15a0ac92fa4 # v2.5.1
1529+
uses: fluxcd/flux2/action@b73c7f7191086ca7629840e680e71873349787f8 # v2.6.1
15301530
with:
15311531
# Keep this and the github action up to date with the version of flux installed in dogfood cluster
15321532
version: "2.5.1"

.github/workflows/docs-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Setup Node
2929
uses: ./.github/actions/setup-node
3030

31-
- uses: tj-actions/changed-files@3981e4f74104e7a4c67a835e1e5dd5d9eb0f0a57 # v45.0.7
31+
- uses: tj-actions/changed-files@115870536a85eaf050e369291c7895748ff12aea # v45.0.7
3232
id: changed-files
3333
with:
3434
files: |

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
persist-credentials: false
3131

3232
- name: "Run analysis"
33-
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
33+
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
3434
with:
3535
results_file: results.sarif
3636
results_format: sarif

agent/agent.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ func (t *trySingleflight) Do(key string, fn func()) {
456456
fn()
457457
}
458458

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

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

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

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

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

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

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

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

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

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

19611961
type apiConnRoutineManager struct {
19621962
logger slog.Logger
1963-
aAPI proto.DRPCAgentClient24
1963+
aAPI proto.DRPCAgentClient26
19641964
tAPI tailnetproto.DRPCTailnetClient24
19651965
eg *errgroup.Group
19661966
stopCtx context.Context
@@ -1969,7 +1969,7 @@ type apiConnRoutineManager struct {
19691969

19701970
func newAPIConnRoutineManager(
19711971
gracefulCtx, hardCtx context.Context, logger slog.Logger,
1972-
aAPI proto.DRPCAgentClient24, tAPI tailnetproto.DRPCTailnetClient24,
1972+
aAPI proto.DRPCAgentClient26, tAPI tailnetproto.DRPCTailnetClient24,
19731973
) *apiConnRoutineManager {
19741974
// routines that remain in operation during graceful shutdown use the remainCtx. They'll still
19751975
// exit if the errgroup hits an error, which usually means a problem with the conn.
@@ -2002,7 +2002,7 @@ func newAPIConnRoutineManager(
20022002
// but for Tailnet.
20032003
func (a *apiConnRoutineManager) startAgentAPI(
20042004
name string, behavior gracefulShutdownBehavior,
2005-
f func(context.Context, proto.DRPCAgentClient24) error,
2005+
f func(context.Context, proto.DRPCAgentClient26) error,
20062006
) {
20072007
logger := a.logger.With(slog.F("name", name))
20082008
var ctx context.Context

agent/agentcontainers/acmock/acmock.go

Lines changed: 84 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

agent/agentcontainers/acmock/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Package acmock contains a mock implementation of agentcontainers.Lister for use in tests.
22
package acmock
33

4-
//go:generate mockgen -destination ./acmock.go -package acmock .. Lister,DevcontainerCLI
4+
//go:generate mockgen -destination ./acmock.go -package acmock .. ContainerCLI,DevcontainerCLI

agent/agentcontainers/api.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type API struct {
4343
logger slog.Logger
4444
watcher watcher.Watcher
4545
execer agentexec.Execer
46-
cl Lister
46+
ccli ContainerCLI
4747
dccli DevcontainerCLI
4848
clock quartz.Clock
4949
scriptLogger func(logSourceID uuid.UUID) ScriptLogger
@@ -80,11 +80,11 @@ func WithExecer(execer agentexec.Execer) Option {
8080
}
8181
}
8282

83-
// WithLister sets the agentcontainers.Lister implementation to use.
84-
// The default implementation uses the Docker CLI to list containers.
85-
func WithLister(cl Lister) Option {
83+
// WithContainerCLI sets the agentcontainers.ContainerCLI implementation
84+
// to use. The default implementation uses the Docker CLI.
85+
func WithContainerCLI(ccli ContainerCLI) Option {
8686
return func(api *API) {
87-
api.cl = cl
87+
api.ccli = ccli
8888
}
8989
}
9090

@@ -186,8 +186,8 @@ func NewAPI(logger slog.Logger, options ...Option) *API {
186186
for _, opt := range options {
187187
opt(api)
188188
}
189-
if api.cl == nil {
190-
api.cl = NewDocker(api.execer)
189+
if api.ccli == nil {
190+
api.ccli = NewDockerCLI(api.execer)
191191
}
192192
if api.dccli == nil {
193193
api.dccli = NewDevcontainerCLI(logger.Named("devcontainer-cli"), api.execer)
@@ -363,7 +363,7 @@ func (api *API) updateContainers(ctx context.Context) error {
363363
listCtx, listCancel := context.WithTimeout(ctx, listContainersTimeout)
364364
defer listCancel()
365365

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

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

382384
api.mu.Lock()
383385
defer api.mu.Unlock()
@@ -682,7 +684,7 @@ func (api *API) recreateDevcontainer(dc codersdk.WorkspaceAgentDevcontainer, con
682684

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

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

0 commit comments

Comments
 (0)