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

Skip to content

Commit d7ecab5

Browse files
committed
Merge remote-tracking branch 'origin' into rebase-restructure-new
2 parents b4bc37d + 5c977c6 commit d7ecab5

File tree

555 files changed

+27040
-6578
lines changed

Some content is hidden

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

555 files changed

+27040
-6578
lines changed

.github/workflows/ci.yaml

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -117,38 +117,40 @@ jobs:
117117
run: |
118118
echo "${{ toJSON(steps.filter )}}"
119119
120-
update-flake:
121-
needs: changes
122-
if: needs.changes.outputs.gomod == 'true'
123-
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
124-
steps:
125-
- name: Checkout
126-
uses: actions/checkout@v4
127-
with:
128-
fetch-depth: 1
129-
# See: https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#commits-made-by-this-action-do-not-trigger-new-workflow-runs
130-
token: ${{ secrets.CDRCI_GITHUB_TOKEN }}
131-
132-
- name: Setup Go
133-
uses: ./.github/actions/setup-go
134-
135-
- name: Update Nix Flake SRI Hash
136-
run: ./scripts/update-flake.sh
137-
138-
# auto update flake for dependabot
139-
- uses: stefanzweifel/git-auto-commit-action@v5
140-
if: github.actor == 'dependabot[bot]'
141-
with:
142-
# Allows dependabot to still rebase!
143-
commit_message: "[dependabot skip] Update Nix Flake SRI Hash"
144-
commit_user_name: "dependabot[bot]"
145-
commit_user_email: "49699333+dependabot[bot]@users.noreply.github.com>"
146-
commit_author: "dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>"
147-
148-
# require everyone else to update it themselves
149-
- name: Ensure No Changes
150-
if: github.actor != 'dependabot[bot]'
151-
run: git diff --exit-code
120+
# Disabled due to instability. See: https://github.com/coder/coder/issues/14553
121+
# Re-enable once the flake hash calculation is stable.
122+
# update-flake:
123+
# needs: changes
124+
# if: needs.changes.outputs.gomod == 'true'
125+
# runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
126+
# steps:
127+
# - name: Checkout
128+
# uses: actions/checkout@v4
129+
# with:
130+
# fetch-depth: 1
131+
# # See: https://github.com/stefanzweifel/git-auto-commit-action?tab=readme-ov-file#commits-made-by-this-action-do-not-trigger-new-workflow-runs
132+
# token: ${{ secrets.CDRCI_GITHUB_TOKEN }}
133+
134+
# - name: Setup Go
135+
# uses: ./.github/actions/setup-go
136+
137+
# - name: Update Nix Flake SRI Hash
138+
# run: ./scripts/update-flake.sh
139+
140+
# # auto update flake for dependabot
141+
# - uses: stefanzweifel/git-auto-commit-action@v5
142+
# if: github.actor == 'dependabot[bot]'
143+
# with:
144+
# # Allows dependabot to still rebase!
145+
# commit_message: "[dependabot skip] Update Nix Flake SRI Hash"
146+
# commit_user_name: "dependabot[bot]"
147+
# commit_user_email: "49699333+dependabot[bot]@users.noreply.github.com>"
148+
# commit_author: "dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>"
149+
150+
# # require everyone else to update it themselves
151+
# - name: Ensure No Changes
152+
# if: github.actor != 'dependabot[bot]'
153+
# run: git diff --exit-code
152154

153155
lint:
154156
needs: changes
@@ -184,7 +186,7 @@ jobs:
184186
185187
# Check for any typos
186188
- name: Check for typos
187-
uses: crate-ci/[email protected].3
189+
uses: crate-ci/[email protected].6
188190
with:
189191
config: .github/workflows/typos.toml
190192

.github/workflows/contrib.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ on:
1313
- opened
1414
- reopened
1515
- edited
16+
# For jobs that don't run on draft PRs.
17+
- ready_for_review
1618

1719
# Only run one instance per PR to ensure in-order execution.
1820
concurrency: pr-${{ github.ref }}
@@ -34,7 +36,7 @@ jobs:
3436
steps:
3537
- name: cla
3638
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
37-
uses: contributor-assistant/github-action@v2.5.1
39+
uses: contributor-assistant/github-action@v2.6.0
3840
env:
3941
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4042
# the below token should have repo scope and must be manually added by you in the repository's secret
@@ -52,7 +54,7 @@ jobs:
5254
release-labels:
5355
runs-on: ubuntu-latest
5456
# Skip tagging for draft PRs.
55-
if: ${{ github.event_name == 'pull_request_target' && success() && !github.event.pull_request.draft }}
57+
if: ${{ github.event_name == 'pull_request_target' && !github.event.pull_request.draft }}
5658
steps:
5759
- name: release-labels
5860
uses: actions/github-script@v7

