Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 62 additions & 2 deletions apricot/protos/apricot.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,95 @@ option java_package = "ch.cern.alice.o2.apricot.rpcserver";
option go_package = "github.com/AliceO2Group/Control/apricot/protos;apricotpb";

service Apricot {
// Increments the persistent run number counter and returns the new value.
// Not safe for concurrent callers: a lost compare-and-set race returns an error instead of retrying.
rpc NewRunNumber(Empty) returns (RunNumberResponse) {}

// Returns the key-value pairs stored under o2/runtime/aliecs/defaults, extended with computed entries:
// consul_base_uri, consul_hostname, consul_port, consul_endpoint, framework_id, core_hostname.
// Computed entries override stored ones with the same key.
// A backend failure yields a map without stored entries, not an error.
rpc GetDefaults(Empty) returns (StringMap) {}

// Returns the key-value pairs stored under o2/runtime/aliecs/vars.
// A backend failure yields an empty map, not an error.
rpc GetVars(Empty) returns (StringMap) {}

// Dumps the raw key-value subtree under rawPath as a JSON string, with no template processing.
rpc RawGetRecursive(RawGetRecursiveRequest) returns (ComponentResponse) {}

// Detectors and host inventories

rpc ListDetectors(DetectorsRequest) returns (DetectorsResponse) {}

// Returns FLP hostnames of the given detector, or of all FLPs if the detector is empty.
rpc GetHostInventory(HostGetRequest) returns (HostEntriesResponse) {}

// Includes private detectors (e.g. TRG).
rpc GetDetectorsInventory(Empty) returns (DetectorEntriesResponse) {}

// Fails if the host is not assigned to any detector.
rpc GetDetectorForHost(HostRequest) returns (DetectorResponse) {}

// Returns a sorted list of unique detectors. Fails if any of the hosts is not assigned to a detector.
rpc GetDetectorsForHosts(HostsRequest) returns (DetectorsResponse) {}

// Returns serials of the host's CRU cards as a JSON-encoded list, in no particular order.
rpc GetCRUCardsForHost(HostRequest) returns (CRUCardsResponse) {}

// Returns endpoints as a single space-separated string.
rpc GetEndpointsForCRUCard(CardRequest) returns (CRUCardEndpointResponse) {}

// Links without an explicit "enabled" field in the card configuration are never returned.
// Results are in no particular order.
rpc GetLinkIDsForCRUEndpoint(LinkIDsRequest) returns (LinkIDsResponse) {}

// Returns sorted link aliases across all FLPs of the detector.
// Fails if an alias is missing for any (enabled, if onlyEnabled) link.
rpc GetAliasedLinkIDsForDetector(AliasedLinkIDsRequest) returns (AliasedLinkIDsResponse) {}

// Runtime KV calls
// Entries live under o2/runtime/<component>/<key>.

// Fails if the entry does not exist.
rpc GetRuntimeEntry(GetRuntimeEntryRequest) returns (ComponentResponse) {}

// Creates or overwrites the entry.
rpc SetRuntimeEntry(SetRuntimeEntryRequest) returns (Empty) {}

// Fails as a whole (returning no entries) if reading any single entry fails.
rpc GetRuntimeEntries(GetRuntimeEntriesRequest) returns (StringMap) {}

// Returns keys relative to the component, possibly nested (e.g. "a/b").
rpc ListRuntimeEntries(ListRuntimeEntriesRequest) returns (ComponentEntriesResponse) {}

// Component configuration calls
// Entries are addressed as <component>/<RUNTYPE>/<role>/<entry>, either as a path
// or as a structured query. If both are given, the path takes precedence.

// Returns component names, in no particular order.
rpc ListComponents(Empty) returns (ComponentEntriesResponse) {}

// Returns sorted entries of the component as <RUNTYPE>/<role>/<entry>.
// Only the component of the query is used; run type and machine role are not filtered on.
// Fails if the component has no entries.
rpc ListComponentEntries(ListComponentEntriesRequest) returns (ComponentEntriesResponse) {}

// Reads exactly the addressed entry, without falling back to ANY run type or "any" role (see ResolveComponentQuery).
rpc GetComponentConfiguration(ComponentRequest) returns (ComponentResponse) {}

// Same as GetComponentConfiguration, plus the Consul modify index of the entry.
// processTemplate is not supported and results in an error.
rpc GetComponentConfigurationWithLastIndex(ComponentRequest) returns (ComponentResponseWithLastIndex) {}

// Finds the entry that would be used for the query. Tries, in order: the exact query,
// run type ANY, role "any", run type ANY with role "any". Fails if none exists.
rpc ResolveComponentQuery(ComponentQuery) returns (ComponentQuery) {}

// Creates or overwrites an entry. Does not invalidate the template cache.
rpc ImportComponentConfiguration(ImportComponentConfigurationRequest) returns (ImportComponentConfigurationResponse) {}

// Drops cached parsed templates, so that subsequent processed reads see changed entries.
rpc InvalidateComponentTemplateCache(Empty) returns (Empty) {}
}

