Skip to content

Commit 13a6a1b

Browse files
committed
Merge remote-tracking branch 'origin/main' into phorcys/docs-variables-input-options
2 parents 102e688 + bcb15aa commit 13a6a1b

File tree

245 files changed

+9510
-4178
lines changed

Some content is hidden

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

245 files changed

+9510
-4178
lines changed

.github/.linkspector.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ ignorePatterns:
1818
- pattern: "i.imgur.com"
1919
- pattern: "code.visualstudio.com"
2020
- pattern: "www.emacswiki.org"
21+
- pattern: "linux.die.net/man"
2122
aliveStatusCodes:
2223
- 200

.github/workflows/ci.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188
189189
# Check for any typos
190190
- name: Check for typos
191-
uses: crate-ci/typos@2872c382bb9668d4baa5eade234dcbc0048ca2cf # v1.28.2
191+
uses: crate-ci/typos@d1c850b2b5d502763520c25fb4a6a1128ad99bd9 # v1.28.3
192192
with:
193193
config: .github/workflows/typos.toml
194194

@@ -895,7 +895,7 @@ jobs:
895895
needs: changes
896896
# We always build the dylibs on Go changes to verify we're not merging unbuildable code,
897897
# but they need only be signed and uploaded on coder/coder main.
898-
if: needs.changes.outputs.docs-only == 'false' || github.ref == 'refs/heads/main'
898+
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
899899
runs-on: ${{ github.repository_owner == 'coder' && 'depot-macos-latest' || 'macos-latest' }}
900900
steps:
901901
- name: Harden Runner
@@ -976,7 +976,7 @@ jobs:
976976
- changes
977977
- build-dylib
978978
if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false' && !github.event.pull_request.head.repo.fork
979-
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
979+
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-22.04' }}
980980
permissions:
981981
packages: write # Needed to push images to ghcr.io
982982
env:

.github/workflows/contrib.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141

4242
cla:
4343
runs-on: ubuntu-latest
44+
permissions:
45+
pull-requests: write
4446
steps:
4547
- name: Harden Runner
4648
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2

.github/workflows/dogfood.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
uses: depot/setup-action@b0b1ea4f69e92ebf5dea3f8713a1b0c37b2126a5 # v1.6.0
5151

5252
- name: Set up Docker Buildx
53-
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
53+
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
5454

5555
- name: Login to DockerHub
5656
if: github.ref == 'refs/heads/main'

.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@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
50+
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
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@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
41+
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
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@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
51+
uses: github/codeql-action/analyze@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
5252

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

146146
- name: Upload Trivy scan results to GitHub Security tab
147-
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
147+
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3.27.9
148148
with:
149149
sarif_file: trivy-results.sarif
150150
category: "Trivy"

.github/workflows/weekly-docs.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ permissions:
1515

1616
jobs:
1717
check-docs:
18-
runs-on: ubuntu-latest
18+
# later versions of Ubuntu have disabled unprivileged user namespaces, which are required by the action
19+
runs-on: ubuntu-22.04
1920
permissions:
2021
pull-requests: write # required to post PR review comments by the action
2122
steps:

