Commit Graph

945 Commits

Author SHA1 Message Date
9dd9fedc12 Implement strict prebuilds eligibility
See https://github.com/coder/internal/issues/372

Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-18 09:39:04 +00:00
e9fdd86c45 Merge branch 'jjs/presets' of github.com:/coder/coder into dk/prebuilds 2025-02-18 08:32:25 +00:00
77306f3de1 feat(coderd): add filters and fix template for provisioner daemons (#16558)
This change adds provisioner daemon ID filter to the provisioner daemons
endpoint, and also implements the limiting to 50 results.

Test coverage is greatly improved and template information for jobs
associated to the daemon was also fixed.

Updates #15084
Updates #15192
Related #16532
2025-02-14 17:26:46 +02:00
c3f67f8169 Claim prebuild by preset ID
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 13:38:17 +00:00
2b296244a5 Taking presets into account when provisioning prebuilds
Fixing migrations

Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:54 +00:00
b60f2f66c6 Persisting presets defined with prebuilds to DB
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:11 +00:00
7e1abd141c Claim prebuild and rename
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:08 +00:00
eebbeb54bc Discrimination between "outdated" and "extraneous" prebuilds, hardening reconciliation
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:08 +00:00
fdabb8cf07 Very basic prebuild reassignment
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:08 +00:00
9d5c6633de Generating short ID for prebuilds
Also dropped unnecessary CASTs

Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:07 +00:00
c227bb842f Control loop now handles reconciliation of multiple prebuilds-configured template versions
Correctly calculates extraneous prebuilds and returns offending prebuild IDs

Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:07 +00:00
b7c43f663e Fixed bug in state query relating to multiple template versions & workspaces in partially-deleted statuses
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:06 +00:00
41a9778af0 Improving control loop resilience, fixing calculations
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:06 +00:00
cffd63450d Add prebuilds user to default org
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:05 +00:00
815ecbc74b Specify progress type
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:05 +00:00
981f61e272 Incorporate in-progress jobs into state calculation
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:04 +00:00
4b5555e918 Preset tables, latest workspace view, state logic improved
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:04 +00:00
281a76aad9 WIP on control loop
Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:04 +00:00
1150e206e0 Migrations
Exclude system users from users.sql queries

Signed-off-by: Danny Kopping <danny@coder.com>
2025-02-14 12:17:01 +00:00
bc609d0056 feat: integrate agentAPI with resources monitoring logic (#16438)
As part of the new resources monitoring logic - more specifically for
OOM & OOD Notifications , we need to update the AgentAPI , and the
agents logic.

This PR aims to do it, and more specifically :  
We are updating the AgentAPI & TailnetAPI to version 24 to add two new
methods in the AgentAPI :
- One method to fetch the resources monitoring configuration
- One method to push the datapoints for the resources monitoring.

Also, this PR adds a new logic on the agent side, with a routine running
and ticking - fetching the resources usage each time , but also storing
it in a FIFO like queue.

Finally, this PR fixes a problem we had with RBAC logic on the resources
monitoring model, applying the same logic than we have for similar
entities.
2025-02-14 10:28:15 +01:00
e38bd27183 feat(coderd): add support for provisioner job id and tag filter (#16556)
This change adds to new filters to the provisionerjobs endpoint, id
(array) and tags (map).

Updates #15084
Updates #15192
Related #16532
2025-02-13 18:24:27 +02:00
71cbf735e5 feat(coderd): add support for presets to the coder API (#16526)
This pull request builds on the existing migrations and queries to add
support for presets to the coder API.
2025-02-12 14:41:14 +02:00
e85da8b02b chore: return template data for provisioner daemons (#16514)
Return template data in provisioner jobs to be displayed in the
provisioners page.
2025-02-11 14:22:34 -03:00
34b46f9205 feat(coderd/database): add support for presets (#16509)
This pull requests adds the necessary migrations and queries to support
presets within the coderd database. Future PRs will build functionality
to the provisioners and the frontend.
2025-02-11 13:55:09 +02:00
e9b3561677 refactor: return template_icon and make metadata required (#16496) 2025-02-10 10:00:34 -03:00
b04d883348 feat: add provisioner job metadata (#16454)
This change adds metadata to provisioner jobs to help with rendering
related tempaltes and workspaces in the UI.

Updates #15084
2025-02-06 16:19:20 +02:00
dbad69dbd9 chore: add workspace oom/ood notification templates (#16250) 2025-02-04 19:25:18 +00:00
7cbd77fd94 feat: improve resources_monitoring for OOM & OOD monitoring (#16241)
As requested for [this
issue](https://github.com/coder/internal/issues/245) we need to have a
new resource `resources_monitoring` in the agent.

It needs to be parsed from the provisioner and inserted into a new db
table.
2025-02-04 18:45:33 +01:00
2ace044e0b chore: track the first time html is served in telemetry (#16334)
Addresses https://github.com/coder/nexus/issues/175.

## Changes

- Adds the `telemetry_items` database table. It's a key value store for
telemetry events that don't fit any other database tables.
- Adds a telemetry report when HTML is served for the first time in
`site.go`.
2025-01-31 13:55:46 +01:00
6ea5c6f0ef fix: show user-auth provisioners for all organizations (#16350) 2025-01-30 14:08:27 -07:00
b77b5432c6 test(coderd/database/pubsub): ensure db closure on unhappy paths (#16327) 2025-01-29 14:47:38 +00:00
c069563af1 test: fix use of t.Logf where t.Log would suffice (#16328) 2025-01-29 14:35:04 +00:00
1336925c9f feat(flake.nix): switch dogfood dev image to buildNixShellImage from dockerTools (#16223)
Replace Depot build action with Nix for Nix dogfood image builds

The dogfood Nix image is now built using Nix's native container tooling instead of Depot. This change:

- Adds Nix setup steps to the GitHub Actions workflow
- Removes the Dockerfile.nix in favor of a Nix-native container build
- Updates the flake.nix to support building Docker images
- Introduces a hash file to track Nix-related changes
- Updates the vendorHash for Go dependencies

Change-Id: I4e011fe3a19d9a1375fbfd5223c910e59d66a5d9
Signed-off-by: Thomas Kosiewski <tk@coder.com>
2025-01-28 16:38:37 +01:00
75c899ff71 feat(cli): add provisioner job cancel command (#16252)
Fixes #16117
Updates #15084
2025-01-27 16:26:56 +00:00
f27e73d21a chore(coderd/database/gen/dump): add optional DB_DUMP_CONNECTION_URL (#16243) 2025-01-23 18:53:24 +02:00
5762d8add4 fix: return only the first workspace agent script timing per script (#16203)
Fixes https://github.com/coder/coder/issues/16124

If a workspace agent crashes, it is possible for any startup scripts to
be ran again. This PR makes it so that the
`GetWorkspaceAgentScriptTimingsByBuildID` query only returns the first
timing recorded per-script.
2025-01-21 11:54:43 +00:00
4d9dd0aa94 test(coderd/database/awsiamrds): fix unclosed pubsub (#16202) 2025-01-20 17:25:31 +00:00
c0db364f3f feat(cli): add provisioner list and provisioner jobs list (#16030) 2025-01-20 17:24:22 +00:00
3864c7e3b0 feat(coderd): add endpoint to list provisioner jobs (#16029)
Closes #15190
Updates #15084
2025-01-20 11:18:53 +02:00
0e8ef09415 test(coderd/database/dbauthz): compare outputs with cmp (#16161) 2025-01-20 11:12:04 +02:00
f34e6fd92c chore: implement 'use' verb to template object, read has less scope now (#16075)
Template `use` is now a verb.
- Template admins can `use` all templates (org template admins same in
org)
- Members get the `use` perm from the `everyone` group in the
`group_acl`.
2025-01-17 11:55:41 -06:00
50bf5ca8fe fix(coderd/database): aggregate user engagement statistics by interval (#16150)
This PR addresses the TODO comment here:

https://github.com/coder/coder/pull/16134/files#diff-1844f895bb005f036da11d800fe2a76b54bfddd481c5d8cb15f210c64679caa5R47

The backend now backfills entries for dates with no status changes.
2025-01-16 17:34:53 +02:00
ab880904e2 feat(coderd/database): order user engagement statistics by date (#16142)
This PR orders user engagement statistics by date as mentioned
[here](https://github.com/coder/coder/pull/16134/files#diff-1844f895bb005f036da11d800fe2a76b54bfddd481c5d8cb15f210c64679caa5R47)
2025-01-15 13:19:25 +02:00
071bb26018 feat(coderd): add endpoint to list provisioner daemons (#16028)
Updates #15190
Updates #15084
Supersedes #15940
2025-01-14 16:40:26 +00:00
009069cd47 feat: allow notification templates to be disabled by default (#16093)
Change as part of https://github.com/coder/coder/pull/16071

It has been decided that we want to be able to have some notification
templates be disabled _by default_
https://github.com/coder/coder/pull/16071#issuecomment-2580757061.

This adds a new column (`enabled_by_default`) to
`notification_templates` that defaults to `TRUE`. It also modifies the
`inhibit_enqueue_if_disabled` function to reject notifications for
templates that have `enabled_by_default = FALSE` with the user not
explicitly enabling it.
2025-01-13 15:01:47 +00:00
4543b21b7c feat(coderd/database): track user status changes over time (#16019)
RE: https://github.com/coder/coder/issues/15740,
https://github.com/coder/coder/issues/15297

In order to add a graph to the coder frontend to show user status over
time as an indicator of license usage, this PR adds the following:

* a new `api.insightsUserStatusCountsOverTime` endpoint to the API
* which calls a new `GetUserStatusCountsOverTime` query from postgres
* which relies on two new tables `user_status_changes` and
`user_deleted`
* which are populated by a new trigger and function that tracks updates
to the users table

The chart itself will be added in a subsequent PR

---------

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2025-01-13 13:08:16 +02:00
7b88776403 chore(testutil): add testutil.GoleakOptions (#16070)
- Adds `testutil.GoleakOptions` and consolidates existing options to
this location
- Pre-emptively adds required ignore for this Dependabot PR to pass CI
https://github.com/coder/coder/pull/16066
2025-01-08 15:38:37 +00:00
106b1cd3bc chore: convert dbauthz tests to also run with Postgres (#15862)
Another PR to address https://github.com/coder/coder/issues/15109.

- adds the DisableForeignKeysAndTriggers utility, which simplifies
converting tests from in-mem to postgres
- converts the dbauthz test suite to pass on both the in-mem db and
Postgres
2025-01-08 16:22:51 +01:00
289338f19e feat(site): connect open_in parameter (#16036)
Second step to resolve [open_in
issue](https://github.com/coder/terraform-provider-coder/issues/297)

This PR improves the way the open_in parameter is forwarded across the
code, changing the last `string` to const everywhere.

Also make sure it is available and forwarded up to the `CreateLink`
component.
2025-01-07 18:08:03 +01:00
a7ed977ba9 chore: prevent db migrations from running on all cli commands (#15980) 2025-01-03 11:15:35 -06:00