Skip to content

Commit 306dbc7

Browse files
committed
Merge branch 'main' into mes/logs-flake
2 parents 35a40df + dc395c3 commit 306dbc7

35 files changed

+1616
-148
lines changed

.github/workflows/ci.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,12 @@ jobs:
490490
gotestsum --format standard-quiet --packages "$PACKAGES" \
491491
-- -timeout=20m -v -p $NUM_PARALLEL_PACKAGES -parallel=$NUM_PARALLEL_TESTS $TESTCOUNT
492492
493+
- name: Upload failed test db dumps
494+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
495+
with:
496+
name: failed-test-db-dump-${{matrix.os}}
497+
path: "**/*.test.sql"
498+
493499
- name: Upload Go Build Cache
494500
uses: ./.github/actions/test-cache/upload
495501
with:
@@ -788,7 +794,7 @@ jobs:
788794
# the check to pass. This is desired in PRs, but not in mainline.
789795
- name: Publish to Chromatic (non-mainline)
790796
if: github.ref != 'refs/heads/main' && github.repository_owner == 'coder'
791-
uses: chromaui/action@4d8ebd13658d795114f8051e25c28d66f14886c6 # v13.1.2
797+
uses: chromaui/action@58d9ffb36c90c97a02d061544ecc849cc4a242a9 # v13.1.3
792798
env:
793799
NODE_OPTIONS: "--max_old_space_size=4096"
794800
STORYBOOK: true
@@ -820,7 +826,7 @@ jobs:
820826
# infinitely "in progress" in mainline unless we re-review each build.
821827
- name: Publish to Chromatic (mainline)
822828
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
823-
uses: chromaui/action@4d8ebd13658d795114f8051e25c28d66f14886c6 # v13.1.2
829+
uses: chromaui/action@58d9ffb36c90c97a02d061544ecc849cc4a242a9 # v13.1.3
824830
env:
825831
NODE_OPTIONS: "--max_old_space_size=4096"
826832
STORYBOOK: true
@@ -1121,7 +1127,7 @@ jobs:
11211127
# Setup GCloud for signing Windows binaries.
11221128
- name: Authenticate to Google Cloud
11231129
id: gcloud_auth
1124-
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
1130+
uses: google-github-actions/auth@b7593ed2efd1c1617e1b0254da33b86225adb2a5 # v2.1.12
11251131
with:
11261132
workload_identity_provider: ${{ secrets.GCP_CODE_SIGNING_WORKLOAD_ID_PROVIDER }}
11271133
service_account: ${{ secrets.GCP_CODE_SIGNING_SERVICE_ACCOUNT }}
@@ -1425,7 +1431,7 @@ jobs:
14251431
fetch-depth: 0
14261432

14271433
- name: Authenticate to Google Cloud
1428-
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
1434+
uses: google-github-actions/auth@b7593ed2efd1c1617e1b0254da33b86225adb2a5 # v2.1.12
14291435
with:
14301436
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
14311437
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com

.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@055970845dd036d7345da7399b7e89f2e10f2b04 # v45.0.7
31+
- uses: tj-actions/changed-files@c2ca2493190021783138cb8aac49bcee14b4bb89 # v45.0.7
3232
id: changed-files
3333
with:
3434
files: |

.github/workflows/dogfood.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262

6363
- name: Get branch name
6464
id: branch-name
65-
uses: tj-actions/branch-names@dde14ac574a8b9b1cedc59a1cf312788af43d8d8 # v8.2.1
65+
uses: tj-actions/branch-names@5250492686b253f06fa55861556d1027b067aeb5 # v9.0.2
6666

6767
- name: "Branch name to Docker tag name"
6868
id: docker-tag-name
@@ -129,7 +129,7 @@ jobs:
129129
uses: ./.github/actions/setup-tf
130130

131131
- name: Authenticate to Google Cloud
132-
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
132+
uses: google-github-actions/auth@b7593ed2efd1c1617e1b0254da33b86225adb2a5 # v2.1.12
133133
with:
134134
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
135135
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com

.github/workflows/nightly-gauntlet.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- windows-2022
2828
steps:
2929
- name: Harden Runner
30-
uses: step-security/harden-runner@6c439dc8bdf85cadbbce9ed30d1c7b959517bc49 # v2.12.2
30+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
3131
with:
3232
egress-policy: audit
3333

