Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 60ef479

Browse files
committed
Merge remote-tracking branch 'origin/main' into 1433-template-constraint-for-workspace-scheduling
2 parents 244e479 + 3878e64 commit 60ef479

File tree

182 files changed

+4100
-1934
lines changed

Some content is hidden

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

182 files changed

+4100
-1934
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/config.yaml

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/doc.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/feature.md

Lines changed: 0 additions & 14 deletions
This file was deleted.

.github/codecov.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
codecov:
22
require_ci_to_pass: false
3+
notify:
4+
after_n_builds: 5
35

46
comment: false
57

@@ -19,7 +21,7 @@ coverage:
1921
ignore:
2022
# This is generated code.
2123
- coderd/database/models.go
22-
- coderd/database/query.sql.go
24+
- coderd/database/queries.sql.go
2325
- coderd/database/databasefake
2426
# These are generated or don't require tests.
2527
- cmd

.github/dependabot.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ updates:
66
interval: "weekly"
77
time: "06:00"
88
timezone: "America/Chicago"
9+
labels: []
910
commit-message:
1011
prefix: "chore"
1112
ignore:
@@ -32,9 +33,7 @@ updates:
3233
timezone: "America/Chicago"
3334
commit-message:
3435
prefix: "chore"
35-
labels:
36-
- "dependencies"
37-
- "go"
36+
labels: []
3837

3938
- package-ecosystem: "npm"
4039
directory: "/site/"
@@ -44,9 +43,7 @@ updates:
4443
timezone: "America/Chicago"
4544
commit-message:
4645
prefix: "chore"
47-
labels:
48-
- "dependencies"
49-
- "typescript/js"
46+
labels: []
5047
ignore:
5148
# Ignore major updates to Node.js types, because they need to
5249
# correspond to the Node.js engine version
@@ -62,9 +59,7 @@ updates:
6259
timezone: "America/Chicago"
6360
commit-message:
6461
prefix: "chore"
65-
labels:
66-
- "dependencies"
67-
- "terraform"
62+
labels: []
6863
ignore:
6964
# We likely want to update this ourselves.
7065
- dependency-name: "coder/coder"

.github/workflows/coder.yaml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -355,21 +355,21 @@ jobs:
355355
path: ${{ steps.go-cache-paths.outputs.go-mod }}
356356
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
357357

358-
- uses: goreleaser/goreleaser-action@v3
359-
with:
360-
install-only: true
361-
362358
- name: Cache Node
363359
id: cache-node
364360
uses: actions/cache@v3
365361
with:
366362
path: |
367363
**/node_modules
368364
.eslintcache
369-
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
365+
key: js-${{ runner.os }}-release-node-${{ hashFiles('**/yarn.lock') }}
370366
restore-keys: |
371367
js-${{ runner.os }}-
372368
369+
- uses: goreleaser/goreleaser-action@v3
370+
with:
371+
install-only: true
372+
373373
- name: Build site
374374
run: make -B site/out/index.html
375375

@@ -379,18 +379,6 @@ jobs:
379379
version: latest
380380
args: release --snapshot --rm-dist --skip-sign
381381

382-
- uses: actions/upload-artifact@v3
383-
with:
384-
name: coder_windows_amd64.zip
385-
path: ./dist/coder_*_windows_amd64.zip
386-
retention-days: 7
387-
388-
- uses: actions/upload-artifact@v3
389-
with:
390-
name: coder_linux_amd64.tar.gz
391-
path: ./dist/coder_*_linux_amd64.tar.gz
392-
retention-days: 7
393-
394382
- name: Install Release
395383
run: |
396384
gcloud config set project coder-dogfood
@@ -402,6 +390,14 @@ jobs:
402390
- name: Start
403391
run: gcloud compute ssh coder -- sudo service coder restart
404392

393+
- uses: actions/upload-artifact@v3
394+
with:
395+
name: coder
396+
path: |
397+
./dist/coder_*_linux_amd64.tar.gz
398+
./dist/coder_*_windows_amd64.zip
399+
retention-days: 7
400+
405401
test-js:
406402
name: "test/js"
407403
runs-on: ubuntu-latest

.goreleaser.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ nfpms:
9494
- src: coder.service
9595
dst: /usr/lib/systemd/system/coder.service
9696

