WorkerCoordination and GetSession API refactoring (#354)
* Possible api changes. * Worker API update. * Updating import alias name. * Moving session down a level as a member of the GetSessionResponse. * Marshal the auth flag into the GetSessionResponse proto instead of the session.
This commit is contained in:
1 parent
2914b4c14c
commit
33e7b4538e
18 files changed
+1923
-936
No files matched your search
@@ -0,0 +1,70 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.api.resources.sessions.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api/resources/sessions;sessions";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/wrappers.proto";
|
||||
import "google/protobuf/struct.proto";
|
||||
import "controller/api/resources/scopes/v1/scope.proto";
|
||||
import "controller/custom_options/v1/options.proto";
|
||||
|
||||
|
||||
message WorkerInfo {
|
||||
// The address of the worker
|
||||
string address = 10;
|
||||
}
|
||||
|
||||
// Session contains all fields related to a Session resource
|
||||
message Session {
|
||||
// The ID of the resource
|
||||
// Output only.
|
||||
string id = 10;
|
||||
|
||||
// The id of the parent of this resource. This must be defined for creation of this resource, but is otherwise
|
||||
// read only.
|
||||
string target_id = 20 [json_name="target_id"];
|
||||
|
||||
// Scope information for this resource
|
||||
// Output only.
|
||||
resources.scopes.v1.ScopeInfo scope = 30;
|
||||
|
||||
// The time this resource was created
|
||||
// Output only.
|
||||
google.protobuf.Timestamp created_time = 40 [json_name="created_time"];
|
||||
|
||||
// The time this resource was last updated.
|
||||
// Output only.
|
||||
google.protobuf.Timestamp updated_time = 50 [json_name="updated_time"];
|
||||
|
||||
// After this time the connection will be expired, e.g. forcefully terminated
|
||||
google.protobuf.Timestamp expiration_time = 60 [json_name="expiration_time"];
|
||||
|
||||
// The version can be used in subsequent write requests to ensure this
|
||||
// resource has not changed and to fail the write if it has.
|
||||
uint32 version = 70;
|
||||
|
||||
// Type of the session (e.g. tcp, ssh, etc.)
|
||||
string type = 80;
|
||||
|
||||
// The ID of the user that requested the session
|
||||
string user_id = 90 [json_name="user_id"];
|
||||
|
||||
string host_id = 100 [json_name="host_id"];
|
||||
|
||||
string scope_id = 110 [json_name="scope_id"];
|
||||
|
||||
// The certificate to use when connecting (or if using custom certs, to
|
||||
// serve as the "login"). Raw DER bytes.
|
||||
bytes certificate = 120;
|
||||
|
||||
// The private key to use when connecting (or if using custom certs, to pass
|
||||
// as the "password").
|
||||
bytes private_key = 130 [json_name="private_key"];
|
||||
|
||||
string endpoint = 140;
|
||||
|
||||
// Worker information. The first worker in the slice should be prioritized.
|
||||
repeated WorkerInfo worker_info = 150 [json_name="worker_info"];
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.api.services.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/gen/controller/api/services;services";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "controller/servers/v1/servers.proto";
|
||||
|
||||
service WorkerService {
|
||||
rpc Status(StatusRequest) returns (StatusResponse) {}
|
||||
rpc ValidateSession(ValidateSessionRequest) returns (ValidateSessionResponse) {}
|
||||
}
|
||||
|
||||
message StatusRequest {
|
||||
// The worker info. We could use information from the TLS connection but this
|
||||
// is easier and going the other route doesn't provide much benefit -- if you
|
||||
// get access to the key and spoof the connection, you're already compromised.
|
||||
servers.v1.Server worker = 10;
|
||||
|
||||
// Jobs currently active on this worker.
|
||||
repeated string active_job_ids = 20;
|
||||
}
|
||||
|
||||
message StatusResponse {
|
||||
// Active controllers. This can be used (eventually) for conneciton
|
||||
// management.
|
||||
repeated servers.v1.Server controllers = 10;
|
||||
|
||||
// Jobs that should be canceled: ones assigned to this worker that have been
|
||||
// reported as active but are in canceling state in the database. Once the
|
||||
// worker cancels the job, it will no longer show up in active_jobs in the
|
||||
// next heartbeat, and we can move the job to canceled state.
|
||||
repeated string cancel_job_ids = 20;
|
||||
}
|
||||
|
||||
message ValidateSessionRequest {
|
||||
// The session ID from the client
|
||||
string id = 10;
|
||||
}
|
||||
|
||||
// SessionResponse contains information necessary for a client to establish a session
|
||||
message ValidateSessionResponse {
|
||||
// ID of the session job
|
||||
string id = 10;
|
||||
|
||||
// The scope the job was created in
|
||||
string scope_id = 20;
|
||||
|
||||
// The ID of the user that requested the session
|
||||
string user_id = 30;
|
||||
|
||||
// Type of the session (e.g. tcp, ssh, etc.)
|
||||
string type = 40;
|
||||
|
||||
// The endpoint to connect to, in a manner that makes sense for the type
|
||||
string endpoint = 50;
|
||||
|
||||
// The certificate to use when connecting (or if using custom certs, to
|
||||
// serve as the "login"). Raw DER bytes.
|
||||
bytes certificate = 60;
|
||||
|
||||
// The private key to use when connecting (or if using custom certs, to pass
|
||||
// as the "password").
|
||||
bytes private_key = 70;
|
||||
|
||||
// After this time the connection will be expired, e.g. forcefully terminated
|
||||
google.protobuf.Timestamp expiration_time = 80;
|
||||
|
||||
// Worker information. The first worker in the slice should be prioritized.
|
||||
repeated WorkerInfo worker_info = 90;
|
||||
}
|
||||
|
||||
message WorkerInfo {
|
||||
// The address of the worker
|
||||
string address = 10;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.servers.services.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/gen/controller/servers/services;services";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "controller/servers/v1/servers.proto";
|
||||
|
||||
service ServerCoordinationService {
|
||||
// Status gets worker status requests which include the ongoing jobs the worker is handling and
|
||||
// returns the status response which includes the changes the controller would like to make to
|
||||
// jobs as well as provide a list of the controllers in the system.
|
||||
rpc Status(StatusRequest) returns (StatusResponse) {}
|
||||
}
|
||||
|
||||
message Connection {
|
||||
// TODO: Populate the connection specific info.
|
||||
// byte up/down
|
||||
// duration
|
||||
// etc...
|
||||
}
|
||||
|
||||
message SessionJobInfo {
|
||||
repeated Connection connections = 1;
|
||||
}
|
||||
|
||||
message Job {
|
||||
string job_id = 1;
|
||||
enum JOBTYPE {
|
||||
JOBTYPE_UNSPECIFIED = 0;
|
||||
JOBTYPE_SESSION = 1;
|
||||
}
|
||||
JOBTYPE type = 2;
|
||||
oneof job_info {
|
||||
// This value is specified when type is JOBTYPE_SESSION.
|
||||
SessionJobInfo session_info = 3;
|
||||
}
|
||||
}
|
||||
|
||||
message JobStatus {
|
||||
enum STATUS {
|
||||
// TODO: Get a better picture of what states general jobs can be in.
|
||||
STATUS_UNSPECIFIED = 0;
|
||||
// Specifies that the job is actively being handled by the worker.
|
||||
STATUS_ACTIVE = 1;
|
||||
STATUS_CANCELLED = 2;
|
||||
STATUS_COMPLETED = 3;
|
||||
}
|
||||
Job job = 1;
|
||||
STATUS status = 3;
|
||||
}
|
||||
|
||||
message StatusRequest {
|
||||
// The worker info. We could use information from the TLS connection but this
|
||||
// is easier and going the other route doesn't provide much benefit -- if you
|
||||
// get access to the key and spoof the connection, you're already compromised.
|
||||
servers.v1.Server worker = 10;
|
||||
|
||||
// Jobs which this worker wants to report the status.
|
||||
repeated JobStatus jobs = 20;
|
||||
}
|
||||
|
||||
message JobChangeRequest {
|
||||
enum CHANGETYPE {
|
||||
CHANGETYPE_UNSPECIFIED = 0;
|
||||
// Indicates that the job should be cancelled on the worker.
|
||||
CHANGETYPE_CANCEL = 1;
|
||||
}
|
||||
Job job = 1;
|
||||
CHANGETYPE request_type = 2;
|
||||
}
|
||||
|
||||
message StatusResponse {
|
||||
// Active controllers. This can be used (eventually) for connection
|
||||
// management.
|
||||
repeated servers.v1.Server controllers = 10;
|
||||
|
||||
// List of jobs and the expected state changes. For example, this will include jobs witch
|
||||
// change type of cancelled for jobs which are active on a worker but should be cancelled.
|
||||
// This could also contain a request to start a job such as a worker -> worker proxy for
|
||||
// establishing a session through an enclave.
|
||||
repeated JobChangeRequest jobs_requests = 20;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package controller.servers.services.v1;
|
||||
|
||||
option go_package = "github.com/hashicorp/boundary/internal/gen/controller/servers/services;services";
|
||||
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "controller/servers/v1/servers.proto";
|
||||
import "controller/api/resources/sessions/v1/session.proto";
|
||||
|
||||
service SessionService {
|
||||
// Validate session allows a worker to retrieve session information from the controller.
|
||||
// This endpoint validates the session
|
||||
rpc GetSession(GetSessionRequest) returns (GetSessionResponse) {}
|
||||
}
|
||||
|
||||
message GetSessionRequest {
|
||||
// The session ID from the client
|
||||
string id = 10;
|
||||
}
|
||||
|
||||
// SessionResponse contains information necessary for a client to establish a session
|
||||
message GetSessionResponse {
|
||||
api.resources.sessions.v1.Session session = 1;
|
||||
}
|
||||
Reference in new issue
Block a user