@@ -37,6 +37,11 @@ jobs:
3737
- name: Disable Spotlight Indexing
3838
if: runner.os == 'macOS'
3939
run: |
40+
enabled=$(sudo mdutil -a -s | grep "Indexing enabled" | wc -l)
41+
if [ $enabled -eq 0 ]; then
42+
echo "Spotlight indexing is already disabled"
43+
exit 0
44+
fi
4045
sudo mdutil -a -i off
4146
sudo mdutil -X /
4247
sudo launchctl bootout system /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

.github/workflows/release.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: Switch XCode Version
6161
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
6262
with:
63-
xcode-version: "16.0.0"
63+
xcode-version: "16.1.0"
6464

6565
- name: Setup Go
6666
uses: ./.github/actions/setup-go
@@ -286,7 +286,7 @@ jobs:
286286
# Setup GCloud for signing Windows binaries.
287287
- name: Authenticate to Google Cloud
288288
id: gcloud_auth
289-
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
289+
uses: google-github-actions/auth@b7593ed2efd1c1617e1b0254da33b86225adb2a5 # v2.1.12
290290
with:
291291
workload_identity_provider: ${{ secrets.GCP_CODE_SIGNING_WORKLOAD_ID_PROVIDER }}
292292
service_account: ${{ secrets.GCP_CODE_SIGNING_SERVICE_ACCOUNT }}
@@ -655,7 +655,7 @@ jobs:
655655
detached_signature="${binary}.asc"
656656
gcloud storage cp "./site/out/bin/${binary}" "gs://releases.coder.com/coder-cli/${version}/${binary}"
657657
gcloud storage cp "./site/out/bin/${detached_signature}" "gs://releases.coder.com/coder-cli/${version}/${detached_signature}"
658-
done
658+
done
659659
660660
- name: Publish release
661661
run: |
@@ -696,7 +696,7 @@ jobs:
696696
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.GPG_RELEASE_KEY_BASE64 }}
697697

698698
- name: Authenticate to Google Cloud
699-
uses: google-github-actions/auth@140bb5113ffb6b65a7e9b937a81fa96cf5064462 # v2.1.11
699+
uses: google-github-actions/auth@b7593ed2efd1c1617e1b0254da33b86225adb2a5 # v2.1.12
700700
with:
701701
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_ID_PROVIDER }}
702702
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ jobs:
4747

4848
# Upload the results to GitHub's code scanning dashboard.
4949
- name: "Upload to code-scanning"
50-
uses: github/codeql-action/upload-sarif@d6bbdef45e766d081b84a2def353b0055f728d3e # v3.29.3
50+
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
5151
with:
5252
sarif_file: results.sarif

.github/workflows/security.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: ./.github/actions/setup-go
3939

4040
- name: Initialize CodeQL
41-
uses: github/codeql-action/init@d6bbdef45e766d081b84a2def353b0055f728d3e # v3.29.3
41+
uses: github/codeql-action/init@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
4242
with:
4343
languages: go, javascript
4444

@@ -48,7 +48,7 @@ jobs:
4848
rm Makefile
4949
5050
- name: Perform CodeQL Analysis
51-
uses: github/codeql-action/analyze@d6bbdef45e766d081b84a2def353b0055f728d3e # v3.29.3
51+
uses: github/codeql-action/analyze@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
5252

5353
- name: Send Slack notification on failure
5454
if: ${{ failure() }}
@@ -150,7 +150,7 @@ jobs:
150150
severity: "CRITICAL,HIGH"
151151

152152
- name: Upload Trivy scan results to GitHub Security tab
153-
uses: github/codeql-action/upload-sarif@d6bbdef45e766d081b84a2def353b0055f728d3e # v3.29.3
153+
uses: github/codeql-action/upload-sarif@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
154154
with:
155155
sarif_file: trivy-results.sarif
156156
category: "Trivy"

