Commit Graph

56 Commits

Author SHA1 Message Date
Kyle Carberry b0fe9bcdd1
chore: Upgrade to Go 1.19 (#3617)
This is required as part of #3505.
2022-08-21 22:32:53 +00:00
Mathias Fredriksson 6a0f8ae9cc
fix: Add `SIGHUP` and `SIGTERM` handling to `coder server` (#3543)
* fix: Add `SIGHUP` and `SIGTERM` handling to `coder server`

To prevent additional signals from aborting program execution, signal
handling was moved to the beginning of the main function, this ensures
that signals stays registered for the entire shutdown procedure.

Fixes #1529
2022-08-18 16:25:32 +03:00
Kyle Carberry d6d9cf9b30
fix: Downgrade embedded PostgreSQL (#3453)
This was causing a new data path to occur, which broke existing installs.
It needs to use the same path and upgrade instead.
2022-08-10 10:08:24 -05:00
Kyle Carberry fd73d6dd0d
fix: Reduce variables needed for Docker template (#3442)
* fix: Reduce variables needed for Docker template

This should make initial setup a bit simpler!

* Fix for M2 Macbooks

PostgreSQL 13 doesn't support the M series architecture.

* Fix name <-> id swap

* Update Docker provider to remove host requirement

Co-authored-by: Kyle Carberry <kyle@air.local>
2022-08-10 14:45:05 +00:00
Kyle Carberry f62e1ede77
feat: Add support for GitHub Enterprise authentication (#3422)
This was manually tested with GitHub Enterprise v3.6.0-rc1.
2022-08-08 20:49:51 -05:00
Kyle Carberry 7bdb8ff9cf
feat: Add workspace metrics export to Prometheus (#3421)
This adds workspace totals indexed by status. It could be any
codersdk.ProvisionerJobStatus.
2022-08-09 01:08:42 +00:00
Kyle Carberry 3279504cbe
feat: Add active users prometheus metric (#3406)
This  allows deployments using our Prometheus export t determine
the number of active users in the past hour.

The interval is an hour to align with API key last used refresh times.

SSH connections poll to check shutdown time, so this will be accurate
even on long-running connections without dashboard requests.
2022-08-08 10:09:46 -05:00
Kyle Carberry 3d0febdd90
feat: Add OIDC authentication (#3314)
* feat: Add OIDC authentication

* Extract username into a separate package and add OIDC tests

* Add test case for invalid tokens

* Add test case for username as email

* Add OIDC to the frontend

* Improve comments from self-review

* Add authentication docs

* Add telemetry

* Update docs/install/auth.md

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>

* Update docs/install/auth.md

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>

* Remove username package

Co-authored-by: Ammar Bandukwala <ammar@ammar.io>
2022-07-31 23:05:35 -05:00
Jon Ayers 8b17bf98ea
fix: prepend scheme to access url (#3317)
- Problems can arise spawning workspaces if a schemeless URL is passed
  as the access URL.

  If an access url is detected to not have an "http" or "https" scheme
  then it is prepended with "https". If the hostname is detected
  to be a loopback device then "http" is preferred.
2022-07-31 17:49:25 -05:00
Mathias Fredriksson d27076cac7
fix: Improve `coder server` shutdown procedure (#3246)
* fix: Improve `coder server` shutdown procedure

This commit improves the `coder server` shutdown procedure so that all
triggers for shutdown do so in a graceful way without skipping any
steps.

We also improve cancellation and shutdown of services by ensuring
resources are cleaned up at the end.

Notable changes:
- We wrap `cmd.Context()` to allow us to control cancellation better
- We attempt graceful shutdown of the http server (`server.Shutdown`)
  because it's less abrupt (compared to `shutdownConns`)
- All exit paths share the same shutdown procedure (except for early
  exit)
- `provisionerd`s are now shutdown concurrently instead of one at a
  time, the also now get a new context for shutdown because
  `cmd.Context()` may be cancelled
- Resources created by `newProvisionerDaemon` are cleaned up
- Lifecycle `Executor` exits its goroutine on context cancellation

Fixes #3245
2022-07-27 18:21:21 +03:00
Mathias Fredriksson 159137dc10
fix: Use stdin/out defined in command (#3199) 2022-07-26 17:23:32 +03:00
Mathias Fredriksson d1d89210b8
fix: Disable telemetry by default in tests (#3200)
I also noticed we don't have `goleak` enabled for CLI tests, this commit
adds it, but commented out. The reason being that we're nowhere near
being able to enable it yet.

Co-authored-by: Cian Johnston <cian@coder.com>
2022-07-26 16:27:48 +03:00
Kyle Carberry fd4954b4e5
fix: Use membership endpoint to ensure user exists in team (#3129)
This was using the incorrect GitHub endpoint prior, which fetched a team
by slug. Any user in a GitHub organization can view all teams, so this
didn't block signups like intended.

I've verified this API returns an error when the calling user is not a
member  of the team requested.

Fixes #3105.
2022-07-22 13:54:08 -05:00
Colin Adler 1033e02d79
feat: add `coder server postgres-builtin-serve` to run the built-in DB (#2997) 2022-07-14 21:51:44 +00:00
Kyle Carberry 8b76e40629
fix: Fetch GitHub teams by name for performance (#2955)
In large organizations with thousands of teams, looping took >5s.
This fetches organizations by team name, which should be very fast!
2022-07-13 00:45:43 +00:00
Kyle Carberry 5ee112bc00
fix: Fetch all GitHub teams on login (#2951)
This wasn't looping prior, so organizations with >100 teams
couldn't login. Contributes to #2848.
2022-07-12 23:06:27 +00:00
Kyle Carberry dff6e97f83
feat: Add allowlist of GitHub teams for OAuth (#2849)
Fixes #2848.
2022-07-08 21:37:18 -05:00
Abhineet Jain c6b1daabc5
feat: Download default terraform version when minor version mismatches (#1775) 2022-06-22 23:11:52 +00:00
Mathias Fredriksson e2785ada5e
feat: Compress and extract slim binaries with zstd (#2533)
Fixes #2202

Co-authored-by: Dean Sheather <dean@deansheather.com>
2022-06-21 19:53:36 +03:00
Kyle Carberry 7cce7a9c69
test: Write URL after signal listen to fix flake (#2456)
The URL could be read before the signal was listening, causing
this test to flake: https://github.com/coder/coder/runs/6936820170?check_suite_focus=true
2022-06-17 14:16:45 +00:00
Kyle Carberry f09ab03baf
fix: Add flag to toggle telemetry (#2455)
* fix: Add flag to toggle telemetry

This allows users to entirely disable tracking from Coder!
Telemetry is enabled by default, so this is opt-out.

* Update cli/server.go

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>

Co-authored-by: Mathias Fredriksson <mafredri@gmail.com>
2022-06-17 14:02:44 +00:00
Kyle Carberry 4cce969018
feat: Add anonymized telemetry to report product usage (#2273)
* feat: Add anonymized telemetry to report product usage

This adds a background service to report telemetry to a Coder
server for usage data. There will be realtime event data sent
in the future, but for now usage will report on a CRON.

* Fix flake and requested changes

* Add reporting options for setup

* Add reporting for workspaces

* Add resources as they are reported

* Track API key usage

* Ensure telemetry is tracked prior to exit
2022-06-17 00:26:40 -05:00
Kyle Carberry 024ab6df57
fix: Use in-memory filesystem for echo provisioner tests (#2408)
* fix: Use in-memory filesystem for echo provisioner tests

This should reduce IO in CI to shave some time off tests!

* test: Increase timeouts to reduce flakes

It's difficult to understand what's timing out due to a lock
vs. taking a long time. This should help resolve! 🕵️
2022-06-16 15:09:22 +00:00
Kyle Carberry ccd061652b
feat: Add built-in PostgreSQL for simple production setup (#2345)
* feat: Add built-in PostgreSQL for simple production setup

Fixes #2321.

* Use fork of embedded-postgres for cache path
2022-06-15 16:02:18 -05:00
Jon Ayers 6cf483bf37
fix: allow server startup without tunnel (#2380)
- Previously, specifying 'no' to the tunnel prompt just killed
  the process. It should be possible to start the server without
  a tunnel and not have the process killed.
2022-06-15 12:54:01 -05:00
Colin Adler f562b74fa1
feat: use custom wireguard reverse proxy for dev tunnel (#1975) 2022-06-10 13:38:11 -05:00
David Wahler 71fd19631a
feat: Warn on coderd startup if access URL is localhost (#2248) 2022-06-10 13:35:51 -05:00
Mathias Fredriksson 0260e39d11
fix: Accept CODER_CACHE_DIRECTORY with CACHE_DIRECTORY fallback (#2236)
Fixes #2199
2022-06-10 17:00:00 +03:00
Kyle Carberry 43f622a52d
fix: Remove unused workspace routes in favor of list with filter (#2038)
* fix: Remove unused workspace routes in favor of list with filter

This consolidates the workspace routes into a single place.
It allows users to fetch a workspace by their username and
workspace name, which will be used by the frontend for routing.

* Fix RBAC

* Fix CLI usages
2022-06-03 14:36:08 -05:00
Cian Johnston 7b40c692eb
fix: coderd: dev mode should show verbose output by default (#1898)
* check buildinfo for devel prerelease tag and show verbose output if so
2022-06-01 11:00:42 +01:00
Garrett Delfosse 8a5277e291
fix: restore previous session on coder server --dev (#1821) 2022-05-27 17:02:02 +00:00
Kyle Carberry 31b819e83f
chore: Remove interface from coderd and lift API surface (#1772)
Abstracting coderd into an interface added misdirection because
the interface was never intended to be fulfilled outside of a single
implementation.

This lifts the abstraction, and attaches all handlers to a root struct
named `*coderd.API`.
2022-05-26 03:14:08 +00:00
Garrett Delfosse 0effb71f43
feat: add tracing for sql (#1610) 2022-05-20 10:51:06 -05:00
Cian Johnston 52230fab56
feat: make default autobuild poll intervals configurable (#1618)
* feat: make default poll intervals for autobuild and ssh ttl polling configurable
2022-05-20 10:57:02 +00:00
Spike Curtis d1817310a1
fix build and lint (#1613)
Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-19 23:28:29 +00:00
Spike Curtis 1871b09697
feat: in-process provisionerd connection (#1568)
* in-process provisionerd connection

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

* disable lint for server.go/newProvisionerDaemon

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-19 17:47:45 -05:00
Garrett Delfosse 376c6819e0
feat: Move from datadog to generic otel (#1567) 2022-05-19 17:43:07 -05:00
Steven Masley 6c1117094d
chore: Force codersdk to not import anything from database (#1576)
* chore: Force codersdk to not import anything from database (linter rule)
* chore: Move all database types in codersdk out
2022-05-19 13:04:44 -05:00
Kyle Carberry 7b5300d0cc
fix: Improve develop script to start tunnel by default (#1409)
This allows for running the development script to actually
build workspaces!
2022-05-12 12:37:51 -05:00
Cian Johnston f4da5d4f3a
feat: add lifecycle.Executor to manage autostart and autostop (#1183)
This PR adds a package lifecycle and an Executor implementation that attempts to schedule a build of workspaces with autostart configured.

- lifecycle.Executor takes a chan time.Time in its constructor (e.g. time.Tick(time.Minute))
- Whenever a value is received from this channel, it executes one iteration of looping through the workspaces and triggering lifecycle operations.
- When the context passed to the executor is Done, it exits.
- Only workspaces that meet the following criteria will have a lifecycle operation applied to them:
  - Workspace has a valid and non-empty autostart or autostop schedule (either)
  - Workspace's last build was successful
- The following transitions will be applied depending on the current workspace state:
  - If the workspace is currently running, it will be stopped.
  - If the workspace is currently stopped, it will be started.
  - Otherwise, nothing will be done.
- Workspace builds will be created with the same parameters and template version as the last successful build (for example, template version)
2022-05-11 23:03:02 +01:00
Kyle Carberry e6f1ce1fb2
fix: Allow coderd to exit on error channel (#1355)
coderd would fail silently if this was called, because connections
would never drain. HashiCorp's hc-install package broke today,
and we couldn't notice because this was hanging!
2022-05-10 02:19:20 +00:00
Kyle Carberry ddb9631d7a
fix: Group subcommands for cognitive ease (#1351) 2022-05-09 17:42:02 -05:00
Spike Curtis ad8d9dd71a
feat: make it harder to skip graceful shutdown accidentally (#1327)
* feat: make it harder to skip graceful shutdown accidentally

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

* fixup: don't use unbuffered signal channel

Signed-off-by: Spike Curtis <spike@coder.com>
2022-05-06 13:45:18 -07:00
Colin Adler 9d2e788fea
feat: allow verbose logging in `coder server` (#1280) 2022-05-03 16:13:30 -05:00
Colin Adler 0f9e30e54f
fix: use correct enable bool for pprof (#1279) 2022-05-03 19:54:10 +00:00
Colin Adler 55ad97bbd7
feat: add pprof and prometheus metrics to `coder server` (#1266) 2022-05-03 12:48:02 +00:00
Kyle Carberry a79aa6418a
fix: Use `cliui.WorkspaceBuild` to prevent cancel of builds jobs (#1255)
Build jobs cannot gracefully terminate because Terraform generally
cannot gracefully terminate.
2022-05-02 10:20:47 -05:00
Kyle Carberry 9b37a0de31
fix: Disable ErrorLog in http.Server (#1244)
Vault does similarly: e2490059d0/command/server.go (L2714)

These messages have primarily been noise.
2022-05-01 20:31:12 -05:00
Mathias Fredriksson afc43fe95f
feat: Generate random admin user password in dev mode (#1207)
* feat: Generate random admin user password in dev mode

* Add dev mode test with email/pass from env

* Set email/pass for playwright e2e test via cli flags
2022-04-28 19:13:44 +03:00
Mathias Fredriksson 8661f92a10
feat: Output username and password for `code server --dev` (#1193)
Fixes #825
2022-04-27 17:59:37 +03:00