Commit Graph

587 Commits

Author SHA1 Message Date
Asher 3014777d2a
feat: add endpoints to oauth2 provider applications (#11718)
These will show up when configuring the application along with the
client ID and everything else.  Should make it easier to configure the
application, otherwise you will have to go look up the URLs in the
docs (which are not yet written).

Co-authored-by: Steven Masley <stevenmasley@gmail.com>
2024-01-22 13:25:25 -09:00
Spike Curtis f01cab9894
feat: use tailnet v2 API for coordination (#11638)
This one is huge, and I'm sorry.

The problem is that once I change `tailnet.Conn` to start doing v2 behavior, I kind of have to change it everywhere, including in CoderSDK (CLI), the agent, wsproxy, and ServerTailnet.

There is still a bit more cleanup to do, and I need to add code so that when we lose connection to the Coordinator, we mark all peers as LOST, but that will be in a separate PR since this is big enough!
2024-01-22 11:07:50 +04:00
Kayla Washburn-Love 80eac73ed1
chore: remove `useLocalStorage` hook (#11712) 2024-01-19 16:04:19 -07:00
Steven Masley ca48b8783b
fix: update template with noop returned undefined template (#11688)
* fix: doing a noop patch to templates resulted in 404

The patch response did not include the template. The UI required the
template to be returned to form the new page path

null is more explicit, and harder to make occur by mistake.
2024-01-19 18:54:25 +00:00
Marcin Tojek 89fd29478d
feat: expose support links as env variables (#11697) 2024-01-19 11:20:36 +01:00
Steven Masley 6bb1a34a37
fix: allow ports in wildcard url configuration (#11657)
* fix: allow ports in wildcard url configuration

This just forwards the port to the ui that generates urls.
Our existing parsing + regex already supported ports for
subdomain app requests.
2024-01-18 09:44:05 -06:00
Spike Curtis 8910ac715c
feat: add tailnet v2 support to wsproxy coordinate endpoint (#11637)
wsproxy also needs to be updated to use tailnet v2 because the `tailnet.Conn` stores peers by ID, and the peerID was not being carried by the JSON protocol.  This adds a query param to the endpoint to conditionally switch to the new protocol.
2024-01-18 10:10:36 +04:00
Steven Masley b246f08d84
chore: move app URL parsing to its own package (#11651)
* chore: move app url parsing to it's own package
2024-01-17 10:41:42 -06:00
Marcin Tojek 5eb3e1cdaa
feat: expose `owner_name` in `coder_workspace` resource (#11639) 2024-01-17 13:20:45 +01:00
Spike Curtis bad2ce562e
fix: stop asserting fuzz bytes written in test
Fixes a flake seen here: https://github.com/coder/coder/actions/runs/7541558190/job/20528545916

```
=== FAIL: enterprise/provisionerd TestRemoteConnector_Fuzz (0.06s)
    t.go:84: 2024-01-16 12:32:27.024 [info]  connector: failed provisioner authentication  remote_addr=[::1]:45138 ...
        error= failed to receive jobID:
                   github.com/coder/coder/v2/enterprise/provisionerd.(*remoteConnector).authenticate
                       /home/runner/actions-runner/_work/coder/coder/enterprise/provisionerd/remoteprovisioners.go:438
                 - bufio.Scanner: token too long
    t.go:84: 2024-01-16 12:32:27.024 [debu]  connector: closed connection  remote_addr=[::1]:45138  error=<nil>
    remoteprovisioners_test.go:209: 
            Error Trace:    /home/runner/actions-runner/_work/coder/coder/enterprise/provisionerd/remoteprovisioners_test.go:209
            Error:          "2992256" is not less than "2097152"
            Test:           TestRemoteConnector_Fuzz
            Messages:       should not allow more than 1 MiB
```

This was an attempt to test that malicious actors can't abuse our authentication protocol to make us allocate a bunch of memory.
However, the test asserted on the number of bytes sent by the fuzzer, not the number of bytes read (& allocated) by the service.  The former is affected by network queue sizes and is thus flaky without actively managing the socket queues, which I don't think we want to do.

In actual practise, the thing that matters is how much memory the bufio Scanner allocates. By inspection, the scanner will allocate up to 64k, and testing this is true devolves into testing the go standard library, which I don't think is worth doing.

So... let's just drop the assertion because 

a) its flaky, 

b) it doesn't test what we actually want to test, 

c) the behavior we actually care about is part of the standard library.
2024-01-17 12:59:45 +04:00
Colin Adler be43d6247d
feat: add additional fields to first time setup trial flow (#11533)
* feat: add additional fields to first time setup trial flow

* trial generator typo
2024-01-16 18:19:16 -06:00
Jon Ayers 1196f83ebd
feat: automatically activate dormant workspaces when manually started (#11655) 2024-01-16 16:42:04 -06:00
Steven Masley 08b4eb3124
fix: refresh all oauth links on external auth page (#11646)
* fix: refresh all oauth links on external auth page
2024-01-16 11:03:55 -06:00
Cian Johnston d583acad00
fix(coderd): workspaceapps: update last_used_at when workspace app reports stats (#11603)
- Adds a new query BatchUpdateLastUsedAt
- Adds calls to BatchUpdateLastUsedAt in app stats handler upon flush
- Passes a stats flush channel to apptest setup scaffolding and updates unit tests to assert modifications to LastUsedAt.
2024-01-16 14:06:39 +00:00
Kayla Washburn-Love 4c3f05b8aa
fix: show error when creating a new group fails (#11560) 2024-01-12 16:06:02 -07:00
Steven Masley 905292053a
fix: improve wsproxy error when proxyurl is set to a primary (#11586)
* coder error first
2024-01-12 20:32:02 +00:00
Steven Masley f5a9f5ca3d
chore: handle errors in wsproxy server for cli using buildinfo (#11584)
Cli errors are pretty formatted. This handles nested pretty types. Before it found the first error it could understand and return that. Now it will print the full error stack with more information.

To prevent information loss, a "[Trace=...]" was added to capture some extra error context for debugging.
2024-01-11 16:55:34 -06:00
Jon Ayers aecdafdcf2
fix: fix template edit overriding with flag defaults (#11564) 2024-01-11 16:18:46 -06:00
Colin Adler 4a0808259a
fix: ensure wsproxy `MultiAgent` is closed when websocket dies (#11414)
The `SingleTailnet` behavior only checked to see if the `MultiAgent` was
closed, but the websocket error was not being propogated into the
`MultiAgent`, causing it to never be swapped for a new working one.

Fixes https://github.com/coder/coder/issues/11401

Before:
```
Coder Workspace Proxy v0.0.0-devel+85ff030 - Your Self-Hosted Remote Development Platform
Started HTTP listener at http://0.0.0.0:3001

View the Web UI: http://127.0.0.1:3001

==> Logs will stream in below (press ctrl+c to gracefully exit):
2024-01-04 20:11:56.376 [warn]  net.workspace-proxy.servertailnet: broadcast server node to agents ...
    error= write message:
               github.com/coder/coder/v2/enterprise/wsproxy/wsproxysdk.(*remoteMultiAgentHandler).writeJSON
                   /home/coder/coder/enterprise/wsproxy/wsproxysdk/wsproxysdk.go:524
             - failed to write msg: WebSocket closed: failed to read frame header: EOF
```

After:
```
Coder Workspace Proxy v0.0.0-devel+12f1878 - Your Self-Hosted Remote Development Platform
Started HTTP listener at http://0.0.0.0:3001

View the Web UI: http://127.0.0.1:3001

==> Logs will stream in below (press ctrl+c to gracefully exit):
2024-01-04 20:26:38.545 [warn]  net.workspace-proxy.servertailnet: multiagent closed, reinitializing
2024-01-04 20:26:38.546 [erro]  net.workspace-proxy.servertailnet: reinit multi agent ...
    error= dial coordinate websocket:
               github.com/coder/coder/v2/enterprise/wsproxy/wsproxysdk.(*Client).DialCoordinator
                   /home/coder/coder/enterprise/wsproxy/wsproxysdk/wsproxysdk.go:454
             - failed to WebSocket dial: failed to send handshake request: Get "http://127.0.0.1:3000/api/v2/workspaceproxies/me/coordinate": dial tcp 127.0.0.1:3000: connect: connection refused
2024-01-04 20:26:38.587 [erro]  net.workspace-proxy.servertailnet: reinit multi agent ...
    error= dial coordinate websocket:
               github.com/coder/coder/v2/enterprise/wsproxy/wsproxysdk.(*Client).DialCoordinator
                   /home/coder/coder/enterprise/wsproxy/wsproxysdk/wsproxysdk.go:454
             - failed to WebSocket dial: failed to send handshake request: Get "http://127.0.0.1:3000/api/v2/workspaceproxies/me/coordinate": dial tcp 127.0.0.1:3000: connect: connection refusedhandshake request: Get "http://127.0.0.1:3000/api/v2/workspaceproxies/me/coordinate": dial tcp 127.0.0.1:3000: connect: connection refused
2024-01-04 20:26:40.446 [info]  net.workspace-proxy.servertailnet: successfully reinitialized multiagent  agents=0  took=1.900892615s
```
2024-01-11 11:37:09 -06:00
Jon Ayers 9b437032e9
feat: remove workspace_actions experiment (#11427) 2024-01-10 16:19:39 -06:00
Spike Curtis cae095fdb6
fix: stop logging errors on canceled cleanup queries (#11547)
Fixes flake seen here: https://github.com/coder/coder/actions/runs/7474259128/job/20340051975
2024-01-10 16:20:29 +04:00
Marcin Tojek 525e6e5dc8
docs: remove empty page (#11511) 2024-01-09 12:52:45 +01:00
Cian Johnston 0c953b4b8c
fix(enterprise/coderd): make primary workspace proxy always be updatd now (#11499) 2024-01-09 10:03:08 +00:00
Steven Masley fb29af664b
fix: relax csrf to exclude path based apps (#11430)
* fix: relax csrf to exclude path based apps
* add unit test to verify path based apps are not CSRF blocked
2024-01-08 22:33:57 +00:00
Cian Johnston 04fd96a014
feat(coderd): add provisioner_daemons to /debug/health endpoint (#11393)
Adds a healthcheck for provisioner daemons to /debug/health endpoint.
2024-01-08 09:29:04 +00:00
Garrett Delfosse b21da38bea
chore: deprecate template create command in favor of template push (#11390) 2024-01-05 21:04:14 +00:00
Spike Curtis 64638b381d
feat: promote PG Coordinator out of experimental (#11398)
Promotes PG Coordinator out of experimental to GA
2024-01-05 08:03:36 +04:00
Steven Masley dd05a6b13a
chore: mockgen archived, moved to new location (#11415)
* chore: mockgen archived, moved to new location
2024-01-04 18:35:56 -06:00
Spike Curtis 48cd4c3a10
feat: promote single-tailnet out of experimental (#11366) 2024-01-04 09:27:36 +04:00
Cian Johnston 1ef96022b0
feat(coderd): add provisioner build version and api_version on serve (#11369)
* 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
Asher 5cfa34b31e
feat: add OAuth2 applications (#11197)
* Add database tables for OAuth2 applications

These are applications that will be able to use OAuth2 to get an API key
from Coder.

* Add endpoints for managing OAuth2 applications

These let you add, update, and remove OAuth2 applications.

* Add frontend for managing OAuth2 applications
2023-12-21 21:38:42 +00:00
Jon Ayers 0b7d68dc3f
chore: remove template_update_policies experiment (#11250) 2023-12-21 13:39:33 -06:00
Spike Curtis 52b87a28b0
fix: stop printing warnings on external provisioner daemon command (#11309)
fixes #11307
2023-12-21 16:55:34 +04:00
Steven Masley fbda21a9f2
feat: move moons experiment to ga (released) (#11285)
* feat: release moons experiment as ga
2023-12-19 14:40:22 -06:00
Cian Johnston d2d7628522
fix(enterprise/cli): add CODER_PROVISIONER_DAEMON_LOG_* options (#11279)
- Extracts cli.BuildLogger to clilog package
- Updates existing usage of cli.BuildLogger and removes it
- Use clilog to initialize provisionerd logger
2023-12-19 16:49:50 +00:00
Spike Curtis f2606a78dd
fix: avoid converting nil node
fixes: #11276
2023-12-19 13:38:15 +04:00
Cian Johnston 213b768785
feat(coderd): insert provisioner daemons (#11207)
* Adds UpdateProvisionerDaemonLastSeenAt
* Adds heartbeat to provisioner daemons
* Inserts provisioner daemons to database upon start
* Ensures TagOwner is an empty string and not nil
* Adds COALESCE() in idx_provisioner_daemons_name_owner_key
2023-12-18 16:44:52 +00:00
Jon Ayers 56cbd47082
chore: fix TestWorkspaceAutobuild/DormancyThresholdOK flake (#11251) 2023-12-18 09:23:06 -06:00
Dean Sheather e46431078c
feat: add AgentAPI using DRPC (#10811)
Co-authored-by: Spike Curtis <spike@coder.com>
2023-12-18 22:53:28 +10:00
Garrett Delfosse 7924bb2a56
feat!: move workspace renames behind flag, disable by default (#11189) 2023-12-15 13:38:47 -05:00
Dean Sheather 1e49190e12
feat: add server flag to disable user custom quiet hours (#11124) 2023-12-15 19:33:51 +10:00
Spike Curtis 9a4e1100fa
chore: move drpc transport tools to codersdk/drpc (#11224)
Part of #10532

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
Dean Sheather b36071c6bb
feat: allow templates to specify max_ttl or autostop_requirement (#10920) 2023-12-15 18:27:56 +10:00
Spike Curtis ad3fed72bc
chore: rename Coordinator to CoordinatorV1 (#11222)
Renames the tailnet.Coordinator to represent both v1 and v2 APIs, so that we can use this interface for the main atomic pointer.

Part of #10532
2023-12-15 11:38:12 +04:00
Spike Curtis 545cb9a7cc
fix: wait for coordinator in Test_agentIsLegacy (#11214)
Fixes flake https://github.com/coder/coder/runs/19639217635

AGPL coordinator used to process node updates for single_tailnet synchronously, but it's been refactored to process async, so in this test we need to wait for it to be processed.
2023-12-15 07:21:18 +04:00
Colin Adler 4672700ef6
chore: add additional fields to license telemetry (#11173)
This sends the email the license was issued to, and whether or not it's a trial in the telemetry payload. It's a bit janky since the license parsing is all enterprise licensed.
2023-12-14 15:52:52 -06:00
Spike Curtis bf3b35b1e2
fix: stop logging context Canceled as error (#11177)
fixes #11166 and a related log that could have the same problem
2023-12-13 13:08:30 +04:00
Cian Johnston b02796655e
fix(coderd/database): remove column updated_at from provisioner_daemons table (#11108) 2023-12-12 11:19:28 +00:00
Kayla Washburn 6775a86785
chore: make `"users"."avatar_url"` `NOT NULL` (#11112) 2023-12-11 10:09:51 -07:00
Jon Ayers 37f6b38d53
fix: return 403 when rebuilding workspace with require_active_version (#11114) 2023-12-08 23:03:46 -06:00
Kayla Washburn d8e95001e8
chore: add theme_preference column to users table (#11069) 2023-12-08 21:59:53 +00:00
Steven Masley 78517cab52
feat: add group allowlist for oidc (#11070)
* feat: group allow list in OIDC settings
2023-12-08 10:14:19 -06:00
Cian Johnston 2b19a2369f
chore(coderd): move provisionerd tags to provisionersdk (#11100) 2023-12-08 12:10:25 +00:00
Spike Curtis b4ca1d6579
feat: include server agent API version in buildinfo (#11057)
First part of #10340 -- we need this version to compare with agents to tell if they are on a deprecated Agent API version
2023-12-08 12:50:25 +04:00
Jon Ayers e73a202aed
feat: show dormant workspaces by default (#11053) 2023-12-07 18:09:35 -06:00
Jon Ayers ce49a55f56
chore: update build_reason 'autolock' -> 'dormancy' (#11074) 2023-12-07 17:11:57 -06:00
Cian Johnston 1e349f0d50
feat(cli): allow specifying name of provisioner daemon (#11077)
- 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
Spike Curtis b34ecf1e9e
fix: fix deadlock of mappingQuery on context canceled
Fixes #11078

replace bare channel send with SendCtx so that we properly shut down when context is canceled.
2023-12-07 17:19:18 +04:00
Spike Curtis 2c86d0bed0
feat: support v2 Tailnet API in AGPL coordinator (#11010)
Fixes #10529
2023-12-06 15:04:28 +04:00
Cian Johnston 2e4e0b2d2c
fix(scripts/apitypings): force health.Message and health.Severity to correct types (#11043)
* Force typegen types for some fields of derp health report
* Explicitly allocate slices for RegionReport.{Errors,Warnings} to avoid nulls in API response
2023-12-05 16:31:48 +00:00
Cian Johnston a235644046
fix(codersdk): make codersdk.ProvisionerDaemon.UpdatedAt a codersdk.NullTime (#11037) 2023-12-05 15:40:45 +00:00
Cian Johnston 5fad611020
feat(coderd): add last_seen_at and version to provisioner_daemons table (#11033)
Related to #10676

- 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
Dean Sheather 695f57f7ff
fix: use header flags in wsproxy server (#10985) 2023-12-05 14:13:42 +04:00
Steven Masley 2f54f769be
feat: allow IDP to return single string for roles/groups claim (#10993)
* feat: allow IDP to return single string instead of array for roles/groups claim

This is to support ADFS
2023-12-04 10:01:45 -06:00
Spike Curtis 812fb95273
fix: prevent connIO from panicking in race between Close and Enqueue (#10948)
Spotted during a code read.  ConnIO unlocks the mutex before attempting to write to the response channel, which could allow another goroutine to call Close() and close the channel, causing a panic.

Fix is to hold the mutex.  This won't cause a deadlock because the `select{}` has a `default` case, so we won't block even if the receiver isn't keeping up.
2023-12-01 10:23:29 +04:00
Spike Curtis 612e67a53b
feat: add cleanup of lost tailnet peers and tunnels to PGCoordinator (#10939)
Adds the "lost" peer cleanup queries to PGCoordinator, including tests.
2023-12-01 10:13:29 +04:00
Spike Curtis 0cab6e7763
feat: support graceful disconnect in PGCoordinator (#10937)
Adds support for graceful disconnect to PGCoordinator.  When peers gracefully disconnect, they send a disconnect message.  This triggers the peer to be disconnected from all tunneled peers.

The Multi-Agent Client supports graceful disconnect, since it is in memory and we know that when it is closed, we really mean to disconnect.

The v1 agent and client Websocket connections do not support graceful disconnect, since the v1 protocol doesn't have this feature.  That means that if a v1 peer connects to a v2 peer, when the v1 peer's coordinator connection is closed, the v2 peer will
see it as "lost" since we don't know whether the v1 peer meant to disconnect, or it just lost connectivity to the coordinator.
2023-12-01 09:55:25 +04:00
Jon Ayers 967db2801b
chore: refactor ResolveAutostart tests to use dbfake (#10603) 2023-11-30 19:33:04 -06:00
Jon Ayers 12a4b114de
fix: fix TestWorkspaceAutobuild/InactiveTTLOK flake (#10965) 2023-11-30 18:29:41 -06:00
Jon Ayers 329aa45c16
fix: fix TestWorkspaceAutobuild/DormantNoAutostart flake (#10963) 2023-11-30 15:45:27 -06:00
Jon Ayers 48d69c9e60
fix: update autostart context to include querying users (#10929) 2023-11-28 17:56:49 -06:00
Garrett Delfosse afbda2235c
fix: insert replica when removed by cleanup (#10917) 2023-11-28 14:15:09 -05:00
Spike Curtis 52901e1219
feat: implement HTMLDebug for PGCoord with v2 API (#10914)
Implements HTMLDebug for the PGCoordinator with the new v2 API and related DB tables.
2023-11-28 22:37:20 +04:00
Marcin Tojek 19b6d194fc
feat: manage health settings using Coder API (#10861) 2023-11-28 18:15:17 +01:00
Steven Masley abb2c7656a
chore: add claims to oauth link in db for debug (#10827)
* chore: add claims to oauth link in db for debug
2023-11-27 10:47:23 -06:00
Cian Johnston dd161b172e
feat: allow auditors to read template insights (#10860)
- Adds a template_insights pseudo-resource
- Grants auditor and template admin roles read access on template_insights
- Updates existing RBAC checks to check for read template_insights, falling back to template update permissions where necessary
- Updates TemplateLayout to show Insights tab if can read template_insights or can update template
2023-11-24 17:21:32 +00:00
Cian Johnston 411ce46442
feat(coderd/healthcheck): add health check for proxy (#10846)
Adds a health check for workspace proxies:
- Healthy iff all proxies are healthy and the same version,
- Warning if some proxies are unhealthy,
- Error if all proxies are unhealthy, or do not all have the same version.
2023-11-24 15:06:51 +00:00
Cian Johnston f342d10c31
fix(enterprise/coderd/proxyhealth): properly defer healthCheckDuration observe (#10848) 2023-11-23 15:23:40 +00:00
Spike Curtis 89c13c2212
fix: enable FeatureHighAvailability if it is licensed (#10834)
fixes #10810

The tailnet coordinators don't depend on replicasync, so we can still enable HA coordinators even if the relay URL is unset.

The in-memory, non-HA coordinator probably has lower latency than the PG Coordinator, since we have to query the database, so enterprise customers might want to disable it for single-replica deployments, but this PR default-enables the HA coordinator.  We could add support later to disable it if anyone complains. Latency setting up connections matters, but I don't believe the coordinator contributes significantly at this point for reasonable postgres round-trip-time.
2023-11-22 14:46:55 +04:00
Jon Ayers 8d1cfbce8f
fix: update workspace cleanup flag names for template cmds (#10805) 2023-11-21 18:20:01 -06:00
Cian Johnston abafc0863c
feat(coderd): store workspace proxy version in the database (#10790)
Stores workspace proxy version in database upon registration.
2023-11-21 11:21:25 +00:00
Steven Masley 5229d7fd3a
feat: implement deprecated flag for templates to prevent new workspaces (#10745)
* feat: implement deprecated flag for templates to prevent new workspaces
* Add deprecated filter to template fetching
* Add deprecated to template table
* Add deprecated notice to template page
* Add ui to deprecate a template
2023-11-20 19:16:18 +00:00
Spike Curtis 5173bce5cc
fix: stop redirecting DERP and replicasync http requests (#10752)
Fixes an issue where setting CODER_REDIRECT_TO_ACCESS_URL breaks use of multiple Coder server replicas for DERP traffic.
2023-11-20 14:46:59 +04:00
Spike Curtis 5c48cb4447
feat: modify PG Coordinator to work with new v2 Tailnet API (#10573)
re: #10528

Refactors PG Coordinator to work with the Tailnet v2 API, including wrappers for the existing v1 API.

The debug endpoint functions, but doesn't return sensible data, that will be in another stacked PR.
2023-11-20 14:31:04 +04:00
Dean Sheather 10204ba829
chore: retry healthcheck in proxy region test (#10729) 2023-11-16 22:21:16 +10:00
Jon Ayers 75ab16d19a
fix: prevent db deadlock when workspaces go dormant (#10618) 2023-11-13 13:40:20 -06:00
Cian Johnston b69c237b8a
feat(coderd/healthcheck): allow configuring database hc threshold (#10623)
* feat(coderd/healthcheck): allow configuring database hc threshold
* feat(coderd): add database hc latency, plumb through
* feat(coderd): allow configuring healthcheck refresh interval
2023-11-13 14:14:43 +00:00
Spike Curtis f400d8a0c5
fix: handle SIGHUP from OpenSSH (#10638)
Fixes an issue where remote forwards are not correctly torn down when using OpenSSH with `coder ssh --stdio`.  OpenSSH sends a disconnect signal, but then also sends SIGHUP to `coder`.  Previously, we just exited when we got SIGHUP, and this raced against properly disconnecting.

Fixes https://github.com/coder/customers/issues/327
2023-11-13 15:14:42 +04:00
Jon Ayers e23873ff8f
feat: add endpoint for resolving autostart status (#10507) 2023-11-08 23:24:56 -06:00
Jon Ayers cf8ee78547
fix: disable autostart for flakey test (#10598) 2023-11-08 17:56:36 -06:00
Cian Johnston 26740cf00d
chore(scripts/rules.go): broaden scope of testingWithOwnerUser linter (#10548)
* Updated testingWithOwnerUser ruleguard rule to detect:
  a) Passing client from coderdenttest.New() to clitest.SetupConfig() similar to what already exists for AGPL code
  b) Usage of any method of the owner client from coderdenttest.New() - all usages of the owner client must be justified with a `//nolint:gocritic` comment.
* Fixed resulting linter complaints.
* Added new coderdtest helpers CreateGroup and UpdateTemplateMeta.
* Modified check_enterprise_import.sh to ignore scripts/rules.go.
2023-11-08 14:54:48 +00:00
Steven Masley 64398def48
feat: add configurable cipher suites for tls listening (#10505)
* feat: add configurable cipher suites for tls listening
* tls.VersionName is go 1.21, copy the function
2023-11-07 14:55:39 +00:00
Dean Sheather bb5acb0332
fix: allow users to use quiet hours endpoint (#10547) 2023-11-06 13:16:50 +00:00
Jon Ayers 2dce4151ba
feat: add cli support for workspace automatic updates (#10438) 2023-11-02 14:41:34 -05:00
Kyle Carberry 5abfe5afd0
chore: rename dbfake to dbmem (#10432) 2023-10-30 17:42:20 +00:00
Kira Pilot ed5567ba28
fix: show dormant and suspended users in groups (#10333)
* fix: show dormant and suspended users in groups

* added status column
2023-10-20 11:36:00 -04:00
Jon Ayers f5f150d568
feat: add cli support for --require-active-version (#10337) 2023-10-19 17:16:15 -05:00
Jon Ayers 997493d4ae
feat: add template setting to require active template version (#10277) 2023-10-18 17:07:21 -05:00
Colin Adler 504cedf15a
feat: add telemetry for external provisioners (#10322) 2023-10-18 14:20:30 -05:00
Cian Johnston 6875faf238
fix(coderd/provisionerdserver): pass through api ctx to provisionerdserver (#10259)
Passes through coderd API ctx to provisionerd server so we can cancel workspace updates when API is shutting down.
2023-10-16 13:50:07 +01:00
Steven Masley 39c0539d42
feat: add controls to template for determining startup days (#10226)
* feat: template controls which days can autostart
* Add unit test to test blocking autostart with DaysOfWeek
2023-10-13 11:57:18 -05:00
Marcin Tojek 2a4ac2a53c
feat: expose user seat limits as Prometheus metrics (#10169) 2023-10-13 08:10:16 +00:00
Cian Johnston 59ae69b7f2
chore(enterprise/cli): fix test flake in TestServerDBCrypt (#10222)
* increase randomness in names generated by server dbcrypt

* more randomness

* close PTYs when we are done with them
2023-10-11 17:38:20 +01:00
Spike Curtis 3c43216e99
fix: remove Parallel() call after timeout context (#10203)
Fixes test flake seen here: https://github.com/coder/coder/runs/17562370632

It's inherently flaky to create a context with a timeout and then later call `t.Parallel()` since it causes the test to wait until all non-parallel tests have completed before resuming execution.  By the time execution has resumed, the context may 
have expired.  The amount of time before resuming is dependent on machine resources and number of test cases, which are inherently variable.
2023-10-11 11:39:15 +04:00
Spike Curtis fbabb43cbb
fix: ignore spurious node updates while waiting for errors (#10175)
fixes #9921
2023-10-11 09:22:20 +04:00
Jon Ayers ec9b480ac0
fix: use is-dormant instead of dormant_at (#10191) 2023-10-10 19:00:09 -05:00
Jon Ayers 91555c3a85
feat: support configurable web terminal rendering (#10095)
* feat: support configurable web terminal rendering

- Added a deployment option for configuring web terminal rendering.
  Valid values are 'webgl', 'canvas', and 'dom'.
2023-10-10 13:18:02 -05:00
Jon Ayers 05a393cd06
feat: only display license warnings to privileged users (#10096) 2023-10-10 12:48:51 -05:00
Steven Masley 69d13f1676
chore: add archive column to template versions (#10178)
* chore: add archive column to template versions
2023-10-10 10:52:42 -05:00
Spike Curtis b780bff429
chore: drop unused redirectToLoginOnMe parameter (#10164)
The parameter seems to be vestigial from an earlier use of the middleware, but is always set to `false` in the code.
2023-10-10 16:13:00 +04:00
Kyle Carberry 863c2e7b64
feat: allow storing extra oauth token properties in the database (#10152) 2023-10-09 18:49:30 -05:00
Colin Adler 36f3151b71
fix(enterprise/tailnet): properly detect legacy agents (#10083) 2023-10-06 16:49:26 +00:00
Spike Curtis 983e8c3ae8
feat: add API support for workspace automatic updates (#10099)
* Added automatic_updates to workspaces table

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

* Queries and API updates

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

* Golden files

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

* Enable automatic updates on autostart

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

* db migration number

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

* fix imports and ts mock

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

* code review updates

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-10-06 13:27:12 +04:00
Jon Ayers b32d79ef0b
fix: fix failed workspaces continuously auto-deleting (#10069)
- Fixes an issue where workspaces that are eligible for auto-deletion
  are retried every tick (1 minute) even if the previous deletion
  transition failed.

  The updated logic only attempts to delete workspaces that previously
  failed once a day (24 hours since last attempt).
2023-10-05 14:11:39 -05:00
Jon Ayers 91265678ad
chore: add auditing to workspace dormancy (#10070)
- Adds an audit log for workspaces automatically transitioned to the dormant
  state.
- Imposes a mininum of 1 minute on cleanup-related fields. This is to
  prevent accidental API misuse from resulting in catastrophe.
2023-10-05 13:41:07 -05:00
Steven Masley 5021e23105
chore: compute job status as column (#10024)
* chore: provisioner job status as column
* use provisioner job status for workspace searching
2023-10-04 20:57:46 -05:00
Kayla Washburn c194119689
chore: rename `AwaitTemplateVersionJobCompleted` and `AwaitWorkspaceBuildJobCompleted` (#10003) 2023-10-03 11:02:56 -06:00
Kyle Carberry f16eb1331f
chore: update multiple git providers docs (#10017)
* chore: update multiple git providers docs

* Improve var name

* Fix fmt
2023-10-03 15:27:02 +00:00
Cian Johnston e55c25e037
chore: enable exhaustruct linter for database param structs (#9995) 2023-10-03 09:23:45 +01:00
Kyle Carberry 8abca9bea7
chore: rename `git_auth` to `external_auth` in our schema (#9935)
* chore: rename `git_auth` to `external_auth` in our schema

We're changing Git auth to be external auth. It will support
any OAuth2 or OIDC provider.

To split up the larger change I want to contribute the schema
changes first, and I'll add the feature itself in another PR.

* Fix names

* Fix outdated view

* Rename some additional places

* Fix sort order

* Fix template versions auth route

* Fix types

* Fix dbauthz
2023-09-29 19:13:20 +00:00
Colin Adler 4da1223a80
fix: pass `OnSubscribe` to HA MultiAgent (#9947)
Fixes https://github.com/coder/coder/issues/9929
2023-09-29 13:37:17 -05:00
Steven Masley 2d1b35390e
chore: relax wsproxy version checking (#9796) 2023-09-27 19:34:55 +00:00
Marcin Tojek cb5f8df4c2
feat: expose application name via Appearance API (#9886) 2023-09-27 17:02:18 +02:00
Cian Johnston 93ef696b57
refactor(agent): add agenttest.New helper function (#9812)
* Adds agenttest.New() helper function
* Makes sure agent gets closed on test cleanup
* Makes sure you don't forget to set session token
* Sets the agent and client logger automatically
2023-09-26 12:05:19 +01:00
Cian Johnston 8d8402da00
fix(coderd/database): avoid clobbering workspace build state (#9826)
Fixes #9823.

- Decomposes UpdateWorkspaceBuildByID into UpdateWorkspaceBuildProvisionerStateByID and UpdateWorkspaceBuildDeadlineByID.
- Replaces existing invocations of UpdateWorkspaceBuildByID with the newer queries where applicable.
- Modifies GetActiveWorkspaceBuildsByTemplateID to not return incomplete workspace builds.
2023-09-22 16:22:07 +01:00
Spike Curtis e9077f3bd2
fix: use AlwaysEnable for licenses with all features (#9808)
* fix: use AlwaysEnable for licenses with all features

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

* use dbtime.Now() intead of time.Now()

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-22 05:02:28 +00:00
Colin Adler c900b5f8df
feat: add single tailnet support to pgcoord (#9351) 2023-09-21 14:30:48 -05:00
Steven Masley f89b68056d
chore: add debug information to wsproxy errors (#9683)
* chore: add debug information to wsproxy errors
* Use codersdk.ReadBodyAsError
2023-09-20 10:05:14 -05:00
Spike Curtis 375c70d141
feat: integrate Acquirer for provisioner jobs (#9717)
* chore: add Acquirer to provisionerdserver pkg

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

* code review improvements & fixes

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

* feat: integrate Acquirer for provisioner jobs

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

* Fix imports, whitespace

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

* provisionerdserver always closes; remove poll interval from playwright

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

* post jobs outside transactions

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

* graceful shutdown in test

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

* Mark AcquireJob deprecated

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

* Graceful shutdown on all provisionerd tests

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

* Deprecate, not remove CLI flags

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-19 10:25:57 +04:00
Cian Johnston 1df7589105
feat(coderd/database/dbtestutil): add ability to dump database on failure (#9704)
Adds dbtestutil.DumpOnFailure() to allow dumping the entire test database contents upon test failure.
This does nothing for dbfake currently.
2023-09-18 11:50:15 +01:00
Cian Johnston 9bcff30dee
fix(coderd/database): migrate workspaces.last_used_at to timestamptz (#9699) 2023-09-18 11:07:54 +01:00
Kayla Washburn efe804498b
feat: add quiet hours settings page (#9676) 2023-09-15 11:14:33 -06:00
Cian Johnston 72dff7f188
fix(enterprise/dbcrypt): do not skip deleted users when encrypting or deleting (#9694)
- Broadens scope of data generation in TestServerDBCrypt over all user login types, statuses, and deletion status.
- Adds support for specifying user status / user deletion status in dbgen
- Adds more comprehensive logging in TestServerDBCrypt upon test failure (to be generalized and expanded upon in a follow-up)
- Adds AllUserIDs query, updates dbcrypt to use this instead of GetUsers.
2023-09-15 15:09:40 +01:00
Cian Johnston 65db7a71b7
feat(coderd/database/dbtestutil): set default database timezone to non-UTC in unit tests (#9672)
- Adds dbtestutil.WithTimezone(tz) to allow setting the timezone for a test database.
- Modifies our test database setup code to pick a consistently weird timezone for the database.
- Adds the facility randtz.Name() to pick a random timezone which is consistent across subtests (via sync.Once).
- Adds a linter rule to warn against setting the test database timezone to UTC.
2023-09-15 09:01:32 +01:00
Ammar Bandukwala b63dfe7b75
perf(cli): optimize CPU consumption of help pages (#9607)
This change reduces the CPU consumption of --help by ~50%.

Also, this change removes ANSI escape codes from our golden files. I
don't think those were worth the inability to parallelize golden file tests and
global state fragility.
2023-09-14 19:48:29 -05:00
Colin Adler 38560dd922
chore: remove coder trace telemetry (#9677) 2023-09-14 02:20:28 -04:00
Spike Curtis 4ebf490d97
feat: add Acquirer to provisionerdserver pkg (#9658)
* chore: add Acquirer to provisionerdserver pkg

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

* code review improvements & fixes

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-13 16:36:43 +04:00
Ammar Bandukwala f703a5b34e
chore(cli): lighten flags on help page (#9606) 2023-09-08 13:43:56 -05:00
Ammar Bandukwala e361f1107b
feat(cli): colorize help page (#9589) 2023-09-08 18:21:33 +00:00
Spike Curtis 8d7eb1728c
fix: stop inserting provisioner daemons into the database (#9108)
Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-08 10:37:36 +00:00
Spike Curtis 11b6068112
feat: add support for networked provisioners (#9593)
* Refactor provisionerd to use interface to connect to provisioners

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

* feat: add support for networked provisioners

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

* fix token length and linting

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

---------

Signed-off-by: Spike Curtis <spike@coder.com>
2023-09-08 09:53:48 +00:00
Ammar Bandukwala dd97fe2bce
chore(cli): replace lipgloss with coder/pretty (#9564)
This change will improve over CLI performance and "snappiness" as well as
substantially reduce our test times. Preliminary benchmarks show
`coder server --help` times cut from 300ms to 120ms on my dogfood
instance.

The inefficiency of lipgloss disproportionately impacts our system, as all help
text for every command is generated whenever any command is invoked.

The `pretty` API could clean up a lot of the code (e.g., by replacing
complex string concatenations with Printf), but this commit is too
expansive as is so that work will be done in a follow up.
2023-09-07 16:28:22 -05:00
Cian Johnston 7d7c84bb4d
feat(coderd): connect dbcrypt package implementation (#9523)
See also: https://github.com/coder/coder/pull/9522

- Adds commands `server dbcrypt {rotate,decrypt,delete}` to re-encrypt, decrypt, or delete encrypted data, respectively.
- Plumbs through dbcrypt in enterprise/coderd (including unit tests).
- Adds documentation in admin/encryption.md.

This enables dbcrypt by default, but the feature is soft-enforced on supplying external token encryption keys. Without specifying any keys, encryption/decryption is a no-op.
2023-09-07 15:49:49 +01:00
Cian Johnston 7918e65510
feat(coderd): add dbcrypt package (#9522)
- Adds package enterprise/dbcrypt to implement database encryption/decryption
- Adds table dbcrypt_keys and associated queries
- Adds columns oauth_access_token_key_id and oauth_refresh_token_key_id
  to tables git_auth_links and user_links

Co-authored-by: Kyle Carberry <kyle@coder.com>
2023-09-06 12:06:26 +01:00
Steven Masley 630d125286
chore: fix typo in OpenID on cli help (#9535) 2023-09-05 18:37:21 +00:00
Steven Masley 58f7071569
fix: make 'NoRefresh' honor unlimited tokens in gitauth (#9472)
* chore: fix NoRefresh to honor unlimited tokens
* improve testing coverage of gitauth
* refactor rest of gitauth tests
2023-09-05 09:08:04 -05:00
Mathias Fredriksson 39e3b049a5
refactor(coderd/healthcheck): move derp report to derphealth package (#9506)
This change helps remove one indirect use of coderd/database in the slim
CLI.

No size change (yet).

Ref: #9380
2023-09-04 21:41:50 +03:00
Mathias Fredriksson d2115941b7
refactor(cli)!: remove reset-password from slim binary (#9520)
This is an alternative approach to #9519 and removes 2 MB instead of 1
MB (1.2 MB accounted for by embedded migration SQL files).

Combined with #9481, #9506, #9508, #9517, a total of 5 MB is removed.

Ref: #9380
2023-09-04 19:38:53 +03:00
Mathias Fredriksson ad23d33f28
refactor(coderd/schedule): move cron schedule to cron package (#9507)
This removes an indirect import of `coderd/database` from the CLI and
results in a logical separation between server related and generalized
schedule.

No size change (yet).

Ref: #9380
2023-09-04 16:48:25 +03:00
Kyle Carberry 05439d2c1b
fix: generate username with uuid to prevent collision (#9496)
See https://github.com/coder/coder/actions/runs/6052801777/job/16426982174
2023-09-03 18:02:28 +00:00