Commit Graph

547 Commits

Author SHA1 Message Date
8e684c8195 feat: run all migrations in a transaction (#10966)
Updates coder/customers#365

This PR updates our migration framework to run all migrations in a single transaction. This is the same behavior we had in v1 and ensures that failed migrations don't bring the whole deployment down. If a migration fails now, it will automatically be rolled back to the previous version, allowing the deployment to continue functioning.
2023-12-01 16:11:10 -06:00
13b89f79df feat: purge old provisioner daemons (#10949) 2023-12-01 12:43:05 +00:00
571d358e4b feat: add queries to clean lost connections in PGCoordinator (#10938)
Adds cleanup queries to clean out "lost" peer and tunnel state after 24 hours.  We leave this state in the database so that anything trying to connect to the peer can see that it was lost, but clean it up after 24 hours to ensure our table doesn't grow without bounds.
2023-12-01 10:02:30 +04:00
967db2801b chore: refactor ResolveAutostart tests to use dbfake (#10603) 2023-11-30 19:33:04 -06:00
2b71e38b31 feat: add status to tailnet mapping query (#10936)
Adds the `status` column to the mapping query so that we can add graceful disconnect logic around it
2023-11-29 16:53:01 +04:00
2dc565d5de chore: remove New----Builder from dbfake function names (#10882)
Drop "New" and "Builder" from the function names, in favor of the top-level resource created.  This shortens tests and gives a nice syntax.  Since everything is a builder, the prefix and suffix don't add much value and just make things harder to read.

I've also chosen to leave `Do()` as the function to insert into the database.  Even though it's a builder pattern, I fear `.Build()` might be confusing with Workspace Builds.  One other idea is `Insert()` but if we later add dbfake functions that update, this might be inconsistent.
2023-11-29 11:06:04 +04:00
48d69c9e60 fix: update autostart context to include querying users (#10929) 2023-11-28 17:56:49 -06:00
19b6d194fc feat: manage health settings using Coder API (#10861) 2023-11-28 18:15:17 +01:00
452668c893 chore: avoid dbmock test errors in dbgen (#10923) 2023-11-28 17:04:25 +00:00
14bd489af6 feat: add queries for PGCoord HTMLDebug (#10913)
Adds queries for implementing HTMLDebug on the new PGCoordinator
2023-11-28 20:19:32 +04:00
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
3a0a4ddfcd chore: convert dbfake.ProvisionerJobResources to builder (#10881)
Convert to builder for consistency with rest of the package.  This will make it easier to use, and means we can drop "Builder" from function arguments since they are all builders in the package.
2023-11-27 14:46:31 +04:00
4548ad7cef chore: remove dbfake.Workspace (#10880)
Remove dbfake.Workspace and use builder instead.
2023-11-27 14:39:16 +04:00
78283a7fb9 chore: remove dbfake.WorkspaceWithAgent (#10879)
Replace dbfake.WorkspaceWithAgent() with the builder pattern and remove this function.
2023-11-27 14:30:15 +04:00
82d5130b07 chore: convert dbfake.Workspace and .WorkspaceWithAgent to a builder pattern (#10878)
Converts dbfake Workspace and WorkspaceWithAgent to builder pattern.
2023-11-27 14:16:31 +04:00
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
a7c27cad26 feat: add database support for dismissed healthchecks (#10845) 2023-11-23 16:18:12 +00:00
b25e5dc90b chore: remove dbfake.WorkspaceBuild in favor of builder pattern (#10814)
I'd like to convert dbfake into a builder pattern to prevent a proliferation of XXXWithYYY methods.  This is one step of the way by removing the Non-builder function.
2023-11-22 13:04:58 +04:00
5d5b5aa074 chore: use dbfake for ssh tests rather than provisionerd (#10812)
Refactors SSH tests to skip provisionerd and instead use dbfake to insert workspaces and builds.  This should make tests faster and more reliable.

dbfake.WorkspaceBuild is refactored to use a "builder" pattern with "fluent" options, as the number of options and variants was starting to get out of hand.
2023-11-21 16:22:08 +04:00
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
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
290180b104 feat!: bump workspace activity by 1 hour (#10704)
Marked as a breaking change as the previous activity bump was always the TTL duration of the workspace/template.

This change is more cost conservative, only bumping by 1 hour for workspace activity. To accommodate wrap around, eg bumping a workspace into the next autostart, the deadline is bumped by the TTL if the workspace crosses the autostart threshold.

This is a niche case that is likely caused by an idle terminal making a workspace survive through a night. The next morning, the workspace will get activity bumped the default TTL on the autostart, being similar to as if the workspace was autostarted again.

In practice, a good way to avoid this is to set a max_deadline of <24hrs to avoid wrap around entirely.
2023-11-15 09:42:27 -06:00
1516c6636b feat: add SQL queries for v2 PG Coordinator (#10572)
re #10528

Adds SQL queries to support Tailnet v2 API in the PG Coordinator
2023-11-15 10:13:27 +04:00
75ab16d19a fix: prevent db deadlock when workspaces go dormant (#10618) 2023-11-13 13:40:20 -06:00
e23873ff8f feat: add endpoint for resolving autostart status (#10507) 2023-11-08 23:24:56 -06:00
0a550815e9 feat: expose app insights as Prometheus metrics (#10346) 2023-11-07 17:14:59 +01:00
bb5acb0332 fix: allow users to use quiet hours endpoint (#10547) 2023-11-06 13:16:50 +00:00
23f02651f9 chore: migrate CLI tests to use dbfake (#10500) 2023-11-03 12:22:32 -05:00
839a16e299 feat: add dbfake for workspace builds and resources (#10426)
* feat: add dbfakedata for workspace builds and resources

This creates `coderdtest.NewWithDatabase` and adds a series of
helper functions to `dbfake` that insert structured fake data
for resources into the database.

It allows us to remove provisionerd from a significant amount of
tests which should speed them up and reduce flakes.

* Rename dbfakedata to dbfake

* Migrate workspaceagents_test.go to use the new dbfake

* Migrate agent_test.go to use the new fakes

* Fix comments
2023-11-02 17:15:07 +00:00
cac29e0b4d feat: add tables for PGCoordinator v2 (#10442)
Adds tables for a simplified PG Coordinator that only considers Peers and Tunnels, rather than agent/client distinctions we have today.
2023-11-01 16:30:09 +04:00
a7c671ca07 feat: add workspace agent APIVersion (#10419)
Fixes #10339
2023-10-31 10:08:43 +04:00
5abfe5afd0 chore: rename dbfake to dbmem (#10432) 2023-10-30 17:42:20 +00:00
7a8da08124 feat: add api_version column to workspace_agents (#10418)
Adds api_version to workspace_agents table

Part of #10399
2023-10-30 21:30:49 +04:00
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
c4f590581e feat: expose template insights as Prometheus metrics (#10325) 2023-10-19 08:45:12 +00:00
997493d4ae feat: add template setting to require active template version (#10277) 2023-10-18 17:07:21 -05:00
1ad998ee3a fix: add requester IP to workspace build audit logs (#10242) 2023-10-18 15:08:02 -05:00
619df23ad1 chore: fix linting issues and generated files (#10317) 2023-10-17 14:41:35 -06:00
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
7eeba15d16 feat(coderd): add support for sending batched agent metadata (#10223)
Part of #9782
2023-10-13 16:37:55 +03:00
d56f49f619 fix(coderd): make activitybump aware of default template ttl (#10253)
The refactored ActivityBump query did not take into account the
template-level TTL, resulting in potentially incorrect bump
amounts for workspaces that have both a user-defined and template-
defined TTL that differ.

This change is ported over from PR#10035 to reduce the overall
size of that PR.

Also includes a drive-by unit test in autobuild for checking template autostop/TTL.

Co-authored-by: Dean Sheather <dean@deansheather.com>
2023-10-13 13:53:02 +01:00
782c22a293 test(coderd/database/dbtestutil): allow access to *sql.DB (#10238) 2023-10-12 15:07:16 +03:00
1e950fa9a8 feat: archive template versions to hide them from the ui (#10179)
* api + cli implementation
2023-10-11 09:26:22 -05:00
ec9b480ac0 fix: use is-dormant instead of dormant_at (#10191) 2023-10-10 19:00:09 -05:00
69d13f1676 chore: add archive column to template versions (#10178)
* chore: add archive column to template versions
2023-10-10 10:52:42 -05:00
863c2e7b64 feat: allow storing extra oauth token properties in the database (#10152) 2023-10-09 18:49:30 -05:00
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
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
888b97fd86 chore: use JobStatus computed from the db (#10079)
Fixes `main`
2023-10-05 18:25:06 +00:00
ab9276bd08 feat: modify workspace_agent_stats index (#10073) 2023-10-05 14:49:08 +02:00