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

Commite2973ba

Browse files
committed
fixup! feat: add endpoint to get listening ports in agent
1 parentea2027e commite2973ba

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

‎agent/ports_supported.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package agent
55

66
import (
7-
"runtime"
87
"time"
98

109
"github.com/cakturk/go-netstat/netstat"
@@ -17,13 +16,6 @@ func (lp *listeningPortsHandler) getListeningPorts() ([]codersdk.ListeningPort,
1716
lp.mut.Lock()
1817
deferlp.mut.Unlock()
1918

20-
ifruntime.GOOS!="linux"&&runtime.GOOS!="windows" {
21-
// Can't scan for ports on non-linux or non-windows systems at the
22-
// moment. The UI will not show any "no ports found" message to the
23-
// user, so the user won't suspect a thing.
24-
return []codersdk.ListeningPort{},nil
25-
}
26-
2719
iftime.Since(lp.mtime)<time.Second {
2820
// copy
2921
ports:=make([]codersdk.ListeningPort,len(lp.ports))

‎coderd/workspaceagents.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,21 @@ func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Req
227227
return
228228
}
229229

230+
apiAgent,err:=convertWorkspaceAgent(api.DERPMap,api.TailnetCoordinator,workspaceAgent,nil,api.AgentInactiveDisconnectTimeout)
231+
iferr!=nil {
232+
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
233+
Message:"Internal error reading workspace agent.",
234+
Detail:err.Error(),
235+
})
236+
return
237+
}
238+
ifapiAgent.Status!=codersdk.WorkspaceAgentConnected {
239+
httpapi.Write(ctx,rw,http.StatusPreconditionRequired, codersdk.Response{
240+
Message:fmt.Sprintf("Agent state is %q, it must be in the %q state.",apiAgent.Status,codersdk.WorkspaceAgentConnected),
241+
})
242+
return
243+
}
244+
230245
agentConn,release,err:=api.workspaceAgentCache.Acquire(r,workspaceAgent.ID)
231246
iferr!=nil {
232247
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp