Commit Graph

177 Commits

Author SHA1 Message Date
Kyle Carberry 2ba4a62a0d feat: Add high availability for multiple replicas (#4555)
* feat: HA tailnet coordinator

* fixup! feat: HA tailnet coordinator

* fixup! feat: HA tailnet coordinator

* remove printlns

* close all connections on coordinator

* impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* fixup! impelement high availability feature

* Add replicas

* Add DERP meshing to arbitrary addresses

* Move packages to highavailability folder

* Move coordinator to high availability package

* Add flags for HA

* Rename to replicasync

* Denest packages for replicas

* Add test for multiple replicas

* Fix coordination test

* Add HA to the helm chart

* Rename function pointer

* Add warnings for HA

* Add the ability to block endpoints

* Add flag to disable P2P connections

* Wow, I made the tests pass

* Add replicas endpoint

* Ensure close kills replica

* Update sql

* Add database latency to high availability

* Pipe TLS to DERP mesh

* Fix DERP mesh with TLS

* Add tests for TLS

* Fix replica sync TLS

* Fix RootCA for replica meshing

* Remove ID from replicasync

* Fix getting certificates for meshing

* Remove excessive locking

* Fix linting

* Store mesh key in the database

* Fix replica key for tests

* Fix types gen

* Fix unlocking unlocked

* Fix race in tests

* Update enterprise/derpmesh/derpmesh.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

* Rename to syncReplicas

* Reuse http client

* Delete old replicas on a CRON

* Fix race condition in connection tests

* Fix linting

* Fix nil type

* Move pubsub to in-memory for twenty test

* Add comment for configuration tweaking

* Fix leak with transport

* Fix close leak in derpmesh

* Fix race when creating server

* Remove handler update

* Skip test on Windows

* Fix DERP mesh test

* Wrap HTTP handler replacement in mutex

* Fix error message for relay

* Fix API handler for normal tests

* Fix speedtest

* Fix replica resend

* Fix derpmesh send

* Ping async

* Increase wait time of template version jobd

* Fix race when closing replica sync

* Add name to client

* Log the derpmap being used

* Don't connect if DERP is empty

* Improve agent coordinator logging

* Fix lock in coordinator

* Fix relay addr

* Fix race when updating durations

* Fix client publish race

* Run pubsub loop in a queue

* Store agent nodes in order

* Fix coordinator locking

* Check for closed pipe

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-10-17 13:43:30 +00:00
Ammar Bandukwala dc3519e973 Support all transitions in build progress bar (#4575)
* Use null types instead of -1 for simplicity

* Fix pgcrypto bug in migration 59

* Add stories

* Fix visual stutter
2022-10-16 23:34:03 -05:00
Ammar Bandukwala e456799f1a Add template build time stats (#4557)
- Expose time in Template pages
- Show progress bar when building a workspace
2022-10-15 20:36:50 +00:00
Colin Adler 7ec88bf841 feat: audit git ssh key regeneration (#4544) 2022-10-14 16:25:46 -05:00
Dean Sheather d898737d6d feat: app sharing (now open source!) (#4378) 2022-10-15 02:46:38 +10:00
Jon Ayers 4e57b9fbdc fix: allow regular users to push files (#4500)
- As part of merging support for Template RBAC
  and user groups a permission check on reading files
  was relaxed.

  With the addition of admin roles on individual templates, regular
  users are now able to push template versions if they have
  inherited the 'admin' role for a template. In order to do so
  they need to be able to create and read their own files. Since
  collisions on hash in the past were ignored, this means that a regular user
  who pushes a template version with a file hash that collides with
  an existing hash will not be able to read the file (since it belongs to
  another user).

  This commit fixes the underlying problem which was that
  the files table had a primary key on the 'hash' column.
  This was not a problem at the time because only template
  admins and other users with similar elevated roles were
  able to read all files regardless of ownership. To fix this
  a new column and primary key 'id' has been introduced to the files
  table. The unique constraint has been updated to be hash+created_by.
  Tables (provisioner_jobs) that referenced files.hash have been updated
  to reference files.id. Relevant API endpoints have also been updated.
2022-10-13 18:02:52 -05:00
Colin Adler a55186cd02 fix(database): remove usage of String() for comparing UUIDs (#4547) 2022-10-13 22:38:30 +00:00
Garrett Delfosse 459ee4e66a feat: add pagination to getWorkspaces (#4521) 2022-10-13 12:41:13 -04:00
Kyle Carberry 0d0ea981da fix: Filter by deleted when querying workspaces (#4512)
Fixes #4508.
2022-10-12 14:53:03 -05:00
Presley Pizzo 62357084ba feat: filter for running workspaces (#4157)
* Refactor workspaces xservice

* Remove layout comment

* Format

* Add comments

* Add running workspaces filter to frontend

* Start on backend - add status to filter

* Update sql and add test - wip

* Attempt to unconvert status for easier querying

* Fix syntax

* Join jobs table, untested

* sql

* Add Status to GetAuthorizedWorkspaces

* Update job tests to have canceled time

* fmt

* add status filter to database fake

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-10-11 13:50:41 -04:00
Jon Ayers 3120c94c22 feat: add template RBAC/groups (#4235) 2022-10-10 15:37:06 -05:00
Kyle Carberry daa34cf7b8 fix: Return deleted users when fetching workspace builds (#4441)
Fixes #4359.
2022-10-10 18:03:54 +00:00
Ammar Bandukwala eefc26c108 Hide build logs older than 30 days (#4436) 2022-10-09 20:01:18 +00:00
Garrett Delfosse f5df54831a feat: tokens (#4380) 2022-10-06 19:02:27 +00:00
Dean Sheather 3b15f13ae4 fix: fix apps being unavailable until rebuild (#4395) 2022-10-06 10:23:55 -05:00
Dean Sheather 2a66395fb7 feat: use app wildcards for apps if configured (#4263)
* feat: use app wildcards for apps if configured

* feat: relative_path -> subdomain

- rename relative_path -> subdomain when referring to apps
    - migrate workspace_apps.relative_path to workspace_apps.subdomain
- upgrade coder/coder terraform module to 0.5.0
2022-10-05 19:23:01 +00:00
Steven Masley cd4ab97efa feat: Convert rego queries into SQL clauses (#4225)
* feat: Convert rego queries into SQL clauses

* Fix postgres quotes to single quotes

* Ensure all test cases can compile into SQL clauses

* Do not export extra types

* Add custom query with rbac filter

* First draft of a custom authorized db call

* Add comments + tests

* Support better regex style matching for variables

* Handle jsonb arrays

* Remove auth call on workspaces

* Fix PG endpoints test

* Match psql implementation

* Add some comments

* Remove unused argument

* Add query name for tracking

* Handle nested types

This solves it without proper types in our AST.
Might bite the bullet and implement some better types

* Add comment

* Renaming function call to GetAuthorizedWorkspaces
2022-10-04 11:35:33 -04:00
Kyle Carberry df2649ed2a fix: Test flake in TestWorkspaceStatus (#4333)
This also changes the status to be on the workspace build, since
that's where the true value is calculated. This exposed a bug where
jobs could never enter the canceled state unless fetched by a
provisioner daemon, which was nice to fix!

See: https://github.com/coder/coder/actions/runs/3175304200/jobs/5173479506
2022-10-03 11:43:11 -05:00
Garrett Delfosse 69c73b2d28 feat: workspace quotas (#4184) 2022-09-30 14:01:20 -04:00
Ammar Bandukwala 4b540b7c42 docs: simplify Docker quickstart (#4257) 2022-09-29 17:55:15 -05:00
Ammar Bandukwala 47a53ce6c5 coderd: treat email case insensitively (#4215) 2022-09-27 03:51:58 +00:00
Ammar Bandukwala ee4b934601 Add Users Last Seen At (#4192) 2022-09-26 15:31:03 +00:00
Garrett Delfosse 4c8be34d81 feat: add health check monitoring to workspace apps (#4114) 2022-09-23 15:51:04 -04:00
Dean Sheather 6deef06ad2 feat: secure and cross-domain subdomain-based proxying (#4136)
Co-authored-by: Kyle Carberry <kyle@carberry.com>
2022-09-22 22:30:32 +00:00
Bruno Quaresma bc47d7ce69 feat: Add extra fields to the audit filter (#4123) 2022-09-20 13:07:21 -03:00
Kyle Carberry 72d6731924 fix: Only update workspace LastUsed when the connection payload has changed (#4115)
This was causing every workspace to update last used to time.Now() when
coderd was restarted!
2022-09-19 14:11:18 -05:00
Dean Sheather 29d804e692 feat: add API key scopes and application_connect scope (#4067) 2022-09-19 17:39:02 +00:00
Bruno Quaresma adad347902 refactor: Refactor audit logs count to support filtering (#4113) 2022-09-19 17:08:25 +00:00
Bruno Quaresma bf8d823ae3 feat: Add audit log filters in the API (#4078) 2022-09-19 10:37:33 -03:00
Garrett Delfosse 63fd4945a2 chore: watch workspace endpoint (#4060) 2022-09-16 18:54:23 +00:00
Colin Adler 86fdafda23 fix: data races in databasefake (#4084) 2022-09-16 00:06:39 +00:00
Bruno Quaresma 214e59452f feat: Show custom resource icons in the UI (#4020) 2022-09-13 11:32:59 -03:00
Kyle Carberry 850a83097c feat: Allow deleting users (#4028)
* Add deleted column to the users table

* Fix user indexes

* Add frontend

* Add test
2022-09-12 23:24:20 +00:00
Bruno Quaresma 8a94b72c7d feat: Allow hide resources (#3977) 2022-09-09 16:38:00 -03:00
Ammar Bandukwala f6aa025a01 feat: use active users instead of total users in Template views (#3900) 2022-09-09 19:30:31 +00:00
Colin Adler abb804f2de feat: add template/template version auditing (#3965) 2022-09-09 11:34:23 -05:00
Colin Adler 7dc73ed6c6 feat: add description to audit log responses (#3949) 2022-09-08 09:36:34 -05:00
Kyle Carberry 720c9dadcf fix: Remove name from workspace builds (#3937)
Fixes #1561.
2022-09-07 19:49:57 +00:00
Colin Adler 762063ed8f fix: add avatar_url to user object in audit log response (#3939) 2022-09-07 19:22:04 +00:00
Colin Adler 3d6d51fbd0 feat: audit log api (#3898) 2022-09-07 16:38:19 +00:00
Kyle Carberry bb17fe5398 Use go run when executing goimports in gen 2022-09-06 19:59:14 -05:00
Kyle Carberry 65d63f9167 Use go run for executing goimports 2022-09-06 19:53:39 -05:00
Kyle Carberry 00f05e798b Fix avatar_url dump.sql 2022-09-04 16:56:09 +00:00
Kyle Carberry d8f9537880 Fix avatar_url database type 2022-09-04 16:55:25 +00:00
Kyle Carberry 05e2806ff3 feat: Add profile pictures to OAuth users (#3855)
This supports GitHub and OIDC login for profile pictures!
2022-09-04 11:44:27 -05:00
Colin Adler 55c13c8ff9 chore: fully implement enterprise audit pkg (#3821) 2022-09-02 16:42:28 +00:00
Mathias Fredriksson 4c18034260 fix: Prevent autobuild executor from slowing down API requests (#3726)
With just a few workspaces, the autobuild executor can slow down API
requests every time it runs. This is because we started a long running
transaction and checked all eligible (for autostart) workspaces inside
that transaction. PostgreSQL doesn't know if we're modifying rows and as
such is locking the tables for read operations.

This commit changes the behavior so each workspace is checked in its own
transaction reducing the time the table/rows needs to stay locked.

For now concurrency has been arbitrarily limited to 10 workspaces at a
time, this could be made configurable or adjusted as the need arises.
2022-09-02 13:24:47 +03:00
Ammar Bandukwala 04b03792cb feat: add last used to Workspaces page (#3816) 2022-09-02 00:08:51 +00:00
Ammar Bandukwala 30f8fd9b95 Daily Active User Metrics (#3735)
* agent: add StatsReporter

* Stabilize protoc
2022-09-01 14:58:23 -05:00
Kyle Carberry 9bd83e5ec7 feat: Add Tailscale networking (#3505)
* fix: Add coder user to docker group on installation

This makes for a simpler setup, and reduces the likelihood
a user runs into a strange issue.

* Add wgnet

* Add ping

* Add listening

* Finish refactor to make this work

* Add interface for swapping

* Fix conncache with interface

* chore: update gvisor

* fix tailscale types

* linting

* more linting

* Add coordinator

* Add coordinator tests

* Fix coordination

* It compiles!

* Move all connection negotiation in-memory

* Migrate coordinator to use net.conn

* Add closed func

* Fix close listener func

* Make reconnecting PTY work

* Fix reconnecting PTY

* Update CI to Go 1.19

* Add CLI flags for DERP mapping

* Fix Tailnet test

* Rename ConnCoordinator to TailnetCoordinator

* Remove print statement from workspace agent test

* Refactor wsconncache to use tailnet

* Remove STUN from unit tests

* Add migrate back to dump

* chore: Upgrade to Go 1.19

This is required as part of #3505.

* Fix reconnecting PTY tests

* fix: update wireguard-go to fix devtunnel

* fix migration numbers

* linting

* Return early for status if endpoints are empty

* Update cli/server.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

* Update cli/server.go

Co-authored-by: Colin Adler <colin1adler@gmail.com>

* Fix frontend entites

* Fix agent bicopy

* Fix race condition for the last node

* Fix down migration

* Fix connection RBAC

* Fix migration numbers

* Fix forwarding TCP to a local port

* Implement ping for tailnet

* Rename to ForceHTTP

* Add external derpmapping

* Expose DERP region names to the API

* Add global option to enable Tailscale networking for web

* Mark DERP flags hidden while testing

* Update DERP map on reconnect

* Add close func to workspace agents

* Fix race condition in upstream dependency

* Fix feature columns race condition

Co-authored-by: Colin Adler <colin1adler@gmail.com>
2022-08-31 20:09:44 -05:00