Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: ensure wsproxyMultiAgent is closed when websocket dies#11414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

coadler
Copy link
Contributor

@coadlercoadler commentedJan 4, 2024
edited
Loading

TheSingleTailnet behavior only checked to see if theMultiAgent was
closed, but the websocket error was not being propogated into the
MultiAgent, causing it to never be swapped for a new working one.

Fixes#11401

Before:

Coder Workspace Proxy v0.0.0-devel+85ff030 - Your Self-Hosted Remote Development PlatformStarted HTTP listener at http://0.0.0.0:3001View the Web UI: http://127.0.0.1:3001==> Logs will stream in below (press ctrl+c to gracefully exit):2024-01-04 20:11:56.376 [warn]  net.workspace-proxy.servertailnet: broadcast server node to agents ...    error= write message:               github.com/coder/coder/v2/enterprise/wsproxy/wsproxysdk.(*remoteMultiAgentHandler).writeJSON                   /home/coder/coder/enterprise/wsproxy/wsproxysdk/wsproxysdk.go:524             - failed to write msg: WebSocket closed: failed to read frame header: EOF

After:

Coder Workspace Proxy v0.0.0-devel+12f1878 - Your Self-Hosted Remote Development PlatformStarted HTTP listener at http://0.0.0.0:3001View the Web UI: http://127.0.0.1:3001==> Logs will stream in below (press ctrl+c to gracefully exit):2024-01-04 20:26:38.545 [warn]  net.workspace-proxy.servertailnet: multiagent closed, reinitializing2024-01-04 20:26:38.546 [erro]  net.workspace-proxy.servertailnet: reinit multi agent ...    error= dial coordinate websocket:               github.com/coder/coder/v2/enterprise/wsproxy/wsproxysdk.(*Client).DialCoordinator                   /home/coder/coder/enterprise/wsproxy/wsproxysdk/wsproxysdk.go:454             - failed to WebSocket dial: failed to send handshake request: Get "http://127.0.0.1:3000/api/v2/workspaceproxies/me/coordinate": dial tcp 127.0.0.1:3000: connect: connection refused2024-01-04 20:26:38.587 [erro]  net.workspace-proxy.servertailnet: reinit multi agent ...    error= dial coordinate websocket:               github.com/coder/coder/v2/enterprise/wsproxy/wsproxysdk.(*Client).DialCoordinator                   /home/coder/coder/enterprise/wsproxy/wsproxysdk/wsproxysdk.go:454             - failed to WebSocket dial: failed to send handshake request: Get "http://127.0.0.1:3000/api/v2/workspaceproxies/me/coordinate": dial tcp 127.0.0.1:3000: connect: connection refusedhandshake request: Get "http://127.0.0.1:3000/api/v2/workspaceproxies/me/coordinate": dial tcp 127.0.0.1:3000: connect: connection refused2024-01-04 20:26:40.446 [info]  net.workspace-proxy.servertailnet: successfully reinitialized multiagent  agents=0  took=1.900892615s

@coadler
Copy link
ContributorAuthor

coadler commentedJan 4, 2024
edited
Loading

In this stack:🚀 Improve WebSocket reliability and resource management

This stack of pull requests is managed by Graphite.Learn more about stacking.

Join@coadler and the rest of your teammates onGraphiteGraphite

@coadlercoadlerforce-pushed thecolin/fixensurewsproxyMultiAgentisclosedwhenwebsocketdies branch from50c92b4 to12f1878CompareJanuary 4, 2024 20:24
Copy link
Contributor

@spikecurtisspikecurtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good work tracking down the bug!

I don't see any new tests though that will catch and prevent a regression, so please add


gofunc() {
defercancel()
dec:=json.NewDecoder(nc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[Re: lines 488 to 488]

I think it's worth dropping an INFO log here.

See this comment inline onGraphite.

}).Init()

gofunc() {
<-ctx.Done()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If I'm understanding this correctly, we're depending on the fact that the reader goroutine below cancels the context on a failed read.

I think we shouldalso tear down the multi-agent on a failed write of subscription messages. It's unlikely that we'd have a failure that leaves the connection half-open (e.g. for reads but not writes), but such things are possible and you don't want the proxy limping on unable to subscribe to new agents.

ticker:=time.NewTicker(15*time.Second)
deferticker.Stop()

for {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

[Re: lines 43 to 43]

Drop an INFO log here

See this comment inline onGraphite.

The `SingleTailnet` behavior only checked to see if the `MultiAgent` wasclosed, but the websocket error was not being propogated into the`MultiAgent`, causing it to never be swapped for a new working one.
@coadlercoadlerforce-pushed thecolin/fixensurewsproxyMultiAgentisclosedwhenwebsocketdies branch from12f1878 to72ad811CompareJanuary 11, 2024 16:35
@coadlercoadler merged commit4a08082 intomainJan 11, 2024
@coadlercoadler deleted the colin/fixensurewsproxyMultiAgentisclosedwhenwebsocketdies branchJanuary 11, 2024 17:37
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJan 11, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@spikecurtisspikecurtisspikecurtis approved these changes

Assignees

@coadlercoadler

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

workspace proxy fails to proxy; error "ensure agent: subscribe agent"

2 participants

@coadler@spikecurtis

[8]ページ先頭

©2009-2025 Movatter.jp