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

chore: Implement workspace proxy going away (graceful shutdown)#7459

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

Merged
Emyrk merged 8 commits intomainfromstevenmasley/proxy_going_away
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 63 additions & 2 deletionscoderd/apidoc/docs.go
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

57 changes: 55 additions & 2 deletionscoderd/apidoc/swagger.json
View file
Open in desktop

Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.

22 changes: 20 additions & 2 deletionscodersdk/workspaceproxy.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,9 +15,9 @@ import (
type ProxyHealthStatus string

const (
//ProxyReachable means the proxy access url is reachable and returns a healthy
//ProxyHealthy means the proxy access url is reachable and returns a healthy
// status code.
ProxyReachable ProxyHealthStatus = "reachable"
ProxyHealthy ProxyHealthStatus = "ok"
// ProxyUnreachable means the proxy access url is not responding.
ProxyUnreachable ProxyHealthStatus = "unreachable"
// ProxyUnhealthy means the proxy access url is responding, but there is some
Expand DownExpand Up@@ -110,6 +110,24 @@ func (c *Client) WorkspaceProxies(ctx context.Context) ([]WorkspaceProxy, error)
return proxies, json.NewDecoder(res.Body).Decode(&proxies)
}

func (c *Client) WorkspaceProxyByName(ctx context.Context, name string) (WorkspaceProxy, error) {
res, err := c.Request(ctx, http.MethodGet,
fmt.Sprintf("/api/v2/workspaceproxies/%s", name),
nil,
)
if err != nil {
return WorkspaceProxy{}, xerrors.Errorf("make request: %w", err)
}
defer res.Body.Close()

if res.StatusCode != http.StatusOK {
return WorkspaceProxy{}, ReadBodyAsError(res)
}

var proxy WorkspaceProxy
return proxy, json.NewDecoder(res.Body).Decode(&proxy)
}

func (c *Client) DeleteWorkspaceProxyByName(ctx context.Context, name string) error {
res, err := c.Request(ctx, http.MethodDelete,
fmt.Sprintf("/api/v2/workspaceproxies/%s", name),
Expand Down
58 changes: 55 additions & 3 deletionsdocs/api/enterprise.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1191,7 +1191,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaceproxies \
"errors": ["string"],
"warnings": ["string"]
},
"status": "reachable"
"status": "ok"
},
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
Expand DownExpand Up@@ -1232,7 +1232,7 @@ Status Code **200**

| Property | Value |
| -------- | -------------- |
| `status` | `reachable` |
| `status` | `ok` |
| `status` | `unreachable` |
| `status` | `unhealthy` |
| `status` | `unregistered` |
Expand DownExpand Up@@ -1286,7 +1286,7 @@ curl -X POST http://coder-server:8080/api/v2/workspaceproxies \
"errors": ["string"],
"warnings": ["string"]
},
"status": "reachable"
"status": "ok"
},
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
Expand All@@ -1302,6 +1302,58 @@ curl -X POST http://coder-server:8080/api/v2/workspaceproxies \

To perform this operation, you must be authenticated. [Learn more](authentication.md).

## Get workspace proxy

### Code samples

```shell
# Example request using curl
curl -X GET http://coder-server:8080/api/v2/workspaceproxies/{workspaceproxy} \
-H 'Accept: application/json' \
-H 'Coder-Session-Token: API_KEY'
```

`GET /workspaceproxies/{workspaceproxy}`

### Parameters

| Name | In | Type | Required | Description |
| ---------------- | ---- | ------------ | -------- | ---------------- |
| `workspaceproxy` | path | string(uuid) | true | Proxy ID or name |

### Example responses

> 200 Response

```json
{
"created_at": "2019-08-24T14:15:22Z",
"deleted": true,
"icon": "string",
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"name": "string",
"status": {
"checked_at": "2019-08-24T14:15:22Z",
"report": {
"errors": ["string"],
"warnings": ["string"]
},
"status": "ok"
},
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
"wildcard_hostname": "string"
}
```