97+
# Image templates are empty on snapshots to avoid lengthy builds for development.
9798
dockers:
98-
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-amd64"]
99+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-amd64{{ end }}"]
99100
id: coder-linux
100101
dockerfile: Dockerfile
101102
use: buildx
@@ -108,7 +109,7 @@ dockers:
108109
- --label=org.opencontainers.image.version={{ .Version }}
109110
- --label=org.opencontainers.image.revision={{ .FullCommit }}
110111
- --label=org.opencontainers.image.licenses=AGPL-3.0
111-
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-arm64"]
112+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-arm64{{ end }}"]
112113
goarch: arm64
113114
dockerfile: Dockerfile
114115
use: buildx
@@ -121,7 +122,7 @@ dockers:
121122
- --label=org.opencontainers.image.version={{ .Tag }}
122123
- --label=org.opencontainers.image.revision={{ .FullCommit }}
123124
- --label=org.opencontainers.image.licenses=AGPL-3.0
124-
- image_templates: ["ghcr.io/coder/coder:{{ .Tag }}-armv7"]
125+
- image_templates: ["{{ if not .IsSnapshot }}ghcr.io/coder/coder:{{ .Tag }}-armv7{{ end }}"]
125126
goarch: arm
126127
goarm: "7"
127128
dockerfile: Dockerfile

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"cSpell.words": [
3+
"apps",
4+
"awsidentity",
5+
"buildinfo",
36
"buildname",
47
"circbuf",
58
"cliflag",
@@ -16,6 +19,7 @@
1619
"Dsts",
1720
"fatih",
1821
"Formik",
22+
"gitsshkey",
1923
"goarch",
2024
"gographviz",
2125
"goleak",
@@ -30,6 +34,7 @@
3034
"incpatch",
3135
"isatty",
3236
"Jobf",
37+
"Keygen",
3338
"kirsle",
3439
"ldflags",
3540
"manifoldco",
@@ -54,6 +59,7 @@
5459
"retrier",
5560
"rpty",
5661
"sdkproto",
62+
"sdktrace",
5763
"Signup",
5864
"sourcemapped",
5965
"stretchr",
@@ -66,13 +72,18 @@
6672
"tfjson",
6773
"tfstate",
6874
"trimprefix",
75+
"turnconn",
6976
"typegen",
7077
"unconvert",
7178
"Untar",
7279
"VMID",
7380
"weblinks",
7481
"webrtc",
82+
"workspaceagent",
83+
"workspaceapp",
84+
"workspaceapps",
7585
"workspacebuilds",
86+
"wsconncache",
7687
"xerrors",
7788
"xstate",
7889
"yamux"

agent/agent.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,10 @@ func (a *agent) run(ctx context.Context) {
155155
}
156156
}
157157

158-
func (*agent) runStartupScript(ctx context.Context, script string) error {
158+
func (a *agent) runStartupScript(ctx context.Context, script string) error {
159159
if script == "" {
160160
return nil
161161
}
162-
currentUser, err := user.Current()
163-
if err != nil {
164-
return xerrors.Errorf("get current user: %w", err)
165-
}
166-
username := currentUser.Username
167-
168-
shell, err := usershell.Get(username)
169-
if err != nil {
170-
return xerrors.Errorf("get user shell: %w", err)
171-
}
172162

173163
writer, err := os.OpenFile(filepath.Join(os.TempDir(), "coder-startup-script.log"), os.O_CREATE|os.O_RDWR, 0600)
174164
if err != nil {
@@ -178,12 +168,10 @@ func (*agent) runStartupScript(ctx context.Context, script string) error {
178168
_ = writer.Close()
179169
}()
180170

181-
caller := "-c"
182-
if runtime.GOOS == "windows" {
183-
caller = "/c"
171+
cmd, err := a.createCommand(ctx, script, nil)
172+
if err != nil {
173+
return xerrors.Errorf("create command: %w", err)
184174
}
185-
186-
cmd := exec.CommandContext(ctx, shell, caller, script)
187175
cmd.Stdout = writer
188176
cmd.Stderr = writer
189177
err = cmd.Run()

agent/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (c *Conn) DialContext(ctx context.Context, network string, addr string) (ne
102102
var res dialResponse
103103
err = dec.Decode(&res)
104104
if err != nil {
105-
return nil, xerrors.Errorf("failed to decode initial packet: %w", err)
105+
return nil, xerrors.Errorf("decode agent dial response: %w", err)
106106
}
107107
if res.Error != "" {
108108
_ = channel.Close()

cli/agent.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cli
33
import (
44
"context"
55
"net/http"
6+
_ "net/http/pprof" //nolint: gosec
67
"net/url"
78
"os"
89
"path/filepath"
@@ -25,7 +26,9 @@ import (
2526

2627
func workspaceAgent() *cobra.Command {
2728
var (
28-
auth string
29+
auth string
30+
pprofEnabled bool
31+
pprofAddress string
2932
)
3033
cmd := &cobra.Command{
3134
Use: "agent",
@@ -49,6 +52,16 @@ func workspaceAgent() *cobra.Command {
4952
logger := slog.Make(sloghuman.Sink(cmd.ErrOrStderr()), sloghuman.Sink(logWriter)).Leveled(slog.LevelDebug)
5053
client := codersdk.New(coderURL)
5154

55+
if pprofEnabled {
56+
srvClose := serveHandler(cmd.Context(), logger, nil, pprofAddress, "pprof")
57+
defer srvClose()
58+
} else {
59+
// If pprof wasn't enabled at startup, allow a
60+
// `kill -USR1 $agent_pid` to start it (on Unix).
61+
srvClose := agentStartPPROFOnUSR1(cmd.Context(), logger, pprofAddress)
62+
defer srvClose()
63+
}
64+
5265
// exchangeToken returns a session token.
5366
// This is abstracted to allow for the same looping condition
5467
// regardless of instance identity auth type.
@@ -139,5 +152,7 @@ func workspaceAgent() *cobra.Command {
139152
}
140153

141154
cliflag.StringVarP(cmd.Flags(), &auth, "auth", "", "CODER_AGENT_AUTH", "token", "Specify the authentication type to use for the agent")
155+
cliflag.BoolVarP(cmd.Flags(), &pprofEnabled, "pprof-enable", "", "CODER_AGENT_PPROF_ENABLE", false, "Enable serving pprof metrics on the address defined by --pprof-address.")
156+
cliflag.StringVarP(cmd.Flags(), &pprofAddress, "pprof-address", "", "CODER_AGENT_PPROF_ADDRESS", "127.0.0.1:6060", "The address to serve pprof.")
142157
return cmd
143158
}

0 commit comments

Comments
 (0)