@@ -52,7 +52,7 @@ func (api *API) workspaceAgent(rw http.ResponseWriter, r *http.Request) {
52
52
})
53
53
return
54
54
}
55
- apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , convertApps (dbApps ), api .AgentInactiveDisconnectTimeout )
55
+ apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , convertApps (dbApps ), api .AgentInactiveDisconnectTimeout , api . DeploymentConfig . AgentFallbackTroubleshootingURL . Value )
56
56
if err != nil {
57
57
httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
58
58
Message : "Internal error reading workspace agent." ,
@@ -67,7 +67,7 @@ func (api *API) workspaceAgent(rw http.ResponseWriter, r *http.Request) {
67
67
func (api * API ) workspaceAgentMetadata (rw http.ResponseWriter , r * http.Request ) {
68
68
ctx := r .Context ()
69
69
workspaceAgent := httpmw .WorkspaceAgent (r )
70
- apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , nil , api .AgentInactiveDisconnectTimeout )
70
+ apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , nil , api .AgentInactiveDisconnectTimeout , api . DeploymentConfig . AgentFallbackTroubleshootingURL . Value )
71
71
if err != nil {
72
72
httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
73
73
Message : "Internal error reading workspace agent." ,
@@ -138,7 +138,7 @@ func (api *API) workspaceAgentMetadata(rw http.ResponseWriter, r *http.Request)
138
138
func (api * API ) postWorkspaceAgentVersion (rw http.ResponseWriter , r * http.Request ) {
139
139
ctx := r .Context ()
140
140
workspaceAgent := httpmw .WorkspaceAgent (r )
141
- apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , nil , api .AgentInactiveDisconnectTimeout )
141
+ apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , nil , api .AgentInactiveDisconnectTimeout , api . DeploymentConfig . AgentFallbackTroubleshootingURL . Value )
142
142
if err != nil {
143
143
httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
144
144
Message : "Internal error reading workspace agent." ,
@@ -192,7 +192,7 @@ func (api *API) workspaceAgentPTY(rw http.ResponseWriter, r *http.Request) {
192
192
httpapi .ResourceNotFound (rw )
193
193
return
194
194
}
195
- apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , nil , api .AgentInactiveDisconnectTimeout )
195
+ apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , nil , api .AgentInactiveDisconnectTimeout , api . DeploymentConfig . AgentFallbackTroubleshootingURL . Value )
196
196
if err != nil {
197
197
httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
198
198
Message : "Internal error reading workspace agent." ,
@@ -269,7 +269,7 @@ func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Req
269
269
return
270
270
}
271
271
272
- apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , nil , api .AgentInactiveDisconnectTimeout )
272
+ apiAgent , err := convertWorkspaceAgent (api .DERPMap , * api .TailnetCoordinator .Load (), workspaceAgent , nil , api .AgentInactiveDisconnectTimeout , api . DeploymentConfig . AgentFallbackTroubleshootingURL . Value )
273
273
if err != nil {
274
274
httpapi .Write (ctx , rw , http .StatusInternalServerError , codersdk.Response {
275
275
Message : "Internal error reading workspace agent." ,
@@ -660,14 +660,18 @@ func convertApps(dbApps []database.WorkspaceApp) []codersdk.WorkspaceApp {
660
660
return apps
661
661
}
662
662
663
- func convertWorkspaceAgent (derpMap * tailcfg.DERPMap , coordinator tailnet.Coordinator , dbAgent database.WorkspaceAgent , apps []codersdk.WorkspaceApp , agentInactiveDisconnectTimeout time.Duration ) (codersdk.WorkspaceAgent , error ) {
663
+ func convertWorkspaceAgent (derpMap * tailcfg.DERPMap , coordinator tailnet.Coordinator , dbAgent database.WorkspaceAgent , apps []codersdk.WorkspaceApp , agentInactiveDisconnectTimeout time.Duration , agentFallbackTroubleshootingURL string ) (codersdk.WorkspaceAgent , error ) {
664
664
var envs map [string ]string
665
665
if dbAgent .EnvironmentVariables .Valid {
666
666
err := json .Unmarshal (dbAgent .EnvironmentVariables .RawMessage , & envs )
667
667
if err != nil {
668
668
return codersdk.WorkspaceAgent {}, xerrors .Errorf ("unmarshal env vars: %w" , err )
669
669
}
670
670
}
671
+ troubleshootingURL := agentFallbackTroubleshootingURL
672
+ if dbAgent .TroubleshootingURL != "" {
673
+ troubleshootingURL = dbAgent .TroubleshootingURL
674
+ }
671
675
workspaceAgent := codersdk.WorkspaceAgent {
672
676
ID : dbAgent .ID ,
673
677
CreatedAt : dbAgent .CreatedAt ,
@@ -683,7 +687,7 @@ func convertWorkspaceAgent(derpMap *tailcfg.DERPMap, coordinator tailnet.Coordin
683
687
Directory : dbAgent .Directory ,
684
688
Apps : apps ,
685
689
ConnectionTimeoutSeconds : dbAgent .ConnectionTimeoutSeconds ,
686
- TroubleshootingURL : dbAgent . TroubleshootingURL ,
690
+ TroubleshootingURL : troubleshootingURL ,
687
691
}
688
692
node := coordinator .Node (dbAgent .ID )
689
693
if node != nil {
0 commit comments