### Responses

| Status | Meaning | Description | Schema |
| ------ | ------------------------------------------------------- | ----------- | ------------------------------------------------------------ |
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | [codersdk.WorkspaceProxy](schemas.md#codersdkworkspaceproxy) |

To perform this operation, you must be authenticated. [Learn more](authentication.md).

## Delete workspace proxy

### Code samples
Expand Down
8 changes: 4 additions & 4 deletionsdocs/api/schemas.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3454,7 +3454,7 @@ Parameter represents a set value for the scope.
## codersdk.ProxyHealthStatus

```json
"reachable"
"ok"
```

### Properties
Expand All@@ -3463,7 +3463,7 @@ Parameter represents a set value for the scope.

| Value |
| -------------- |
| `reachable` |
| `ok` |
| `unreachable` |
| `unhealthy` |
| `unregistered` |
Expand DownExpand Up@@ -5338,7 +5338,7 @@ Parameter represents a set value for the scope.
"errors": ["string"],
"warnings": ["string"]
},
"status": "reachable"
"status": "ok"
},
"updated_at": "2019-08-24T14:15:22Z",
"url": "string",
Expand DownExpand Up@@ -5369,7 +5369,7 @@ Parameter represents a set value for the scope.
"errors": ["string"],
"warnings": ["string"]
},
"status": "reachable"
"status": "ok"
}
```

Expand Down
1 change: 1 addition & 0 deletionsenterprise/cli/proxyserver.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,6 +249,7 @@ func (*RootCmd) proxyServer() *clibase.Cmd {
if err != nil {
return xerrors.Errorf("create workspace proxy: %w", err)
}
closers.Add(func() { _ = proxy.Close() })

shutdownConnsCtx, shutdownConns := context.WithCancel(ctx)
defer shutdownConns()
Expand Down
4 changes: 3 additions & 1 deletionenterprise/coderd/coderd.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -113,13 +113,15 @@ func New(ctx context.Context, options *Options) (*API, error) {
)
r.Post("/issue-signed-app-token", api.workspaceProxyIssueSignedAppToken)
r.Post("/register", api.workspaceProxyRegister)
r.Post("/goingaway", api.workspaceProxyGoingAway)
})
r.Route("/{workspaceproxy}", func(r chi.Router) {
r.Use(
apiKeyMiddleware,
httpmw.ExtractWorkspaceProxyParam(api.Database),
)

r.Get("/", api.fetchWorkspaceProxy)
r.Delete("/", api.deleteWorkspaceProxy)
})
})
Expand DownExpand Up@@ -237,7 +239,7 @@ func New(ctx context.Context, options *Options) (*API, error) {
if api.AGPL.Experiments.Enabled(codersdk.ExperimentMoons) {
// Proxy health is a moon feature.
api.ProxyHealth, err = proxyhealth.New(&proxyhealth.Options{
Interval:time.Minute * 1,
Interval:options.ProxyHealthInterval,
DB: api.Database,
Logger: options.Logger.Named("proxyhealth"),
Client: api.HTTPClient,
Expand Down
2 changes: 2 additions & 0 deletionsenterprise/coderd/coderdenttest/coderdenttest.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,6 +48,7 @@ type Options struct {
EntitlementsUpdateInterval time.Duration
SCIMAPIKey []byte
UserWorkspaceQuota int
ProxyHealthInterval time.Duration
}

// New constructs a codersdk client connected to an in-memory Enterprise API instance.
Expand All@@ -74,6 +75,7 @@ func NewWithAPI(t *testing.T, options *Options) (*codersdk.Client, io.Closer, *c
Options: oop,
EntitlementsUpdateInterval: options.EntitlementsUpdateInterval,
Keys: Keys,
ProxyHealthInterval: options.ProxyHealthInterval,
})
assert.NoError(t, err)
setHandler(coderAPI.AGPL.RootHandler)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp