Commit Graph

159 Commits

Author SHA1 Message Date
Nikolay Edigaryev 3c2de83ea7
Orchard Worker: don't forget to use localnetworkhelper in RPC and RPCv2 (#304)
* Orchard Worker: don't forget to use localnetworkhelper in RPC and RPCv2

* Fix integration tests by not requiring an empty vm.StatusMessage
2025-04-11 00:15:13 +04:00
Nikolay Edigaryev abcfee677d
Work around Sequoia's "Local Network" permission with a helper process (#302)
* Work around Sequoia's "Local Network" permission with a helper process

* README.md: macOS 15 (Sequoia) warning

* Make "orchard dev" unix-specific too, otherwise Release fails

* Fix typo in "localNetworkHerlper"

* Slightly improve the macOS 15 (Sequoia) note

* orchard worker run: better documentation for --user

* Make sure privilege dropping is the first step we do in runWorker()
2025-04-10 18:01:19 +04:00
Nikolay Edigaryev c24db17aa5
Use VM status message to reflect pulling, cloning, configuring, etc. (#298) 2025-04-03 18:08:13 +04:00
Nikolay Edigaryev 599ac40a90
orchard ssh vm: prevent busy loop in remote terminal resize goroutine (#297) 2025-04-02 14:07:52 +00:00
Nikolay Edigaryev 9919117b9b
orchard controller run: create a default bootstrap context (#291)
* orchard controller run: create a default bootstrap context

* Dockerfile: correct AS casing

* Fix typo in BootstrapContextName
2025-03-27 18:48:04 +04:00
Nikolay Edigaryev 7d340d6908
.golangci.yml: support golangci-lint 2.0 (#289) 2025-03-24 23:58:47 +04:00
gsakun 705bf8bd83
add insecure-no-tls flag (#281)
* support enable tls flag

* modify tls enable control flag

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>

* Optimize message print

* Avoid unrelated changes to the bootstrap message

* Consistent command-line argument order

* Extra spacing

* No need to shadow controllerCert

---------

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
2025-03-22 00:09:24 +04:00
Nikolay Edigaryev 39243978ed
orchard context create: ask for service account name and token (#282)
If not provided either via --bootstrap-token or via
--service-account-{name,token}.
2025-03-20 02:21:44 +04:00
Nikolay Edigaryev 59007020f4
Controller: enable experimental RPC v2 by default (#280)
* Controller: enable experimental RPC v2 by default

* Ensure mutual exclusiveness for --{,no-}experimental-rpc-v2

* Check earlier
2025-03-18 21:28:01 +04:00
Nikolay Edigaryev d5cd08fcce
Controller: advertise ALPN (#279) 2025-03-18 18:55:45 +04:00
dependabot[bot] c70eb068d4
Bump go.opentelemetry.io/otel/sdk/metric from 1.27.0 to 1.34.0 (#257)
* Bump go.opentelemetry.io/otel/sdk/metric from 1.27.0 to 1.34.0

Bumps [go.opentelemetry.io/otel/sdk/metric](https://github.com/open-telemetry/opentelemetry-go) from 1.27.0 to 1.34.0.
- [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases)
- [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md)
- [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.27.0...v1.34.0)

---
updated-dependencies:
- dependency-name: go.opentelemetry.io/otel/sdk/metric
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* opentelemetry: add TestConfigure

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
2025-02-20 02:19:11 +04:00
Nikolay Edigaryev 818f4288c2
Controller API: correctly detect WebSocket closure in Watch RPC (#259) 2025-02-20 02:00:57 +04:00
Nikolay Edigaryev 2c8d36ef70
Always randomize MAC address (#251)
* Always randomize MAC address

* Worker: check DHCP lease time and print a warning if it's unconfigured

* Further improve the explanation

* Add two leases example to the explanation

* Add an example of the resulting /var/db/dhcpd_leases
2025-02-13 12:35:12 +00:00
Nikolay Edigaryev 2aae818f78
Worker: prefer assigned CPU/memory to CPU/memory (#250)
* Worker: prefer assigned CPU/memory to CPU/memory

* orchard get worker: show default CPU, default memory and labels
2025-02-13 16:23:47 +04:00
Nikolay Edigaryev ee3c0f91f2
Startup script: implement retries for connection-related operations (#249)
* Startup script: implement retries for connection-related operations

* assert.Equal → assert.Contains

* Wait for at least 1,000 lines of logs

* Join slice of strings before calling assert.Contains()

* TestHostDirs: use require.Contains() instead of require.EqualValues()

* TestHostDirs: wait for at least 4 log lines
2025-02-12 18:11:12 +04:00
Nikolay Edigaryev 4794f2a5b6
orchard create vm: introduce --random-serial command-line argument (#248) 2025-02-12 18:00:13 +04:00
Nikolay Edigaryev 61d7d34ea4
RPC v2: fix Ping() hanging due to PONG not being processed (#247) 2025-02-07 22:05:09 +04:00
Nikolay Edigaryev 8dd74db446
Worker notification improvements (#246)
* OpenAPI: document all default "wait" values

* Re-use waitContext instead of instantiating it anew
2025-02-07 00:38:04 +04:00
Nikolay Edigaryev 722d5a8eaf
Avoid including " and $ characters in bootstrap admin's token (#245)
* Avoid including " and $ characters in bootstrap admin's token

* Avoid fallthrough
2025-02-06 21:37:42 +04:00
Fedor Korotkov 86f0afb5a3
Small timout for worker notification (#242)
* Small timout for worker notification

It seems at the moment if a worker re-establishes notify stream (for example, if network flips or proxy breaks the connection) then we can see "no worker registered with this name" errors.

This change makes Notifier to wait for 30 seconds before failing, at the time of calling `Notifier#Notify` we know such worker exists.

PS not sure if we need to make the timeout configurable.

* Wait via context

* Make sure all `context`s for `Notify` is time bounded

* Lint issues
2025-02-06 17:30:09 +00:00
Nikolay Edigaryev 26c8808506
Support scheduling by labels (#244) 2025-02-06 18:05:36 +04:00
Nikolay Edigaryev 581de320b9
Allow creating VMs with implicit CPU and memory (#243)
* Allow creating VMs with implicit CPU and memory

* Clarify why cpu/memory can be 0 a bit better

* Controller(API): don't forget to update DefaultCPU and DefaultMemory

* Add an integration test for implicit CPU and memory
2025-02-06 00:50:01 +04:00
Nikolay Edigaryev 88fba8004d
Introduce WebSocket-based RPC v2 (#239)
* Introduce WebSocket-based RPC v2

* go test: add -ldflags="-B gobuildid"

* No need to change the "controller.workerNotifier.Notify()" error message

* No need to modify Protocol Buffers/gRPC generated code

* rpcWatch(): explain that connection shouldn't be normally be closed

* Avoid "port forwarding failed: " repetition in error messages

* Improve comments and avoid repetition in IP resolution errors
2025-01-30 17:33:32 +04:00
Nikolay Edigaryev 077252f6d4
Prevent goroutine leak when Close()'ing *grpc_net_conn.Conn (#237) 2025-01-23 18:17:14 +04:00
Nikolay Edigaryev 1fce915d67
API: only overwrite specific worker fields when worker already exists (#236)
* API: only overwrite specific worker fields when worker already exists

* Don't forget to return when creating new worker

* Return updated worker when updating the worker
2025-01-16 16:42:17 +04:00
Nikolay Edigaryev 08769e00b4
Worker: do not consider on-disk VMs syncing error as fatal (#230) 2024-12-11 19:56:00 +04:00
Nikolay Edigaryev d7b6f477e1
Never list workers in Update()/storeUpdate() transactions (#228)
* POST /v1/workers: do not list workers in a single update txn

* schedulingLoopIteration(): do not list workers in a single update txn

* .golangci.yml: remove mentions of fully deprecated linters
2024-12-05 16:59:50 +04:00
Nikolay Edigaryev d94690176e
Schedule opportunistically and more granularly (#225)
* Schedule opportunistically and more granularly

To avoid transaction conflicts.

* Measure scheduling loop iteration duration and log it at debugging level

* Use "continue NextWorker" instead of just "continue" for clarity
2024-12-03 14:11:48 +00:00
Nikolay Edigaryev 7fe0414981
"--scheduler-profile" option to allow different orchestration patterns (#224)
* "--scheduler-profile" option to allow different orchestration patterns

* API(cluster settings): provide a default value for scheduler profile
2024-11-28 20:07:46 +04:00
Nikolay Edigaryev 772336a7bd
Scheduler: stop iterating over workers when candidate worker is found (#220) 2024-11-13 17:59:08 +04:00
Nikolay Edigaryev 60948e14fe
Rendezvous: use a buffered channel of size 1 (#219)
* Rendezvous: use a buffered channel of size 1

* Fix spelling of "absence" in comment
2024-11-08 11:19:54 +04:00
Nikolay Edigaryev d66d667f1e
orchard ssh vm: fix "The handle is invalid." error on Windows (#217) 2024-11-01 16:35:01 -04:00
Nikolay Edigaryev 9da91fa21a
Use a separate lock file on Windows to protect configuration (#216) 2024-11-01 22:38:25 +04:00
Fedor Korotkov b6fe371416
allow to set up worker name (#210) 2024-10-11 07:44:01 -04:00
Nikolay Edigaryev 2a2ddea62a
Controller: emit lifecycle events when the VM gets restarted or deleted (#208)
* Controller: emit lifecycle events when the VM gets restarted or deleted

* vm_{scheduling,run}_time → vm_{scheduling,run}_duration for clarity

* Update VM endpoint: only update VM started time when zero
2024-09-24 17:53:10 +04:00
Nikolay Edigaryev 1730eaf67c
orchard controller: make sure that output goes through the logger (#207)
...which emits JSON on the production for easier processing.
2024-09-17 22:54:43 +04:00
Mark McWhirter 979af1f699
Expose 2 new metrics about worker health (#203)
* Expose more metrics about worker health

* PR feedback

* PR feedback
2024-09-10 10:13:41 -04:00
Nikolay Edigaryev 8aaf05c4f7
controller run: make bootstrap process more user-friendly (#201)
* controller run: make bootstrap process more user-friendly

* Badger: log to zap instead of standard error
2024-09-03 18:54:28 +04:00
Nikolay Edigaryev cd9794197b
API: update service account fields on PUT (#198)
* API: update service account fields on PUT

* Disable G115 integer overflow linter of gosec
2024-08-21 20:03:52 +04:00
Nikolay Edigaryev 4df43e6432
Default ?wait= to 0 seconds (#190) 2024-07-03 23:07:14 +04:00
Nikolay Edigaryev 76f192bdb0
API endpoint and associated RPC changes to resolve VMs IP's (#188)
* API endpoint and associated RPC changes to resolve VMs IP's

* Fix "Missing expected argument '<name>'" error when doing "tart set"

* Implement TestIPEndpoint() and IP() method in controller HTTP client
2024-07-03 22:56:43 +04:00
Nikolay Edigaryev 8119b22817
orchard controller run: introduce --insecure-ssh-no-client-auth (#187) 2024-06-28 23:55:18 +04:00
Nikolay Edigaryev ff0497b1d8
Produce OpenTelemetry metrics (#185)
* .golangci.yml: remove mentions of deprecated linters

* Fix "staticcheck" linter error by using grpc.NewClient

* Configure OpenTelemetry

Metrics only for now.

* Produce OpenTelemetry metrics

* Update DeploymentGuide.md

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>

* Update DeploymentGuide.md

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>

* Introduce "org.cirruslabs.orchard.controller.worker_status"

---------

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
2024-06-24 18:19:51 +04:00
Nikolay Edigaryev 9442b6c5c3
Randomize the VM's MAC-address when using bridged networking (#182)
* Randomize the VM's MAC-address when using bridged networking

* CI: bypass test caching for "go test"
2024-06-18 11:19:56 +04:00
Nikolay Edigaryev d59bc7f8a7
Orchard Controller: implement an SSH server that acts as a jump host (#179)
* proxy.Connections(): require io.ReadWriteCloser instead of net.Conn

* Orchard Controller: implement an SSH server that acts as a jump host

* Issue a warning if the name used will be invalid in the future

* Further restrict uppercase characters in names in the future

The rationale is similar to https://github.com/kubernetes/kubernetes/issues/71140.

We won't want to munge the user's input and introduce subtle bugs doing
lowercase comparisons.
2024-06-11 19:32:45 +04:00
Nikolay Edigaryev c845f3b2fd
API: do not return null when methods returning a list have no items (#170)
* API: do not return null when methods returning a list have no items

* Use "omitempty" in all API structs
2024-04-29 15:49:09 -04:00
Nikolay Edigaryev 8790136f6a
Use macOS Sonoma images by default, instead of macOS Ventura (#166) 2024-04-17 17:56:08 +04:00
Nikolay Edigaryev 7fb0a85834
API(VM): new image FQN (fully-qualified name) field (#165) 2024-04-15 20:14:44 +04:00
Nikolay Edigaryev 510a25956f
Asynchronous VM creation (#163) 2024-04-12 15:56:00 +04:00
Nikolay Edigaryev a5c653d0a6
Introduce `--bootstrap-token-stdin` and `--{username,password}` (#160)
* orchard worker run: introduce --bootstrap-token-stdin flag

* orchard create vm: introduce --username and --password
2024-04-04 15:55:07 +04:00
Nikolay Edigaryev 969f0bd729
Association flow improvements for "orchard context create" and better URL crafting (#149)
* Client: prevent double slashes at the end of URLs

* orchard context create: let the user know which association flow is used

* Client: rename parsePath() to formatPath()

* Client: grab the ServerName from the trusted certificate
2023-11-21 18:43:42 +04:00
Nikolay Edigaryev 13b4e192f0
Introduce "orchard {port-forward, vnc} worker WORKER_NAME" (#140)
* Fix potential NPE in Client.wsRequest()

* Introduce "orchard {port-forward, vnc} worker WORKER_NAME"

* portspec.go: simplify logic and respect [LOCAL_PORT]:REMOTE_PORT format
2023-10-09 18:51:34 +04:00
Nikolay Edigaryev 063405672f
Worker: better cleanup mechanisms (#139)
* Always Close() the Worker instance

* orchard list vms: show assigned worker for each of the VMs

* Stop the failed VMs before we schedule new VMs

To avoid violating resource constraints.

* syncOnDiskVMs: don't ignore running VMs

* Worker: show correct remote and local VM counts
2023-09-28 19:09:43 +00:00
Nikolay Edigaryev 40f58e4aee
More RPC-related logs (#136)
* More RPC-related logs

* Notifier should be set before we use it in the scheduler
2023-09-27 20:16:00 +04:00
Nikolay Edigaryev 64987f6d59
Send http.Server errors to zap at debug level and provide --debug flag (#135) 2023-09-25 18:17:23 +04:00
Nikolay Edigaryev 8c62df0eba
Only allow simple names when creating workers, VMs, etc. and escape paths in API client (#129)
* Controller: only allow simple names when creating workers, VMs, etc.

* Client: escape paths

* simplename: allow ':' character
2023-09-22 14:51:43 -04:00
Nikolay Edigaryev 2adb17c3c4
Introduce "orchard get worker" command (#127) 2023-09-13 23:50:58 +04:00
Nikolay Edigaryev 3d0e375ede
Don't stop and delete VMs that failed to clone (#125)
* NewVM() never returns an error

* Don't stop and delete VMs that failed to clone
2023-09-13 19:39:10 +04:00
Nikolay Edigaryev bb3d6edcd5
Fix Tart VM IP detection in bridged mode (#124) 2023-09-12 08:52:21 +00:00
Nikolay Edigaryev 036eb954be
Retry DB transactions on badger.ErrConflict (#114)
* Log HTTP 500 errors in more detail

* Log errors in storeView and storeUpdate

* Retry on badger.ErrConflict
2023-08-15 15:18:47 +04:00
Tim Peeters 9f4cd5bae7
Fix typo in documentation of the new image-pull-policy option. (#113) 2023-08-07 12:48:57 -04:00
Nikolay Edigaryev 6759618f28
orchard create vm: support --image-pull-policy=Always (#110) 2023-07-26 17:43:14 +04:00
Nikolay Edigaryev fd88ce5890
Introduce ORCHARD_LICENSE_TIER environment variable (#111)
* Introduce ORCHARD_LICENSE_TIER environment variable

* Only parse ORCHARD_LICENSE_TIER if it was provided
2023-07-26 17:28:38 +04:00
Nikolay Edigaryev a52c205c34
API(port forward endpoint): handle normal WebSocket closure gracefully (#108) 2023-07-20 20:55:42 +00:00
Nikolay Edigaryev 0ba7db1a70
orchard list vms: add "Created" row (#106) 2023-07-04 18:11:26 +04:00
Nikolay Edigaryev d57d18d380
Support for sharing files with the host system (#103)
* Support for sharing files with the host system

* Integration tests

* Added back TestVMGarbageCollection comment
2023-07-04 18:10:53 +04:00
Nikolay Edigaryev 6a325daf74
Switch from golang.org/x/net/websocket to nhooyr.io/websocket and handle NotFound errors (#105)
* Switch from golang.org/x/net/websocket to nhooyr.io/websocket

* Do not attach errors that we can handle to the Gin's context

* Add missing newline to "no credentials specified or found, ..." message

* Fix potential NPE in ChooseUsernameAndPassword()

* Fix type in PortForward() error message in "orchard ssh vm"

* Fix potential NPE in Connections()

* Use header.Set() for consistency's sake for Authorization header
2023-07-04 18:10:41 +04:00
Nikolay Edigaryev 3c3b8e8180
Do not treat controller registration error as fatal (#100) 2023-06-29 19:29:32 +04:00
Nikolay Edigaryev 9b0cce182f
Use os.MkdirAll instead of os.Mkdir to create Orchard's home directory (#96)
* Use os.MkdirAll instead of os.Mkdir to create Orchard's home directory

* README.md: document ORCHARD_HOME

* README.md: sort environment variables
2023-06-26 19:35:50 +04:00
Nikolay Edigaryev c4c1851aff
Certificate-less bootstrap tokens (#93) 2023-06-23 00:53:03 +04:00
Nikolay Edigaryev dcc954631b
TLS improvements (#90)
* Fix typo when passing arguments to tls.LoadX509KeyPair()

* Support TLS 1.2 too

* Do not require a controller to only present a single certificate

* No need to set ServerName since we use InsecureSkipVerify

* Use host's root CA set by default and support normal SNI scenarios
2023-06-07 15:31:55 +04:00
Fedor Korotkov f6b48b7c42
Change event prefix to preserve order under load (#89)
* Change event prefix to preserve order under load

When there are a lot of events streamed from a worker, it's possible to have two batches coming for the same timestamp (which is a timestamp of the event on the worker). This way the existing logic would mess up the order because `index` and the random number doesn't guarantee the order.

To fix this I've changed the format of the prefix for the event to include tro things:

1. Timestamp in nanoseconds of the injection time on the controller so two sequential batches will have guaranteed order unless they are processed within a nanosecond.
2. Made the `index` being fixed length with trailing zeros, so they are properly lexicographically sorted (`000001`, `000002`, ...).

* No need to disable linting
2023-06-05 17:01:12 +00:00
Grigory Entin c12f93a90a
Fixed `logs` gluing the lines together. (#87)
* Fixed logs gluing the lines.

* .golangci.yml: disable "depguard" linter

---------

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
2023-06-04 09:42:02 +00:00
Nikolay Edigaryev 60e564da88
Implement restart policy for VMs (#83)
* Implement restart policy for VMs

* Do not update VM.Resource, we only use it as a read-only specification

* Err()/setErr(): use atomic.Pointer instead of sync.Mutex
2023-04-24 19:30:08 +04:00
Fedor Korotkov 010df300a3
Add basic Prometheus metrics (#82)
Fixes #71
2023-04-21 10:05:01 +04:00
Fedor Korotkov dd5e588eb0
Support Bridged Network (#78)
* Support Bridged Network

Inspired by https://github.com/cirruslabs/tart/issues/473

* Fixed tests
2023-04-20 15:04:07 +04:00
Nikolay Edigaryev 06de1094ba
Remove worker role (#77) 2023-04-12 12:03:24 +04:00
Nikolay Edigaryev 77656517fd
Controller info endpoint and API integration examples (#75)
* Controller API: introduce controller's information endpoint

* Prevent generation of empty events after channel closure

* Allow events to be buffered in the events channel

* Controller API: introduce controller's information endpoint[1]

* IntegrationGuide.md: a couple of Python and Golang examples

* Rephrase a sentence

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>

---------

Co-authored-by: Fedor Korotkov <fedor.korotkov@gmail.com>
2023-04-11 07:28:46 +00:00
Nikolay Edigaryev 84633d0e45
Introduce "orchard pause" and "orchard resume" commands (#73) 2023-04-07 22:59:41 +04:00
Nikolay Edigaryev fd1be695d4
Environment variable overrides (#74)
* Environment variable overrides

* Remove ORCHARD_CONTEXT
2023-04-07 17:49:13 +00:00
Nikolay Edigaryev 316f785a0c
orchard ssh vm: introduce exec mode (#72)
* orchard ssh vm: introduce exec mode

* Document "tart vm ssh" exec mode
2023-04-05 11:05:27 -04:00
Nikolay Edigaryev 4eafec99a5
Fail VMs if the worker had crashed/is unhealthy (#70)
* Fail VMs if the worker had crashed/is unhealthy

* OnDiskName: properly handle cases when VM's name contains hyphens

* Worker: introduce Offline() method and check it before scheduling

* tart.List(): use Tart's JSON output

* OnDiskName: remove empty parts check

* Scheduler: move health-checking logic to a separate function

* Only fail "running" VMs

* Only fail orphaned VMs if they're in terminal state

* Integration tests

* Run healthCheckingLoopIteration() before schedulingLoopIteration()

* Worker: sync on-disk VMs only once at start
2023-04-03 16:47:49 +04:00
Fedor Korotkov f152043f19
Reactive Scheduling (#67)
Before we had two main loops: controller loop to assign VMs and worker loop to start VMs. Each of the loops was performed upon an interval every N seconds.

This change introduces a mechanism for reactively requesting loop execution:

 1. Controller loop will be executed upon VM creation to try to immediately schedule.
 2. A worker will be notified upon a VM assigment and worker loop will be requested to sync immediately.

 Fixes #31
2023-03-28 20:51:41 +04:00
Fedor Korotkov 5eaf6b24d4
Make port-forward endpoint to wait for the VM (#65)
* Make port-forward endpoint to wait for the VM

Fixes #62

* Fixes after rebase
2023-03-27 23:52:21 +04:00
Nikolay Edigaryev 357a042937
REST API: provide error messages in error responses (#66)
* REST API: provide error messages in error responses

* Fix role checking logic and add tests

* Ignore testpackage linter error

* Rename NewError() to NewErrorResponse()
2023-03-27 14:12:03 -04:00
Nikolay Edigaryev cb39836ee0
Resources support (#63)
* Resources support

* Ability to provide VM and worker resources via the CLI

* orchard dev: always listen on :6120

* orchard dev: support --resources

* REST API: provide resource defaults when creating VM

* OpenAPI: document "resources" field

* orchard dev: serve Swagger API documentation on /v1/

* Integration guide
2023-03-27 17:30:54 +04:00
Fedor Korotkov f42026824c
Configure workers to log to a file (#59)
* Configure workers to log to a file

As a best practice. Inspired by 845ca51d5b/FAQ.md (does-zap-support-log-rotation)

* Removed redundant error check

* Make log file optional
2023-03-24 18:03:27 +00:00
Nikolay Edigaryev 7647ccdc10
Remove Generation field (#57) 2023-03-24 17:23:07 +00:00
Nikolay Edigaryev 49753ebf4c
Tests: use separate controller listening ports to prevent conflicts (#58) 2023-03-24 17:22:58 +00:00
Fedor Korotkov 63ba8b5532
Separate context for `orchard dev` (#56)
Fixes #51
2023-03-24 13:10:35 -04:00
Fedor Korotkov 362ea85b4f
Always require a client for running a worker (#52)
* Always require a client for running a worker

* Actually validate roles

* Delete worker

Fixes #46

* Update internal/worker/worker.go

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>

---------

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
2023-03-24 17:44:20 +04:00
Nikolay Edigaryev af074f499d
Remove UID for now and use machine ID to differentiate workers (#48)
* Remove UID for now and use machine ID to differentiate workers

* Rename MetadataWorkerKey back to MetadataWorkerNameKey
2023-03-23 23:38:54 +04:00
Nikolay Edigaryev 5c3b47a247
--help fixes and new "orchard logs vm" command (#41)
* Make sure we list names/VM names as required argument in the --help

* Introduce "orchard logs vm" command

* Make sure each command has a Short field

* Future-proof port-forward, ssh and vnc commands

To support not only the VM resource.
2023-03-23 15:59:57 +04:00
Fedor Korotkov cdf5c5eb00
Simplified bootstrapping of a cluster (#40)
* Simplified bootstrapping of a cluster

Introduced a new convention about a pre-defined `bootstrap-admin` account for `orchard controller run`. Providing `ORCHARD_BOOTSTRAP_ADMIN_TOKEN` will auto-create such user for easier configuration. `bootstrap-admin` can be used for creating other service accounts on the first run and after that can be disposed.

Also change `orchard worker run` to expect controller URL as the only parameter and a bootstrap token passed via an argument instead of using a context that might not be created.

* Missing error check
2023-03-22 23:43:37 +04:00
Fedor Korotkov 9b5ad09841
Consolidate controller bootstrap login in `run` command (#38) 2023-03-21 15:36:55 -04:00
Nikolay Edigaryev 10f56bb5e3
Introduce "orchard ssh" and "orchard vnc" commands (#36)
* proxy.Connections(): handle "use of closed network connection" error

* Controller: less strict timeouts that work nicely for WebSockets

* Worker: only attempt connect to the gRPC once our UID is known

* Introduce "orchard ssh" and "orchard vnc" commands

* Worker: prevent context leak by moving logic into a separate function

* Fix linter errors

* Port forwarding integration test

* Check for "uname -mo" output
2023-03-21 14:58:24 -04:00
Fedor Korotkov bdc781214c
Prepare for release (#37)
* Prepare for release

Added LICENSE, set version and configured GoReleaser/Docker

* Updated LICENSE
2023-03-20 15:28:24 -04:00
Fedor Korotkov fb3056d3ae
Refactorings for simplify readability (#35) 2023-03-17 06:11:28 -04:00
Fedor Korotkov 3ecf98c039
Support `startup`/`shutdown` scripts (#33)
* Support `startup`/`shutdown` scripts

Fixes #26

* Fixed Go modules after rebase

* Fixes after rebase
2023-03-14 22:15:54 +04:00
Nikolay Edigaryev 47fef47d1c
Port forwarding support (#30)
* Port forwarding support

* .golangci.yml: remove and replace deprecated and archived linters

* Client: pass credentials when calling WebSocket API methods

* API: require ServiceAccountRoleComputeWrite role for port forwarding

* Use Buf

* Rename Poll() RPC method to Watch()

* Split Rendezvous into two parts: Watcher and Proxy (#32)

* Split Rendezvous into two parts: Watcher and Proxy

* Implement Proxy cancellation

* Use Protocol Buffers structure directly in Watcher

* Fix TestWatcher after switching to Protocol Buffers structure

* portForwardVM(): ensure we also check for gin's context
2023-03-14 11:31:13 -04:00