Expand Down Expand Up @@ -105,7 +165,7 @@ message ComponentRequest {
string path = 1;
ComponentQuery query = 2;
}
bool processTemplate = 3;
bool processTemplate = 3; // if true, the entry is rendered as a template using varStack
map<string, string> varStack = 4;
}

Expand Down Expand Up @@ -208,7 +268,7 @@ message HostEntriesResponse {
message ImportComponentConfigurationRequest {
ComponentQuery query = 1;
string payload = 2;
bool newComponent = 3;
bool newComponent = 3; // must be true if the component does not exist yet, and false if it already exists
}

message ImportComponentConfigurationResponse {
Expand Down
77 changes: 61 additions & 16 deletions core/protos/o2control.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,46 +32,91 @@ import public "protos/events.proto";

// The Control service is the main interface to AliECS
service Control {
// If the detector list cannot be retrieved, detectorsInInstance is ["NIL"] and the other detector lists are empty.
rpc GetFrameworkInfo (GetFrameworkInfoRequest) returns (GetFrameworkInfoReply) {}

rpc GetEnvironments (GetEnvironmentsRequest) returns (GetEnvironmentsReply) {}

// Creates a new environment which automatically follows one STANDBY->RUNNING->DONE cycle in the state machine.
// It returns only once the environment reaches the CONFIGURED state or upon any earlier failure.
// The call returns immediately; the progress and outcome (including failure) are reported
// only through Subscribe called with the same id as in the request.
rpc NewAutoEnvironment (NewAutoEnvironmentRequest) returns (NewAutoEnvironmentReply) {}

// Creates a new environment.
// It returns only once the environment reaches the CONFIGURED state or upon any earlier failure.
// On failure, the error details contain an EnvironmentInfo with the ID of the failed environment.
rpc NewEnvironment (NewEnvironmentRequest) returns (NewEnvironmentReply) {}

// Returns NOT_FOUND for unknown environment IDs.
rpc GetEnvironment (GetEnvironmentRequest) returns (GetEnvironmentReply) {}

// Performs the requested transition synchronously.
// If the transition fails, the environment is moved to ERROR and the call returns ABORTED
// together with a reply describing the resulting state.
rpc ControlEnvironment (ControlEnvironmentRequest) returns (ControlEnvironmentReply) {}

// Without force, a CONFIGURED environment is first RESET, and a RUNNING one is first stopped
// if allowInRunningState is set. An environment in any other state (including RUNNING without
// allowInRunningState), or one for which any of these steps fails, is destroyed as if force was set.
rpc DestroyEnvironment (DestroyEnvironmentRequest) returns (DestroyEnvironmentReply) {}

// Detectors used by any environment.
rpc GetActiveDetectors (Empty) returns (GetActiveDetectorsReply) {}

// Detectors not used by any environment.
rpc GetAvailableDetectors (Empty) returns (GetAvailableDetectorsReply) {}

// Creates a new environment.
// It returns once an environment ID is created and continues the creation asynchronously to the call.
// The environment will be listed in GetEnvironments() only once the workflow is loaded and deployment starts.
// A failure is reported only as an environment event with state ERROR.
rpc NewEnvironmentAsync (NewEnvironmentRequest) returns (NewEnvironmentReply) {}

// rpc SetEnvironmentProperties (SetEnvironmentPropertiesRequest) returns (SetEnvironmentPropertiesReply) {}
// rpc GetEnvironmentProperties (GetEnvironmentPropertiesRequest) returns (GetEnvironmentPropertiesReply) {}

// Returns all tasks known to AliECS, regardless of the environment they belong to (if any).
rpc GetTasks (GetTasksRequest) returns (GetTasksReply) {}

// Channels and the task path are filled in only if the task is locked, i.e. belongs to an environment.
rpc GetTask(GetTaskRequest) returns (GetTaskReply) {}

// Only tasks not locked by an environment can be killed; requesting a locked task is an error.
// The reply lists which tasks were killed and which are still running.
rpc CleanupTasks(CleanupTasksRequest) returns (CleanupTasksReply) {}

rpc GetRoles (GetRolesRequest) returns (GetRolesReply) {}

// Default values of variables are overridden by matching Apricot vars.
rpc GetWorkflowTemplates (GetWorkflowTemplatesRequest) returns (GetWorkflowTemplatesReply) {}

// Repos are ordered alphabetically. The index used in the repo calls below refers to this order,
// and is thus invalidated by adding or removing a repo.
rpc ListRepos(ListReposRequest) returns (ListReposReply) {}

// Adds the repo, cloning it unless it is local.
rpc AddRepo(AddRepoRequest) returns (AddRepoReply) {}

// Deletes the local clone. If the removed repo was the default one, the first repo in the list becomes the default.
rpc RemoveRepo(RemoveRepoRequest) returns (RemoveRepoReply) {}

rpc RefreshRepos(RefreshReposRequest) returns (Empty) {}

// Fails if the repo is already the default one.
rpc SetDefaultRepo(SetDefaultRepoRequest) returns (Empty) {}

rpc SetGlobalDefaultRevision(SetGlobalDefaultRevisionRequest) returns (Empty) {}

// Does not return an error if the revision does not exist. Instead, the default revision is left unchanged
// and the available revisions are returned in info. An empty info means the revision was changed.
rpc SetRepoDefaultRevision(SetRepoDefaultRevisionRequest) returns (SetRepoDefaultRevisionReply) {}

// Streams events of an environment created with NewAutoEnvironment, identified by the id
// given in that request. The stream ends when the environment's event stream is closed.
// If no NewAutoEnvironment call uses the id, the call never returns and waits for one (busy-looping).
rpc Subscribe(SubscribeRequest) returns (stream events.Event) {}

// Plugins which are registered but not loaded are listed with empty fields.
rpc GetIntegratedServices(Empty) returns (ListIntegratedServicesReply) {}

// Reserved and not implemented:
Expand Down Expand Up @@ -121,7 +166,7 @@ message TeardownReply {}
// Environment
////////////////////////////////////////
message GetEnvironmentsRequest {
bool showAll = 1;
bool showAll = 1; // if false (default), only public environments are returned
bool showTaskInfos = 2;
bool showDetailedIntegratedServices = 3; // integratedServices are returned everytime, setting this flag gives detailed report
}
Expand Down Expand Up @@ -187,12 +232,12 @@ message GetEnvironmentReply {
message ControlEnvironmentRequest {
string id = 1;
enum Optype {
NOOP = 0;
NOOP = 0; // not accepted
START_ACTIVITY = 1;
STOP_ACTIVITY = 2;
CONFIGURE = 3;
RESET = 4;
GO_ERROR = 5;
GO_ERROR = 5; // not accepted
DEPLOY = 6;
}
Optype type = 2;
Expand Down Expand Up @@ -231,9 +276,9 @@ message ModifyEnvironmentReply {

message DestroyEnvironmentRequest {
string id = 1;
bool keepTasks = 2;
bool allowInRunningState = 3;
bool force = 4;
bool keepTasks = 2; // if false (default), the environment's tasks are killed after its destruction; ignored if the destruction falls back to force
bool allowInRunningState = 3; // if true, a RUNNING environment is stopped before its destruction; if false, it is destroyed as if force was set
bool force = 4; // if true, the environment is torn down immediately regardless of its state
common.User requestUser = 5;
}
message DestroyEnvironmentReply {
Expand Down Expand Up @@ -335,7 +380,7 @@ message TaskInfo {
}

message CleanupTasksRequest {
repeated string taskIds = 1;
repeated string taskIds = 1; // if empty, all tasks are killed (best effort)
}
message CleanupTasksReply {
repeated ShortTaskInfo killedTasks = 1;
Expand All @@ -348,7 +393,7 @@ message CleanupTasksReply {
////////////////////////////////////////
message GetRolesRequest {
string envId = 1;
string pathSpec = 2;
string pathSpec = 2; // dot-separated role path to look for, e.g. "a.b"; "*" stands for any text within one path element, "**" for any text across elements
}

message RoleInfo {
Expand All @@ -371,11 +416,11 @@ message GetRolesReply {
}

message GetWorkflowTemplatesRequest{
string repoPattern = 1;
string revisionPattern = 2;
bool allBranches = 3;
bool allTags = 4;
bool allWorkflows = 5;
string repoPattern = 1; // repo name, or its index as in ListRepos; "*" stands for any text. Empty means all repos
string revisionPattern = 2; // branch, tag or commit hash; "*" stands for any text. Empty means the default revision of each repo
bool allBranches = 3; // if true, templates of all branches are returned; cannot be combined with revisionPattern
bool allTags = 4; // if true, templates of all tags are returned; cannot be combined with revisionPattern
bool allWorkflows = 5; // if false (default), only public templates are returned
}

message VarSpecMessage {
Expand Down Expand Up @@ -446,7 +491,7 @@ message ListReposReply {

message AddRepoRequest {
string name = 1;
string defaultRevision = 2;
string defaultRevision = 2; // if empty, the global default revision is used
}

message AddRepoReply {
Expand All @@ -465,7 +510,7 @@ message RemoveRepoReply {
}

message RefreshReposRequest {
int32 index = 1;
int32 index = 1; // -1 refreshes all repos
}

message SetDefaultRepoRequest {
Expand Down
Loading