agent/agentcontainers/api.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ type API struct {
7777
subAgentURL string
7878
subAgentEnv []string
7979

80-
projectDiscovery bool // If we should perform project discovery or not.
80+
projectDiscovery bool // If we should perform project discovery or not.
81+
discoveryAutostart bool // If we should autostart discovered projects.
8182

8283
ownerName string
8384
workspaceName string
@@ -144,7 +145,8 @@ func WithCommandEnv(ce CommandEnv) Option {
144145
strings.HasPrefix(s, "CODER_AGENT_TOKEN=") ||
145146
strings.HasPrefix(s, "CODER_AGENT_AUTH=") ||
146147
strings.HasPrefix(s, "CODER_AGENT_DEVCONTAINERS_ENABLE=") ||
147-
strings.HasPrefix(s, "CODER_AGENT_DEVCONTAINERS_PROJECT_DISCOVERY_ENABLE=")
148+
strings.HasPrefix(s, "CODER_AGENT_DEVCONTAINERS_PROJECT_DISCOVERY_ENABLE=") ||
149+
strings.HasPrefix(s, "CODER_AGENT_DEVCONTAINERS_DISCOVERY_AUTOSTART_ENABLE=")
148150
})
149151
return shell, dir, env, nil
150152
}
@@ -287,6 +289,14 @@ func WithProjectDiscovery(projectDiscovery bool) Option {
287289
}
288290
}
289291

292+
// WithDiscoveryAutostart sets if the API should attempt to autostart
293+
// projects that have been discovered
294+
func WithDiscoveryAutostart(discoveryAutostart bool) Option {
295+
return func(api *API) {
296+
api.discoveryAutostart = discoveryAutostart
297+
}
298+
}
299+
290300
// ScriptLogger is an interface for sending devcontainer logs to the
291301
// controlplane.
292302
type ScriptLogger interface {
@@ -542,11 +552,13 @@ func (api *API) discoverDevcontainersInProject(projectPath string) error {
542552
Container: nil,
543553
}
544554

545-
config, err := api.dccli.ReadConfig(api.ctx, workspaceFolder, path, []string{})
546-
if err != nil {
547-
logger.Error(api.ctx, "read project configuration", slog.Error(err))
548-
} else if config.Configuration.Customizations.Coder.AutoStart {
549-
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusStarting
555+
if api.discoveryAutostart {
556+
config, err := api.dccli.ReadConfig(api.ctx, workspaceFolder, path, []string{})
557+
if err != nil {
558+
logger.Error(api.ctx, "read project configuration", slog.Error(err))
559+
} else if config.Configuration.Customizations.Coder.AutoStart {
560+
dc.Status = codersdk.WorkspaceAgentDevcontainerStatusStarting
561+
}
550562
}
551563

552564
api.knownDevcontainers[workspaceFolder] = dc

agent/agentcontainers/api_test.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3792,6 +3792,7 @@ func TestDevcontainerDiscovery(t *testing.T) {
37923792
agentcontainers.WithContainerCLI(&fakeContainerCLI{}),
37933793
agentcontainers.WithDevcontainerCLI(mDCCLI),
37943794
agentcontainers.WithProjectDiscovery(true),
3795+
agentcontainers.WithDiscoveryAutostart(true),
37953796
)
37963797
api.Start()
37973798
defer api.Close()
@@ -3813,6 +3814,75 @@ func TestDevcontainerDiscovery(t *testing.T) {
38133814
// Then: We expect the mock infra to not fail.
38143815
})
38153816
}
3817+
3818+
t.Run("Disabled", func(t *testing.T) {
3819+
t.Parallel()
3820+
var (
3821+
ctx = testutil.Context(t, testutil.WaitShort)
3822+
logger = testutil.Logger(t)
3823+
mClock = quartz.NewMock(t)
3824+
mDCCLI = acmock.NewMockDevcontainerCLI(gomock.NewController(t))
3825+
3826+
fs = map[string]string{
3827+
"/home/coder/.git/HEAD": "",
3828+
"/home/coder/.devcontainer/devcontainer.json": "",
3829+
}
3830+
3831+
r = chi.NewRouter()
3832+
)
3833+
3834+
// We expect that neither `ReadConfig`, nor `Up` are called as we
3835+
// have explicitly disabled the agentcontainers API from attempting
3836+
// to autostart devcontainers that it discovers.
3837+
mDCCLI.EXPECT().ReadConfig(gomock.Any(),
3838+
"/home/coder",
3839+
"/home/coder/.devcontainer/devcontainer.json",
3840+
[]string{},
3841+
).Return(agentcontainers.DevcontainerConfig{
3842+
Configuration: agentcontainers.DevcontainerConfiguration{
3843+
Customizations: agentcontainers.DevcontainerCustomizations{
3844+
Coder: agentcontainers.CoderCustomization{
3845+
AutoStart: true,
3846+
},
3847+
},
3848+
},
3849+
}, nil).Times(0)
3850+
3851+
mDCCLI.EXPECT().Up(gomock.Any(),
3852+
"/home/coder",
3853+
"/home/coder/.devcontainer/devcontainer.json",
3854+
gomock.Any(),
3855+
).Return("", nil).Times(0)
3856+
3857+
api := agentcontainers.NewAPI(logger,
3858+
agentcontainers.WithClock(mClock),
3859+
agentcontainers.WithWatcher(watcher.NewNoop()),
3860+
agentcontainers.WithFileSystem(initFS(t, fs)),
3861+
agentcontainers.WithManifestInfo("owner", "workspace", "parent-agent", "/home/coder"),
3862+
agentcontainers.WithContainerCLI(&fakeContainerCLI{}),
3863+
agentcontainers.WithDevcontainerCLI(mDCCLI),
3864+
agentcontainers.WithProjectDiscovery(true),
3865+
agentcontainers.WithDiscoveryAutostart(false),
3866+
)
3867+
api.Start()
3868+
defer api.Close()
3869+
r.Mount("/", api.Routes())
3870+
3871+
// When: All expected dev containers have been found.
3872+
require.Eventuallyf(t, func() bool {
3873+
req := httptest.NewRequest(http.MethodGet, "/", nil).WithContext(ctx)
3874+
rec := httptest.NewRecorder()
3875+
r.ServeHTTP(rec, req)
3876+
3877+
got := codersdk.WorkspaceAgentListContainersResponse{}
3878+
err := json.NewDecoder(rec.Body).Decode(&got)
3879+
require.NoError(t, err)
3880+
3881+
return len(got.Devcontainers) >= 1
3882+
}, testutil.WaitShort, testutil.IntervalFast, "dev containers never found")
3883+
3884+
// Then: We expect the mock infra to not fail.
3885+
})
38163886
})
38173887
}
38183888

