-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Runner gRPC API #1767
Merged
Merged
New Runner gRPC API #1767
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NicolasMahe
commented
Apr 1, 2020
NicolasMahe
commented
Apr 1, 2020
NicolasMahe
commented
Apr 1, 2020
NicolasMahe
commented
Apr 1, 2020
NicolasMahe
commented
Apr 1, 2020
antho1404
reviewed
Apr 2, 2020
NicolasMahe
force-pushed
the
feature/auth-runner-grpc
branch
from
April 2, 2020 05:22
0d9c9fe
to
3bb7d95
Compare
antho1404
approved these changes
Apr 2, 2020
antho1404
approved these changes
Apr 2, 2020
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #1764
Dependent on #1768 for the exists endpoint.
This PR adds the new Runner gRPC API that service must use.
The big difference between this API and the previous ones is this API is secure (requires authentication) and specifically design for Runners, so it is much easier to integrate.
The API is composed of 4 endpoints:
Register
The service must call this API first but only when it's ready to emit events and/or execute executions.
The service has to call this endpoint with the content of the env variable
MESG_REGISTER_PAYLOAD
(injected by the CLI) to get a credential token requires for the following endpoints.Go example:
Once you got the token, the service need to pass it to the next endpoints in the gRPC metadata.
There are three ways to do this:
WithPerRPCCredentials
on the grpcDialOption
of the clientPerRPCCredentials
on theCallOption
of the requestmesg_credential_token
The first two options requires a struct that implement the interface
credentials.PerRPCCredentials
:Credential in client:
Credential per request:
Event
This endpoint is used to emit events.
It accepts an event's key and data.
The credential token must be passed to this request.
Go example:
Execution
This endpoint is used to create a stream that will receive the execution the runner has to execute.
The credential token must be passed to this request.
Go example:
Result
This endpoint is used to return the execution's result once the upcoming execution from the execution stream has been executed.
It accepts the execution's hash and the result.
The credential token must be passed to this request.
Go example:
CLI
The CLI has to create and inject the env variable
MESG_REGISTER_PAYLOAD
that the service will use to register itself against the Engine.This variable contains the data needed for the engine to register the runner as well as a signature that the engine verifies to check the authenticity of the runner by making sure the runner is created by the CLI.
The protobuf definition of this variable is:
The message
Value
is very close to the runner module MsgCreate. It contains the minimum of data so the engine can actually create, sign, and broadcast MsgCreate to register the runner on the network.signature
is the signature of the messageValue
(amino-json encoded) using the engine's account.Finally, the whole
RegisterRequestPayload
message is also amino-json encoded to be injected in the env of the runner.Here is the implementation of this system in the e2e runner test:
With
MESG_REGISTER_PAYLOAD
containing (without identation):