@@ -138,7 +138,7 @@ func (api *API) patchWorkspaceProxy(rw http.ResponseWriter, r *http.Request) {
138
138
// User is editing the default primary proxy.
139
139
if req .Name != "" {
140
140
httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
141
- Message : "Cannot update name of default primary proxy" ,
141
+ Message : "Cannot update name of default primary proxy, did you mean to update the 'display name'? " ,
142
142
Validations : []codersdk.ValidationError {
143
143
{Field : "name" , Detail : "Cannot update name of default primary proxy" },
144
144
},
@@ -244,7 +244,7 @@ func (api *API) deleteWorkspaceProxy(rw http.ResponseWriter, r *http.Request) {
244
244
aReq .Old = proxy
245
245
defer commitAudit ()
246
246
247
- if proxy .Name == "primary" {
247
+ if proxy .IsPrimary () {
248
248
httpapi .Write (ctx , rw , http .StatusBadRequest , codersdk.Response {
249
249
Message : "Cannot delete primary proxy" ,
250
250
})
@@ -403,6 +403,14 @@ func (api *API) workspaceProxies(rw http.ResponseWriter, r *http.Request) {
403
403
return
404
404
}
405
405
406
+ // Add the primary as well
407
+ primaryProxy , err := api .AGPL .PrimaryWorkspaceProxy (ctx )
408
+ if err != nil && ! xerrors .Is (err , sql .ErrNoRows ) {
409
+ httpapi .InternalServerError (rw , err )
410
+ return
411
+ }
412
+ proxies = append (proxies , primaryProxy )
413
+
406
414
statues := api .ProxyHealth .HealthStatus ()
407
415
httpapi .Write (ctx , rw , http .StatusOK , convertProxies (proxies , statues ))
408
416
}
@@ -680,6 +688,18 @@ func convertProxies(p []database.WorkspaceProxy, statuses map[uuid.UUID]proxyhea
680
688
}
681
689
682
690
func convertProxy (p database.WorkspaceProxy , status proxyhealth.ProxyStatus ) codersdk.WorkspaceProxy {
691
+ if p .IsPrimary () {
692
+ // Primary is always healthy since the primary serves the api that this
693
+ // is returned from.
694
+ u , _ := url .Parse (p .Url )
695
+ status = proxyhealth.ProxyStatus {
696
+ Proxy : p ,
697
+ ProxyHost : u .Host ,
698
+ Status : proxyhealth .Healthy ,
699
+ Report : codersdk.ProxyHealthReport {},
700
+ CheckedAt : time .Now (),
701
+ }
702
+ }
683
703
if status .Status == "" {
684
704
status .Status = proxyhealth .Unknown
685
705
}
0 commit comments