Commit Graph

23 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 4730c589fe
chore: Use standardized test timeouts and delays (#3291) 2022-08-01 15:45:05 +03:00
Mathias Fredriksson e33a74975e
fix: Deadlock and race in `peer`, test improvements (#3086)
* fix: Potential deadlock in peer.Channel dc.OnOpen

* fix: Potential send on closed channel

* fix: Improve robustness of waitOpened during close

* chore: Simplify statements

* fix: Improve teardown and timeout of peer tests

* fix: Improve robustness of TestConn/Buffering test

* Update peer/channel.go

Co-authored-by: Steven Masley <Emyrk@users.noreply.github.com>
2022-07-21 18:47:17 +03:00
Kyle Carberry 984dc2bffd
fix: Close peer negotiate mutex if we haven't negotiated (#1774)
Closes #1706 and #1644.
2022-05-27 17:34:13 +00:00
Cian Johnston c2f74f3cc2
chore: avoid concurrent usage of t.FailNow (#1683)
* chore: golangci: add linter rule to report usage of t.FailNow inside goroutines
* chore: avoid t.FailNow in goroutines to appease the race detector
2022-05-24 08:58:39 +01:00
Cian Johnston a8a8f9dbf3
chore: skip some flaky tests (#1643)
* chore: skip some flaky tests

* Update peer/conn_test.go

* add makefile targets, reduce parallelism in go test
2022-05-21 00:39:51 +01:00
Dean Sheather 9141be3656
feat: add port-forward subcommand (#1350) 2022-05-19 00:10:40 +10:00
Colin Adler be8389fd74
chore: update to go 1.18 (#628)
* add make lint to Makefile
2022-03-28 19:14:40 +00:00
Kyle Carberry 68ceea8a28
test: Fix goroutine leak in peer exchange exit (#370)
Closes #361.
2022-02-27 19:19:02 -06:00
Kyle Carberry d43699306b
fix: Use buffered reader in peer to fix ShortBuffer (#303)
This prevents a io.ErrShortBuffer from occurring when the byte
slice being read is smaller than the chunks sent from the opposite
pipe.

This makes sense for unordered connections, where transmission is
not guaranteed, but does not make sense for TCP-like connections.

We use a bufio.Reader when ordered to ensure data isn't lost.
2022-02-17 08:45:14 -06:00
Kyle Carberry 1796dc6c2f
chore: Add test helpers to improve coverage (#166)
* chore: Rename ProjectHistory to ProjectVersion

Version more accurately represents version storage. This
forks from the WorkspaceHistory name, but I think it's
easier to understand Workspace history.

* Rename files

* Standardize tests a bit more

* Remove Server struct from coderdtest

* Improve test coverage for workspace history

* Fix linting errors

* Fix coderd test leak

* Fix coderd test leak

* Improve workspace history logs

* Standardize test structure for codersdk

* Fix linting errors

* Fix WebSocket compression

* Update coderd/workspaces.go

Co-authored-by: Bryan <bryan@coder.com>

* Add test for listing project parameters

* Cache npm dependencies with setup node

* Remove windows npm cache key

Co-authored-by: Bryan <bryan@coder.com>
2022-02-05 18:24:51 -06:00
Kyle Carberry b8cd579396
test: Skip leaked pion goroutines in peer (#108) 2022-01-30 21:29:38 -06:00
Kyle Carberry 9db5fb0952
refactor: Improve handshake resiliency of peer (#95)
* fix: Synchronize peer logging with a channel

We were depending on the close mutex to properly
report connection state. This ensures the RTC
connection is properly closed before returning.

* Disable pion logging

* Remove buffer

* Try ICE servers

* Remove flushed

* Add diagram explaining handshake

* Fix candidate accept ordering

* Add debug logging to peerbroker

* Fix send ordering

* Lock adding ICE candidate

* Add test for negotiating out of order

* Reduce connection to a single negotiation channel

* Improve test times by pre-installing Terraform

* Lock remote session description being applied

* Organize conn

* Revert to multi-channel setup

* Properly close ICE gatherer

* Improve comments

* Try removing buffered candidates

* Buffer local and remote messages

* Log dTLS transport state

* Add pion logging
2022-01-30 20:11:18 -06:00
Kyle Carberry 3e88f1502a
refactor: Remove "Opts" abbreviation (#92)
Having a mixture of abbreviations in the codebase reduces
clarity. Although opts is common for options, I'd rather
set a precedent of clarifying verbosity.
2022-01-29 19:27:44 -06:00
Kyle Carberry 27f7299383
chore: Update pion/ice fork to resolve goroutine leak (#78)
* chore: Update pion/ice fork to resolve goroutine leak

* Flush remote too

* Add logs for setting the description

* Try locking only on remote

* Remove local bufferring in favor of remote

* Remove unused flush func

* Set candidates flushed to true

* Defer flush until the end of negotiation

* Buffer ICE candidates

* Add comment clarifying channel buffer

* Flush after handshake

* Move away from fork

* Ignore pion/ice leaks
2022-01-27 20:43:55 -06:00
Kyle Carberry 30dae97c3e
chore: Buffer remote candidates like local (#77)
* chore: Buffer remote candidates like local

This was added for local candidates, and is required for remote
to prevent a race where they are added before a negotiation is
complete.

I removed the mutex earlier, because it would cause a different race.
I didn't realize the remote candidates wouldn't be buffered,
but with this change they are!

* Use local description instead

* Add logging for candidate flush

* Fix race with atomic bool

* Simplify locks

* Add mutex to flush

* Reset buffer

* Remove leak dependency to limit confusion

* Fix ordering

* Revert channel close

* Flush candidates after remote session description is set

* Bump up count to ensure race is fixed

* Use custom ICE dependency

* Fix data race

* Lower timeout to make for fast CI

* Add back mutex to prevent race

* Improve debug logging

* Lock on local description

* Flush local candidates uniquely

* Fix race

* Move mutex to prevent candidate send race

* Move lock to handshake so no race can occur

* Reduce timeout to improve test times

* Move unlock to defer

* Use flushed bool instead of checking remote
2022-01-27 09:14:52 -06:00
Kyle Carberry a44056cff5
feat: Add project API endpoints (#51)
* feat: Add project models

* Add project query functions

* Add organization parameter query

* Add project URL parameter parse

* Add project create and list endpoints

* Add test for organization provided

* Remove unimplemented routes

* Decrease conn timeout

* Add test for UnbiasedModulo32

* Fix expected value

* Add single user endpoint

* Add query for project versions

* Fix linting errors

* Add comments

* Add test for invalid archive

* Check unauthenticated endpoints

* Add check if no change happened

* Ensure context close ends listener

* Fix parallel test run

* Test empty

* Fix organization param comment
2022-01-24 17:07:42 +00:00
Kyle Carberry a96cd3fc3d
ci: Run peer tests faster on local machine (#54)
This should result in faster local development, and faster CI!
See the code comment for rationale.
2022-01-24 07:57:21 -08:00
Kyle Carberry 8be245616a
feat: Add organizations endpoint for users (#50)
* feat: Add organizations endpoint for users

This moves the /user endpoint to /users/me instead. This
will reduce code duplication.

This adds /users/<name>/organizations to list organizations
a user has access to. It doesn't contain the permissions a
user has over the organizations, but that will come in a future
contribution.

* Fix requested changes

* Fix tests

* Fix timeout

* Add test for UserOrgs

* Add test for userparam getting

* Add test for NoUser
2022-01-22 23:58:10 -06:00
Kyle Carberry 2654a93132
chore: Fix golangci-lint configuration and patch errors (#34)
* chore: Fix golangci-lint configuration and patch errors

Due to misconfiguration of a linting rules directory, our linter has not been
working properly. This change fixes the configuration issue, and all remaining
linting errors.

* Fix race in peer logging

* Fix race and return

* Lock on bufferred amount low

* Fix mutex lock
2022-01-20 10:00:13 -06:00
Kyle Carberry a461bc1454
test: Increase disconnectTimeout to reduce test flakes (#26)
* test: Increase disconnectTimeout to reduce test flakes

WebRTC uses UDP, which means a network connection is never open or closed. It uses timeouts to determine connection state; on a slow CI runner, these timeouts could be reached. Increasing this timeout should reduce flakes, but is unlikely to remove this flake entirely.

* Fix close after offline

* Run tests in parallel
2022-01-14 10:12:07 -06:00
Kyle Carberry 53cfa8a45a
feat: Create broker for negotiating connections (#14)
* feat: Create broker for negotiating connections

WebRTC require an exchange of encryption keys and network hops to connect. This package pipes the exchange over gRPC. This will be used in all connecting clients and agents.

* Regenerate protobuf definition

* Cache Go build and test

* Fix gRPC language with dRPC

Co-authored-by: Bryan <bryan@coder.com>

Co-authored-by: Bryan <bryan@coder.com>
2022-01-11 09:28:41 -06:00
Kyle Carberry 8accb815e1
chore: Add peer package for networking (#6)
This package was pulled straight from github.com/coder/m. Nothing has been changed.

It will be used for networking clients<->workspaces, and coderd<->provisionerd.
2022-01-05 11:18:29 -06:00