.github/workflows/stale.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ jobs:
1717
with:
1818
stale-issue-label: "stale"
1919
stale-pr-label: "stale"
20-
days-before-stale: 180
20+
# days-before-stale: 180
21+
# essentially disabled for now while we work through polish issues
22+
days-before-stale: 3650
23+
2124
# Pull Requests become stale more quickly due to merge conflicts.
2225
# Also, we promote minimizing WIP.
2326
days-before-pr-stale: 7

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@
133133
"stretchr",
134134
"STTY",
135135
"stuntest",
136+
"subpage",
136137
"tailbroker",
137138
"tailcfg",
138139
"tailexchange",

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ fmt: fmt/ts fmt/go fmt/terraform fmt/shfmt fmt/prettier
395395
.PHONY: fmt
396396

397397
fmt/go:
398+
go mod tidy
398399
echo "$(GREEN)==>$(RESET) $(BOLD)fmt/go$(RESET)"
399400
# VS Code users should check out
400401
# https://github.com/mvdan/gofumpt#visual-studio-code
@@ -451,6 +452,7 @@ lint/ts:
451452

452453
lint/go:
453454
./scripts/check_enterprise_imports.sh
455+
./scripts/check_codersdk_imports.sh
454456
linter_ver=$(shell egrep -o 'GOLANGCI_LINT_VERSION=\S+' dogfood/contents/Dockerfile | cut -d '=' -f 2)
455457
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v$$linter_ver run
456458
.PHONY: lint/go

agent/agent.go

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -941,17 +941,15 @@ func (a *agent) handleManifest(manifestOK *checkpoint) func(ctx context.Context,
941941
}
942942
}
943943

