1
0
mirror of https://github.com/coder/coder.git synced 2025-03-15 19:19:58 +00:00

75 Commits

Author SHA1 Message Date
04c33968cf refactor: replace golang.org/x/exp/slices with slices ()
The experimental functions in `golang.org/x/exp/slices` are now
available in the standard library since Go 1.21.

Reference: https://go.dev/doc/go1.21#slices

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2025-03-04 00:46:49 +11:00
95363c9041 fix(enterprise/coderd): remove useless provisioner daemon id from request ()
`ServeProvisionerDaemonRequest` has had an ID field for quite a while
now.
This field is only used for telemetry purposes; the actual daemon ID is
created upon insertion in the database. There's no reason to set it, and
it's confusing to do so. Deprecating the field and removing references
to it.
2025-02-27 09:08:08 +00:00
e85da8b02b chore: return template data for provisioner daemons ()
Return template data in provisioner jobs to be displayed in the
provisioners page.
2025-02-11 14:22:34 -03:00
e9b3561677 refactor: return template_icon and make metadata required () 2025-02-10 10:00:34 -03:00
b04d883348 feat: add provisioner job metadata ()
This change adds metadata to provisioner jobs to help with rendering
related tempaltes and workspaces in the UI.

Updates 
2025-02-06 16:19:20 +02:00
6ea5c6f0ef fix: show user-auth provisioners for all organizations () 2025-01-30 14:08:27 -07:00
c0db364f3f feat(cli): add provisioner list and provisioner jobs list () 2025-01-20 17:24:22 +00:00
3864c7e3b0 feat(coderd): add endpoint to list provisioner jobs ()
Closes 
Updates 
2025-01-20 11:18:53 +02:00
071bb26018 feat(coderd): add endpoint to list provisioner daemons ()
Updates 
Updates 
Supersedes 
2025-01-14 16:40:26 +00:00
2c7f8ac65f chore: migrate to coder/websocket 1.8.12 ()
Migrates us to `coder/websocket` v1.8.12 rather than `nhooyr/websocket` on an older version.

Works around https://github.com/coder/websocket/issues/504 by adding an explicit test for `xerrors.Is(err, io.EOF)` where we were previously getting `io.EOF` from the netConn.
2024-12-19 00:51:30 +04:00
148a5a3593 fix: fix goroutine leak in log streaming over websocket ()
fixes 