cli/agent.go

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,24 @@ import (
4040

4141
func (r *RootCmd) workspaceAgent() *serpent.Command {
4242
var (
43-
auth string
44-
logDir string
45-
scriptDataDir string
46-
pprofAddress string
47-
noReap bool
48-
sshMaxTimeout time.Duration
49-
tailnetListenPort int64
50-
prometheusAddress string
51-
debugAddress string
52-
slogHumanPath string
53-
slogJSONPath string
54-
slogStackdriverPath string
55-
blockFileTransfer bool
56-
agentHeaderCommand string
57-
agentHeader []string
58-
devcontainers bool
59-
devcontainerProjectDiscovery bool
43+
auth string
44+
logDir string
45+
scriptDataDir string
46+
pprofAddress string
47+
noReap bool
48+
sshMaxTimeout time.Duration
49+
tailnetListenPort int64
50+
prometheusAddress string
51+
debugAddress string
52+
slogHumanPath string
53+
slogJSONPath string
54+
slogStackdriverPath string
55+
blockFileTransfer bool
56+
agentHeaderCommand string
57+
agentHeader []string
58+
devcontainers bool
59+
devcontainerProjectDiscovery bool
60+
devcontainerDiscoveryAutostart bool
6061
)
6162
cmd := &serpent.Command{
6263
Use: "agent",
@@ -366,6 +367,7 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
366367
DevcontainerAPIOptions: []agentcontainers.Option{
367368
agentcontainers.WithSubAgentURL(r.agentURL.String()),
368369
agentcontainers.WithProjectDiscovery(devcontainerProjectDiscovery),
370+
agentcontainers.WithDiscoveryAutostart(devcontainerDiscoveryAutostart),
369371
},
370372
})
371373

@@ -519,6 +521,13 @@ func (r *RootCmd) workspaceAgent() *serpent.Command {
519521
Description: "Allow the agent to search the filesystem for devcontainer projects.",
520522
Value: serpent.BoolOf(&devcontainerProjectDiscovery),
521523
},
524+
{
525+
Flag: "devcontainers-discovery-autostart-enable",
526+
Default: "false",
527+
Env: "CODER_AGENT_DEVCONTAINERS_DISCOVERY_AUTOSTART_ENABLE",
528+
Description: "Allow the agent to autostart devcontainer projects it discovers based on their configuration.",
529+
Value: serpent.BoolOf(&devcontainerDiscoveryAutostart),
530+
},
522531
}
523532

524533
return cmd

0 commit comments

Comments
 (0)