.vscode/markdown.code-snippets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
"body": "![${TM_SELECTED_TEXT:${1:alt}}](${2:url})$0",
2121
"description": "image"
2222
},
23+
"premium-feature": {
24+
"prefix": "#premium-feature",
25+
"body": [
26+
"<blockquote class=\"info\">\n",
27+
"${1:feature} ${2|is,are|} an Enterprise and Premium feature. [Learn more](https://coder.com/pricing#compare-plans).\n",
28+
"</blockquote>"
29+
]
30+
},
2331
"tabs": {
2432
"prefix": "#tabs",
2533
"body": [

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,8 +640,8 @@ vpn/vpn.pb.go: vpn/vpn.proto
640640
./vpn/vpn.proto
641641

642642
site/src/api/typesGenerated.ts: $(wildcard scripts/apitypings/*) $(shell find ./codersdk $(FIND_EXCLUSIONS) -type f -name '*.go')
643-
go run ./scripts/apitypings/ > $@
644-
./scripts/pnpm_install.sh
643+
# -C sets the directory for the go run command
644+
go run -C ./scripts/apitypings main.go > $@
645645

646646
site/e2e/provisionerGenerated.ts: provisionerd/proto/provisionerd.pb.go provisionersdk/proto/provisioner.pb.go
647647
cd site

cli/testdata/coder_list_--output_json.golden

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@
5050
"deadline": "[timestamp]",
5151
"max_deadline": null,
5252
"status": "running",
53-
"daily_cost": 0
53+
"daily_cost": 0,
54+
"matched_provisioners": {
55+
"count": 0,
56+
"available": 0,
57+
"most_recently_seen": null
58+
}
5459
},
5560
"outdated": false,
5661
"name": "test-workspace",

cmd/coder/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"os"
66
_ "time/tzdata"
77

8+
tea "github.com/charmbracelet/bubbletea"
9+
810
"github.com/coder/coder/v2/agent/agentexec"
911
"github.com/coder/coder/v2/cli"
1012
)
@@ -15,6 +17,9 @@ func main() {
1517
_, _ = fmt.Fprintln(os.Stderr, err)
1618
os.Exit(1)
1719
}
20+
// This preserves backwards compatibility with an init function that is causing grief for
21+
// web terminals using agent-exec + screen. See https://github.com/coder/coder/pull/15817
22+
tea.InitTerminal()
1823
var rootCmd cli.RootCmd
1924
rootCmd.RunWithSubcommands(rootCmd.AGPL())
2025
}

coderd/apidoc/docs.go

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

coderd/apidoc/swagger.json

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

coderd/autobuild/lifecycle_executor.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package autobuild
33
import (
44
"context"
55
"database/sql"
6+
"fmt"
67
"net/http"
78
"sync"
89
"sync/atomic"
@@ -177,6 +178,15 @@ func (e *Executor) runOnce(t time.Time) Stats {
177178
err := e.db.InTx(func(tx database.Store) error {
178179
var err error
179180

181+
ok, err := tx.TryAcquireLock(e.ctx, database.GenLockID(fmt.Sprintf("lifecycle-executor:%s", wsID)))
182+
if err != nil {
183+
return xerrors.Errorf("try acquire lifecycle executor lock: %w", err)
184+
}
185+
if !ok {
186+
log.Debug(e.ctx, "unable to acquire lock for workspace, skipping")
187+
return nil
188+
}
189+
180190
// Re-check eligibility since the first check was outside the
181191
// transaction and the workspace settings may have changed.
182192
ws, err = tx.GetWorkspaceByID(e.ctx, wsID)
@@ -389,7 +399,7 @@ func (e *Executor) runOnce(t time.Time) Stats {
389399
}
390400
return nil
391401
}()
392-
if err != nil {
402+
if err != nil && !xerrors.Is(err, context.Canceled) {
393403
log.Error(e.ctx, "failed to transition workspace", slog.Error(err))
394404
statsMu.Lock()
395405
stats.Errors[wsID] = err

coderd/autobuild/lifecycle_executor_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/coder/coder/v2/coderd/coderdtest"
1919
"github.com/coder/coder/v2/coderd/database"
2020
"github.com/coder/coder/v2/coderd/database/dbauthz"
21+
"github.com/coder/coder/v2/coderd/database/dbtestutil"
2122
"github.com/coder/coder/v2/coderd/notifications"
2223
"github.com/coder/coder/v2/coderd/notifications/notificationstest"
2324
"github.com/coder/coder/v2/coderd/schedule"
@@ -72,6 +73,76 @@ func TestExecutorAutostartOK(t *testing.T) {
7273
require.Equal(t, template.AutostartRequirement.DaysOfWeek, []string{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"})
7374
}
7475

76+
func TestMultipleLifecycleExecutors(t *testing.T) {
77+
t.Parallel()
78+
79+
db, ps := dbtestutil.NewDB(t)
80+
81+
var (
82+
sched = mustSchedule(t, "CRON_TZ=UTC 0 * * * *")
83+
// Create our first client
84+
tickCh = make(chan time.Time, 2)
85+
statsChA = make(chan autobuild.Stats)
86+
clientA = coderdtest.New(t, &coderdtest.Options{
87+
IncludeProvisionerDaemon: true,
88+
AutobuildTicker: tickCh,
89+
AutobuildStats: statsChA,
90+
Database: db,
91+
Pubsub: ps,
92+
})
93+
// ... And then our second client
94+
statsChB = make(chan autobuild.Stats)
95+
_ = coderdtest.New(t, &coderdtest.Options{
96+
IncludeProvisionerDaemon: true,
97+
AutobuildTicker: tickCh,
98+
AutobuildStats: statsChB,
99+
Database: db,
100+
Pubsub: ps,
101+
})
102+
// Now create a workspace (we can use either client, it doesn't matter)
103+
workspace = mustProvisionWorkspace(t, clientA, func(cwr *codersdk.CreateWorkspaceRequest) {
104+
cwr.AutostartSchedule = ptr.Ref(sched.String())
105+
})
106+
)
107+
108+
// Have the workspace stopped so we can perform an autostart
109+
workspace = coderdtest.MustTransitionWorkspace(t, clientA, workspace.ID, database.WorkspaceTransitionStart, database.WorkspaceTransitionStop)
110+
111+
// Get both clients to perform a lifecycle execution tick
112+
next := sched.Next(workspace.LatestBuild.CreatedAt)
113+
114+
startCh := make(chan struct{})
115+
go func() {
116+
<-startCh
117+
tickCh <- next
118+
}()
119+
go func() {
120+
<-startCh
121+
tickCh <- next
122+
}()
123+
close(startCh)
124+
125+
// Now we want to check the stats for both clients
126+
statsA := <-statsChA
127+
statsB := <-statsChB
128+
129+
// We expect there to be no errors
130+
assert.Len(t, statsA.Errors, 0)
131+
assert.Len(t, statsB.Errors, 0)
132+
133+
// We also expect there to have been only one transition
134+
require.Equal(t, 1, len(statsA.Transitions)+len(statsB.Transitions))
135+
136+
stats := statsA
137+
if len(statsB.Transitions) == 1 {
138+
stats = statsB
139+
}
140+
141+
// And we expect this transition to have been a start transition
142+
assert.Contains(t, stats.Transitions, workspace.ID)
143+
assert.Equal(t, database.WorkspaceTransitionStart, stats.Transitions[workspace.ID])
144+
}
145+
75146
func TestExecutorAutostartTemplateUpdated(t *testing.T) {
76147
t.Parallel()
77148

coderd/database/dbauthz/dbauthz.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,10 @@ func (q *querier) GetDeploymentWorkspaceStats(ctx context.Context) (database.Get
15681568
return q.db.GetDeploymentWorkspaceStats(ctx)
15691569
}
15701570

1571+
func (q *querier) GetEligibleProvisionerDaemonsByProvisionerJobIDs(ctx context.Context, provisionerJobIds []uuid.UUID) ([]database.GetEligibleProvisionerDaemonsByProvisionerJobIDsRow, error) {
1572+
return fetchWithPostFilter(q.auth, policy.ActionRead, q.db.GetEligibleProvisionerDaemonsByProvisionerJobIDs)(ctx, provisionerJobIds)
1573+
}
1574+
15711575
func (q *querier) GetExternalAuthLink(ctx context.Context, arg database.GetExternalAuthLinkParams) (database.ExternalAuthLink, error) {
15721576
return fetchWithAction(q.log, q.auth, policy.ActionReadPersonal, q.db.GetExternalAuthLink)(ctx, arg)
15731577
}

0 commit comments

Comments
 (0)