Our handlers for streaming logs don't read from the websocket. We don't allow the client to send us any data, but the websocket library we use requires reading from the websocket to properly handle pings and closing. Not doing so can [can cause the websocket to hang on write](https://github.com/coder/websocket/issues/405), leaking go routines which were noticed in .

This fixes the issue, and in process refactors our log streaming to a encoder/decoder package which provides generic types for sending JSON over websocket.

I'd also like for us to upgrade to the latest https://github.com/coder/websocket but we should also upgrade our tailscale fork before doing so to avoid including two copies of the websocket library.
2024-12-03 10:12:30 +04:00
3014713c47 fix(cli): handle version mismatch re MatchedProvisioners response ()
* Modifies `MatchedProvisioners` response of `codersdk.TemplateVersion`
to be a pointer
* CLI now checks for absence of `*MatchedProvisioners` before showing
warning regarding provisioners
* Extracts logic for warning about provisioners to a function
* Improves test coverage for CLI template push with
`coder_workspace_tags`.
2024-11-29 19:45:58 +00:00
1cdc3e8921 feat!: extract provisioner tags from coder_workspace_tags data source ()
Relates to https://github.com/coder/coder/issues/15087 and
https://github.com/coder/coder/issues/15427

- Extracts provisioner job tags from `coder_workspace_tags` on template
version creation using `provisioner/terraform/tfparse` added in
https://github.com/coder/coder/pull/15236
- Drops a WARN log in coderd if no matching provisioners found.
- Also drops a warning message in the CLI if no provisioners are found.
- To support both CLI and UI warnings, added a
`codersdk.MatchedProvisioners` struct to the `TemplateVersion` response
containing details of how many provisioners were around at the time of
the insert.

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2024-11-25 11:19:14 +00:00
a518017a88 feat(coderd): add endpoint to fetch provisioner key details ()
This PR is the first step aiming to resolve  - 

Creating a new endpoint to return the details associated to a
provisioner key.

This is an authenticated endpoints aiming to be used by the provisioner
daemons - using the provisioner key as authentication method.

This endpoint is not ment to be used with PSK or User Sessions.
2024-11-20 18:04:47 +01:00
b1298a3c1e feat: add WorkspaceUpdates tailnet RPC ()
Closes 
Closes 

Adds a new user-scoped tailnet API endpoint (`api/v2/tailnet`) with a new RPC stream for receiving updates on workspaces owned by a specific user, as defined in . 

When a stream is started, the `WorkspaceUpdatesProvider` will begin listening on the user-scoped pubsub events implemented in . When a relevant event type is seen (such as a workspace state transition), the provider will query the DB for all the workspaces (and agents) owned by the user. This gets compared against the result of the previous query to produce a set of workspace updates. 

Workspace updates can be requested for any user ID, however only workspaces the authorised user is permitted to `ActionRead` will have their updates streamed.
Opening a tunnel to an agent requires that the user can perform `ActionSSH` against the workspace containing it.
2024-11-01 14:53:53 +11:00
d6766f706d fix: sort provisioner key tags in cli output ()
I'm seeing flakes like

```
    provisionerkeys_test.go:68: 2024-09-30 05:58:44.686: cmd: matched newline = "CREATED AT            NAME          TAGS            "
    provisionerkeys_test.go:72: 2024-09-30 05:58:44.686: cmd: matched newline = "2024-09-30T05:58:44Z  dont-test-me  my=way foo=bar  "
    provisionerkeys_test.go:74: 
        	Error Trace:	/Users/runner/work/coder/coder/enterprise/cli/provisionerkeys_test.go:74
        	Error:      	"2024-09-30T05:58:44Z  dont-test-me  my=way foo=bar  " does not contain "foo=bar my=way"
        	Test:       	TestProvisionerKeys/CRUD
```

e.g.
https://github.com/coder/coder/actions/runs/11100237276/job/30835714478?pr=14855

Since the tags are a map, we weren't outputting them in a consistent
order on the CLI, leading to flakes.

This sorts the tags by key when converting to a string, for a
consistent, canonical output.
2024-10-01 09:11:19 +04:00
5cc5bbea04 fix: improve provisioner key cli usability ()
What this changes:
- Unhides the `--key` flag on provisioner start
- Deprecates and hides `provisionerd` command group in favor of
`provisioner(s)`
- Removes org id from `coder provisioner keys list`
2024-09-27 10:34:41 -05:00
335eb05223 feat: add keys to organization provision daemons () 2024-09-16 20:02:08 +00:00
0b2ba96065 feat(cli): add shell completions () 2024-08-20 14:47:46 +10:00
6161d173d3 feat: add tags to provisioner keys api () 2024-07-25 15:20:45 +00:00
ca83017dc1 feat: accept provisioner keys for provisioner auth () 2024-07-25 10:22:55 -04:00
f975701b34 feat: add provisioner key cli commands () 2024-07-18 14:44:20 -04:00
b697c6939a chore: add provisioner key crud apis () 2024-07-16 13:27:12 -04:00
c6b7588933 chore: add organization id to provisioner sdk type ()
* chore: add organization id to provisioner sdk type
2024-07-12 10:56:34 -05:00
5c6974e55f feat: implement provisioner auth middleware and proper org params ()
* feat: provisioner auth in mw to allow ExtractOrg

Step to enable org scoped provisioner daemons

* chore: handle default org handling for provisioner daemons
2024-03-04 15:15:41 -06:00
475c3650ca feat: add support for optional external auth providers () 2024-02-21 11:18:38 -07:00
643c3ee54b refactor(provisionerd): move provisionersdk.VersionCurrent -> provisionerdproto.VersionCurrent () 2024-02-20 12:44:19 +00:00
a2cbb0f87f fix(enterprise/coderd): check provisionerd API version on connection () 2024-02-16 18:43:07 +00:00
1f5a6d59ba chore: consolidate websocketNetConn implementations ()
Consolidates websocketNetConn from multiple packages in favor of a central one in codersdk
2024-02-09 11:39:08 +04:00
1ef96022b0 feat(coderd): add provisioner build version and api_version on serve ()
* assert provisioner daemon version and api_version in unit tests
* add build info in HTTP header, extract codersdk.BuildVersionHeader
* add api_version to codersdk.ProvisionerDaemon
* testutil.MustString -> testutil.MustRandString
2024-01-03 09:01:57 +00:00
9a4e1100fa chore: move drpc transport tools to codersdk/drpc ()
Part of 

DRPC transport over yamux and in-mem pipes was previously only used on the provisioner APIs, but now will also be used in tailnet.  Moved to subpackage of codersdk to avoid import loops.
2023-12-15 12:41:39 +04:00
b02796655e fix(coderd/database): remove column updated_at from provisioner_daemons table () 2023-12-12 11:19:28 +00:00
1e349f0d50 feat(cli): allow specifying name of provisioner daemon ()
- Adds a --name argument to provisionerd start
- Plumbs through name to integrated and external provisioners
- Defaults to hostname if not specified for external, hostname-N for integrated
- Adds cliutil.Hostname
2023-12-07 16:59:13 +00:00
a235644046 fix(codersdk): make codersdk.ProvisionerDaemon.UpdatedAt a codersdk.NullTime () 2023-12-05 15:40:45 +00:00
5fad611020 feat(coderd): add last_seen_at and version to provisioner_daemons table ()
Related to 

- Adds columns last_seen_at and version to provisioner_daemons table
- Adds the above to codersdk.ProvisionerDaemons struct
2023-12-05 13:54:38 +00:00
504cedf15a feat: add telemetry for external provisioners () 2023-10-18 14:20:30 -05:00
5021e23105 chore: compute job status as column ()
* chore: provisioner job status as column
* use provisioner job status for workspace searching
2023-10-04 20:57:46 -05:00
b240799f47 refactor(cli): use codersdk for provisioner types ()
This change removes one use of `coderd/database` from the slim binary
and more correctly uses codersdk instead of database or provisionerd
packages.

No size change (yet).

Ref: 
2023-09-04 21:42:15 +03:00
e845deaa89 fix: prompt when parameter options are incompatible () 2023-08-23 18:18:38 +02:00
22e781eced chore: add /v2 to import module path ()
* chore: add /v2 to import module path

go mod requires semantic versioning with versions greater than 1.x

This was a mechanical update by running:
```
go install github.com/marwan-at-work/mod/cmd/mod@latest
mod upgrade
```

Migrate generated files to import /v2

* Fix gen
2023-08-18 18:55:43 +00:00
cb4989cd8d feat: add PSK for external provisionerd auth ()
Signed-off-by: Spike Curtis <spike@coder.com>
2023-08-04 12:32:28 +04:00
69f911dfd5 feat: add queue_position and queue_size to provisioner jobs () 2023-06-20 15:07:18 -05:00
7c3dbbbe93 fix: stream provisioner logs ()
* stream provisioner logs

Signed-off-by: Spike Curtis <spike@coder.com>

* Fix imports

Signed-off-by: Spike Curtis <spike@coder.com>

* Better logging, naming, arg order

Signed-off-by: Spike Curtis <spike@coder.com>

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-05-31 06:15:58 +00:00
cb7375450b feat: add startup script logs to the ui ()
* Add startup script logs to the database

* Add coderd endpoints for startup script logs

* Push startup script logs from agent

* Pull startup script logs on frontend

* Rename queries

* Add constraint

* Start creating log sending loop

* Add log sending to the agent

* Add tests for streaming logs

* Shorten notify channel name

* Add FE

* Improve bulk log performance

* Finish UI display

* Fix startup log visibility

* Add warning for overflow

* Fix agent queue logs overflow

* Display staartup logs in a virtual DOM for performance

* Fix agent queue with loads of logs

* Fix authorize test

* Remove faulty test

* Fix startup and shutdown reporting error

* Fix gen

* Fix comments

* Periodically purge old database entries

* Add test fixture for migration

* Add Storybook

* Check if there are logs when displaying features

* Fix startup component overflow gap

* Fix startup log wrapping

---------

Co-authored-by: Asher <ash@coder.com>
2023-03-23 14:09:13 -05:00
db2bdd1cab fix: pass sdk header transport to websocket connections ()
Fixes .
2023-03-09 02:29:02 +00:00
3b87316ad7 feat: propagate job error codes ()
* feat: propagate job error_code

* fix

* Fix

* Fix

* Fix

* add errors to typesGenerated

* Address PR comments

* Fix
2023-03-08 16:32:00 +01:00
5df7872661 fix: Improve use of context in websocket.NetConn code paths () 2023-02-14 16:42:55 +02:00
7ad87505c8 chore: move agent functions from codersdk into agentsdk ()
* chore: rename `AgentConn` to `WorkspaceAgentConn`

The codersdk was becoming bloated with consts for the workspace
agent that made no sense to a reader. `Tailnet*` is an example
of these consts.

* chore: remove `Get` prefix from *Client functions

* chore: remove `BypassRatelimits` option in `codersdk.Client`

It feels wrong to have this as a direct option because it's so infrequently
needed by API callers. It's better to directly modify headers in the two
places that we actually use it.

* Merge `appearance.go` and `buildinfo.go` into `deployment.go`

* Merge `experiments.go` and `features.go` into `deployment.go`

* Fix `make gen` referencing old type names

* Merge `error.go` into `client.go`

`codersdk.Response` lived in `error.go`, which is wrong.

* chore: refactor workspace agent functions into agentsdk

It was odd conflating the codersdk that clients should use
with functions that only the agent should use. This separates
them into two SDKs that are closely coupled, but separate.

* Merge `insights.go` into `deployment.go`

* Merge `organizationmember.go` into `organizations.go`

* Merge `quota.go` into `workspaces.go`

* Rename `sse.go` to `serversentevents.go`

* Rename `codersdk.WorkspaceAppHostResponse` to `codersdk.AppHostResponse`

* Format `.vscode/settings.json`

* Fix outdated naming in `api.ts`

* Fix app host response

* Fix unsupported type

* Fix imported type
2023-01-29 15:47:24 -06:00
d9436fab69 docs: API enterprise ()
* docs: audit, deploymentconfig, files, parameters

* Swagger comments in workspacebuilds.go

* structs in workspacebuilds.go

* workspaceagents: instance identity

* workspaceagents.go in progress

* workspaceagents.go in progress

* Agents

* workspacebuilds.go

* /workspaces

* templates.go, templateversions.go

* templateversion.go in progress

* cancel

* templateversions

* wip

* Merge

* x-apidocgen

* NullTime hack not needed anymore

* Fix: x-apidocgen

* Members

* Fixes

* Fix

* WIP

* WIP

* Users

* Logout

* User profile

* Status suspend activate

* User roles

* User tokens

* Keys

* SSH key

* All

* Typo

* Fix

* Entitlements

* Groups

* SCIM

* Fix

* Fix

* Clean templates

* Sort API pages

* Fix: HashedSecret

* General is first
2023-01-11 16:05:42 +01:00
66fa2a1a8c docs: API workspace agents and builds () 2023-01-05 15:27:10 +01:00