944-
err = a.scriptRunner.Init(manifest.Scripts)
944+
err = a.scriptRunner.Init(manifest.Scripts, aAPI.ScriptCompleted)
945945
if err != nil {
946946
return xerrors.Errorf("init script runner: %w", err)
947947
}
948948
err = a.trackGoroutine(func() {
949949
start := time.Now()
950950
// here we use the graceful context because the script runner is not directly tied
951951
// to the agent API.
952-
err := a.scriptRunner.Execute(a.gracefulCtx, func(script codersdk.WorkspaceAgentScript) bool {
953-
return script.RunOnStart
954-
})
952+
err := a.scriptRunner.Execute(a.gracefulCtx, agentscripts.ExecuteStartScripts)
955953
// Measure the time immediately after the script has finished
956954
dur := time.Since(start).Seconds()
957955
if err != nil {
@@ -1119,9 +1117,6 @@ func (a *agent) wireguardAddresses(agentID uuid.UUID) []netip.Prefix {
11191117
return []netip.Prefix{
11201118
// This is the IP that should be used primarily.
11211119
netip.PrefixFrom(tailnet.IPFromUUID(agentID), 128),
1122-
// We also listen on the legacy codersdk.WorkspaceAgentIP. This
1123-
// allows for a transition away from wsconncache.
1124-
netip.PrefixFrom(workspacesdk.AgentIP, 128),
11251120
}
11261121
}
11271122

@@ -1360,7 +1355,7 @@ func (a *agent) runCoordinator(ctx context.Context, conn drpc.Conn, network *tai
13601355
defer close(errCh)
13611356
select {
13621357
case <-ctx.Done():
1363-
err := coordination.Close()
1358+
err := coordination.Close(a.hardCtx)
13641359
if err != nil {
13651360
a.logger.Warn(ctx, "failed to close remote coordination", slog.Error(err))
13661361
}
@@ -1510,6 +1505,8 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
15101505
var mu sync.Mutex
15111506
status := a.network.Status()
15121507
durations := []float64{}
1508+
p2pConns := 0
1509+
derpConns := 0
15131510
pingCtx, cancelFunc := context.WithTimeout(ctx, 5*time.Second)
15141511
defer cancelFunc()
15151512
for nodeID, peer := range status.Peer {
@@ -1526,13 +1523,18 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
15261523
wg.Add(1)
15271524
go func() {
15281525
defer wg.Done()
1529-
duration, _, _, err := a.network.Ping(pingCtx, addresses[0].Addr())
1526+
duration, p2p, _, err := a.network.Ping(pingCtx, addresses[0].Addr())
15301527
if err != nil {
15311528
return
15321529
}
15331530
mu.Lock()
15341531
defer mu.Unlock()
15351532
durations = append(durations, float64(duration.Microseconds()))
1533+
if p2p {
1534+
p2pConns++
1535+
} else {
1536+
derpConns++
1537+
}
15361538
}()
15371539
}
15381540
wg.Wait()
@@ -1552,6 +1554,9 @@ func (a *agent) Collect(ctx context.Context, networkStats map[netlogtype.Connect
15521554
// Agent metrics are changing all the time, so there is no need to perform
15531555
// reflect.DeepEqual to see if stats should be transferred.
15541556

1557+
// currentConnections behaves like a hypothetical `GaugeFuncVec` and is only set at collection time.
1558+
a.metrics.currentConnections.WithLabelValues("p2p").Set(float64(p2pConns))
1559+
a.metrics.currentConnections.WithLabelValues("derp").Set(float64(derpConns))
15551560
metricsCtx, cancelFunc := context.WithTimeout(ctx, 5*time.Second)
15561561
defer cancelFunc()
15571562
a.logger.Debug(ctx, "collecting agent metrics for stats")
@@ -1669,13 +1674,12 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
16691674
}
16701675

16711676
score, niceErr := proc.Niceness(a.syscaller)
1672-
if niceErr != nil && !xerrors.Is(niceErr, os.ErrPermission) {
1677+
if !isBenignProcessErr(niceErr) {
16731678
debouncer.Warn(ctx, "unable to get proc niceness",
16741679
slog.F("cmd", proc.Cmd()),
16751680
slog.F("pid", proc.PID),
16761681
slog.Error(niceErr),
16771682
)
1678-
continue
16791683
}
16801684

16811685
// We only want processes that don't have a nice value set
@@ -1689,7 +1693,7 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
16891693

16901694
if niceErr == nil {
16911695
err := proc.SetNiceness(a.syscaller, niceness)
1692-
if err != nil && !xerrors.Is(err, os.ErrPermission) {
1696+
if !isBenignProcessErr(err) {
16931697
debouncer.Warn(ctx, "unable to set proc niceness",
16941698
slog.F("cmd", proc.Cmd()),
16951699
slog.F("pid", proc.PID),
@@ -1703,7 +1707,7 @@ func (a *agent) manageProcessPriority(ctx context.Context, debouncer *logDebounc
17031707
if oomScore != unsetOOMScore && oomScore != proc.OOMScoreAdj && !isCustomOOMScore(agentScore, proc) {
17041708
oomScoreStr := strconv.Itoa(oomScore)
17051709
err := afero.WriteFile(a.filesystem, fmt.Sprintf("/proc/%d/oom_score_adj", proc.PID), []byte(oomScoreStr), 0o644)
1706-
if err != nil && !xerrors.Is(err, os.ErrPermission) {
1710+
if !isBenignProcessErr(err) {
17071711
debouncer.Warn(ctx, "unable to set oom_score_adj",
17081712
slog.F("cmd", proc.Cmd()),
17091713
slog.F("pid", proc.PID),
@@ -1838,9 +1842,7 @@ func (a *agent) Close() error {
18381842
a.gracefulCancel()
18391843

18401844
lifecycleState := codersdk.WorkspaceAgentLifecycleOff
1841-
err = a.scriptRunner.Execute(a.hardCtx, func(script codersdk.WorkspaceAgentScript) bool {
1842-
return script.RunOnStop
1843-
})
1845+
err = a.scriptRunner.Execute(a.hardCtx, agentscripts.ExecuteStopScripts)
18441846
if err != nil {
18451847
a.logger.Warn(a.hardCtx, "shutdown script(s) failed", slog.Error(err))
18461848
if errors.Is(err, agentscripts.ErrTimeout) {
@@ -2139,3 +2141,14 @@ func (l *logDebouncer) log(ctx context.Context, level slog.Level, msg string, fi
21392141
}
21402142
l.messages[msg] = time.Now()
21412143
}
2144+
2145+
func isBenignProcessErr(err error) bool {
2146+
return err != nil &&
2147+
(xerrors.Is(err, os.ErrNotExist) ||
2148+
xerrors.Is(err, os.ErrPermission) ||
2149+
isNoSuchProcessErr(err))
2150+
}
2151+
2152+
func isNoSuchProcessErr(err error) bool {
2153+
return err != nil && strings.Contains(err.Error(), "no such process")
2154+
}

0 commit comments

Comments
 (0)