Skip to content

Commit 2fb3053

Browse files
committed
Merge branch 'main' into dean/user-maintenance-window
2 parents 4c70ade + b650ab4 commit 2fb3053

File tree

130 files changed

+4440
-1763
lines changed

Some content is hidden

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

130 files changed

+4440
-1763
lines changed

.github/dependabot.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ updates:
4444
update-types:
4545
- version-update:semver-patch
4646
groups:
47-
go-otel:
47+
otel:
4848
patterns:
4949
- "go.nhat.io/otelsql"
5050
- "go.opentelemetry.io/otel*"
@@ -67,7 +67,7 @@ updates:
6767
# our Go code.
6868
- dependency-name: "terraform"
6969
groups:
70-
docker:
70+
scripts-docker:
7171
patterns:
7272
- "*"
7373

@@ -93,31 +93,31 @@ updates:
9393
update-types:
9494
- version-update:semver-major
9595
groups:
96-
npm-react:
96+
react:
9797
patterns:
9898
- "react*"
9999
- "@types/react*"
100-
npm-xterm:
100+
xterm:
101101
patterns:
102102
- "xterm*"
103-
npm-xstate:
103+
xstate:
104104
patterns:
105105
- "xstate"
106106
- "@xstate*"
107-
npm-mui:
107+
mui:
108108
patterns:
109109
- "@mui*"
110-
npm-storybook:
110+
storybook:
111111
patterns:
112112
- "@storybook*"
113113
- "storybook*"
114-
npm-eslint:
114+
eslint:
115115
patterns:
116116
- "eslint*"
117117
- "@eslint*"
118118
- "@typescript-eslint/eslint-plugin"
119119
- "@typescript-eslint/parser"
120-
npm-jest:
120+
jest:
121121
patterns:
122122
- "jest*"
123123
- "@swc/jest"

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ jobs:
198198
with:
199199
# This doesn't need caching. It's super fast anyways!
200200
cache: false
201-
go-version: 1.20.5
201+
go-version: 1.20.6
202202

203203
- name: Install prettier
204204
# We only need prettier for fmt, so do not install all dependencies.

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ env:
3131
# For some reason, setup-go won't actually pick up a new patch version if
3232
# it has an old one cached. We need to manually specify the versions so we
3333
# can get the latest release. Never use "~1.xx" here!
34-
CODER_GO_VERSION: "1.20.5"
34+
CODER_GO_VERSION: "1.20.6"
3535

3636
jobs:
3737
release:

.github/workflows/security.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ concurrency:
2222
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2323

2424
env:
25-
CODER_GO_VERSION: "1.20.5"
25+
CODER_GO_VERSION: "1.20.6"
2626

2727
jobs:
2828
codeql:

agent/agent.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type Options struct {
6464
SSHMaxTimeout time.Duration
6565
TailnetListenPort uint16
6666
Subsystem codersdk.AgentSubsystem
67+
Addresses []netip.Prefix
6768

6869
PrometheusRegistry *prometheus.Registry
6970
}
@@ -132,6 +133,7 @@ func New(options Options) Agent {
132133
connStatsChan: make(chan *agentsdk.Stats, 1),
133134
sshMaxTimeout: options.SSHMaxTimeout,
134135
subsystem: options.Subsystem,
136+
addresses: options.Addresses,
135137

136138
prometheusRegistry: prometheusRegistry,
137139
metrics: newAgentMetrics(prometheusRegistry),
@@ -177,6 +179,7 @@ type agent struct {
177179
lifecycleStates []agentsdk.PostLifecycleRequest
178180

179181
network *tailnet.Conn
182+
addresses []netip.Prefix
180183
connStatsChan chan *agentsdk.Stats
181184
latestStat atomic.Pointer[agentsdk.Stats]
182185

@@ -545,6 +548,10 @@ func (a *agent) run(ctx context.Context) error {
545548
}
546549
a.logger.Info(ctx, "fetched manifest", slog.F("manifest", manifest))
547550

551+
if manifest.AgentID == uuid.Nil {
552+
return xerrors.New("nil agentID returned by manifest")
553+
}
554+
548555
// Expand the directory and send it back to coderd so external
549556
// applications that rely on the directory can use it.
550557
//
@@ -630,7 +637,7 @@ func (a *agent) run(ctx context.Context) error {
630637
network := a.network
631638
a.closeMutex.Unlock()
632639
if network == nil {
633-
network, err = a.createTailnet(ctx, manifest.DERPMap, manifest.DisableDirectConnections)
640+
network, err = a.createTailnet(ctx, manifest.AgentID, manifest.DERPMap, manifest.DisableDirectConnections)
634641
if err != nil {
635642
return xerrors.Errorf("create tailnet: %w", err)
636643
}
@@ -648,6 +655,11 @@ func (a *agent) run(ctx context.Context) error {
648655

649656
a.startReportingConnectionStats(ctx)
650657
} else {
658+
// Update the wireguard IPs if the agent ID changed.
659+
err := network.SetAddresses(a.wireguardAddresses(manifest.AgentID))
660+
if err != nil {
661+
a.logger.Error(ctx, "update tailnet addresses", slog.Error(err))
662+
}
651663
// Update the DERP map and allow/disallow direct connections.
652664
network.SetDERPMap(manifest.DERPMap)
653665
network.SetBlockEndpoints(manifest.DisableDirectConnections)
@@ -661,6 +673,20 @@ func (a *agent) run(ctx context.Context) error {
661673
return nil
662674
}
663675

676+
func (a *agent) wireguardAddresses(agentID uuid.UUID) []netip.Prefix {
677+
if len(a.addresses) == 0 {
678+
return []netip.Prefix{
679+
// This is the IP that should be used primarily.
680+
netip.PrefixFrom(tailnet.IPFromUUID(agentID), 128),
681+
// We also listen on the legacy codersdk.WorkspaceAgentIP. This
682+
// allows for a transition away from wsconncache.
683+
netip.PrefixFrom(codersdk.WorkspaceAgentIP, 128),
684+
}
685+
}
686+
687+
return a.addresses
688+
}
689+
664690
func (a *agent) trackConnGoroutine(fn func()) error {
665691
a.closeMutex.Lock()
666692
defer a.closeMutex.Unlock()
@@ -675,9 +701,9 @@ func (a *agent) trackConnGoroutine(fn func()) error {
675701
return nil
676702
}
677703

678-
func (a *agent) createTailnet(ctx context.Context, derpMap *tailcfg.DERPMap, disableDirectConnections bool) (_ *tailnet.Conn, err error) {
704+
func (a *agent) createTailnet(ctx context.Context, agentID uuid.UUID, derpMap *tailcfg.DERPMap, disableDirectConnections bool) (_ *tailnet.Conn, err error) {
679705
network, err := tailnet.NewConn(&tailnet.Options{
680-
Addresses: []netip.Prefix{netip.PrefixFrom(codersdk.WorkspaceAgentIP, 128)},
706+
Addresses: a.wireguardAddresses(agentID),
681707
DERPMap: derpMap,
682708
Logger: a.logger.Named("tailnet"),
683709
ListenPort: a.tailnetListenPort,

0 commit comments

Comments
 (0)