feat(plugin): add experimental gRPC v1alpha plugin backend support #1500
No reviewers
Labels
No labels
FreeBSD
Kind/Breaking
Kind/Bug
Kind/Chore
Kind/DependencyUpdate
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
Windows
linux-powerpc64le
linux-riscv64
linux-s390x
run-end-to-end-tests
run-forgejo-tests
run-multi-platform-tests
No milestone
No assignees
6 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
forgejo/runner!1500
Loading…
Reference in a new issue
No description provided.
Delete branch "eleboucher/runner:plugin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements an experimental gRPC protocol for plugable backend systems, per forgejo/forgejo-actions-feature-requests#107 (comment).
(Notes from @mfenniak, Forgejo merger):
Implements an experimental gRPC protocol for plugable backend systems, per forgejo/forgejo-actions-feature-requests#107 (comment). This allows future development of new job container execution models, such as Firecracker VMs, qEMU VMs, systemd-nspawn containers, Kubernetes pods, etc.
As an v1alpha protocol, the protocol is subject to change with no stability guarantees at the moment.
As an experimental feature, the Forgejo team is not yet willing to fully commit that this feature will be a permanent addition. We believe it is a good direction, and we believe we can continue to iterate it to a fully supportable and capable feature based upon feedback from ourselves and other users. But as that feedback is collected and incorporated, we leave open the possibility that we may gain new knowledge and be required to change direction.
7764310894ff3bfc7532ff3bfc7532870ea62b11870ea62b117df1656f9b6441c1da3bfed7286109fed7286109266be7e9bb266be7e9bbeef6a8f04ceef6a8f04c7df964c1197df964c1190e8a4fe6820e8a4fe682277b97a3a7277b97a3a73103fe44763103fe4476e46f11d039Hello @aahlenst
so this will be the next and last PR for the plugin right ? should we tackle it now ?
e46f11d03900ecf1906c00ecf1906c2ad15396152ad1539615c74cb26490@eleboucher wrote in #1500 (comment):
It's been a while, and I'm focused on something else, so my mental model might be outdated or incomplete. As far as I remember, there's no back-end discovery or loading, yet. Would it be possible for the plug-in to land without that?
It looks like this PR contains some commits that have already landed. Would a rebase help making it smaller?
c74cb26490eb54e71bc8@aahlenst wrote in #1500 (comment):
Hey, i squashed some commit so the history is better, but this is everything and rebased.
Yes no discovery yet it's config driven for now
@eleboucher wrote in #1500 (comment):
That doesn't really answer my question. 🙂 It was: Would it be possible for the plug-in to land without that [back-end discovery]?
I have even more questions: Would it be sensible to land it without back-end discovery? What does that mean for existing users of Forgejo Runner? Or other people that want to use the plug-in interface?
@aahlenst wrote in #1500 (comment):
oh yeah no problem in releasing that already without the backend discovery, here is how i use my config
we can probably rework the config to fit more the backend interface we worked on but no behavior changes for anyone already the forgejo runner already
Before I try to digest over 5000 lines in vain: What do you think, @mfenniak?
I'm good with the broad direction. With a few minutes of reviewing, it's clear to me that this will not get a good review if it isn't broken down severely into smaller chunks of reviewable work.
This is certainly subject to @eleboucher's expertise, but I'd say:
delegates_to_docker-- seems like an entirely separate capability that doesn't need to be in one PRI'm not prescribing how to split it, but, I wouldn't be able to review this. This is really important functionality, with really subtle possible behaviours, and doing it right requires the ability for a reviewer to be able to fully grasp each change and think about the code that isn't present. "is this going to work when a job is cancelled", "what happens when this times out", "will error handling or resource leakage occur here" -- and that requires small chunks of work that build up the capabilities. Even if something doesn't have a meaningful outcome/output/deliverable in the first PRs.
eb54e71bc8fdf5ce3f3c@mfenniak wrote in #1500 (comment):
I refactored the commit history to make more sense i hope now it's ready for review and i'm still reachable here or on matrix for more
I've reviewed the first one and a half commits. My comments on the protocol are extensive and I'm starting to repeat myself, so I want to send this feedback for you first -- the rest of the protocol likely also needs more documentation, more consistency, and more independence from docker-related concepts.
@ -0,0 +24,18 @@return x.ep}// NewJobContainer creates the container the job runs in.func (x *ExecutionEnvironment) NewJobContainer(input *actcontainer.NewContainerInput) actcontainer.ExecutionsEnvironment {return NewContainer(x.ep, input)}// NewServiceContainer creates a service container for the job.func (x *ExecutionEnvironment) NewServiceContainer(input *actcontainer.NewContainerInput) actcontainer.ExecutionsEnvironment {return NewContainer(x.ep, input)}// NewStepContainer creates the container a single step runs in (container// actions and `uses: docker://`).func (x *ExecutionEnvironment) NewStepContainer(input *actcontainer.NewContainerInput) actcontainer.ExecutionsEnvironment {return NewContainer(x.ep, input)}Why are three different methods with the same signature, and same implementation, required? In what case would an execution environment have different behaviour based upon whether you're working in a job, service, or step?
There has been no response to this comment asking a question, and no change related to it.
@ -0,0 +17,4 @@rpc Create(CreateRequest) returns (CreateResponse);// Start boots a previously created environment.rpc Start(StartRequest) returns (StartResponse);What do errors look like from this request, or any of these requests? How are errors encoded, and do they contain any information that is actionable / machine-readable? Are there any need for structured errors?
There has been no response to this comment asking a question, and no change related to it.
@ -0,0 +44,4 @@message CapabilitiesRequest {}message CapabilitiesResponse {All the fields in the protocol requests and response deserve documentation to explain them. It would be reasonable to assume this is the primary source of information for a developer working on implementing the protocol.
Only 2 of the 15 fields in
CapabilitiesResponseare documented.@ -0,0 +53,4 @@string default_path_variable = 6;string path_separator = 7;bool supports_docker_actions = 8;bool manages_own_networking = 9;There are no APIs on
BackendPluginto manage networking. As an author of a plugin, what am I expecting this parameter to do?@ -0,0 +58,9 @@bool environment_case_insensitive = 11;map<string, string> runner_context = 12;bool supports_local_copy = 13;// delegates_to_docker indicates the plugin only manages an execution// environment lifecycle and exposes a Docker daemon endpoint for the// runner to drive containers against. When true, the runner ignores// Exec/CopyIn/CopyLocal/CopyOut/UpdateEnv/IsHealthy on this plugin and// talks directly to the daemon returned in CreateResponse.delegate.bool delegates_to_docker = 14;This is such a different protocol implementation that I'm inclined to think that it shouldn't be part of the same service. Would it be plausible to split the service along this dimension?
e.g. a plugin can implement either
BackendPluginorDockerTunnelPlugin, and the later doesn't require defining 6 methods that do nothing.@ -0,0 +79,4 @@}message CreateRequest {string image = 1;What is
imageintended to contain in execution environments that are not docker? Can we document that? Is it just plugin-defined arbitrary string, from the protocol's perspective?@ -0,0 +81,4 @@message CreateRequest {string image = 1;string name = 2;repeated string env = 3;Would this make more sense as a key-value pair so that a plugin doesn't have to parse it?
@ -0,0 +82,4 @@string image = 1;string name = 2;repeated string env = 3;string working_dir = 4;Kinda surprising that this comes from the runner and not from the plugin to the runner. How does the runner know the right field value here, assuming that, for example, you're writing a plugin that creates a VM in a different OS like Windows?
working_dir is just the workflow's configured working directory, the same value the built-in Docker and host backends already get. The runner isn't claiming to know the VM's filesystem layout. It passes the path the job expects, and a plugin that can't use it literally (a Windows VM, say) maps it to wherever makes sense, same as it does for the paths in CapabilitiesResponse.
@ -0,0 +83,5 @@string name = 2;repeated string env = 3;string working_dir = 4;repeated string cap_add = 5;repeated string cap_drop = 6;These are pretty Linux-specific, and, I wouldn't expect every execution environment can mange this even within Linux. What is a plugin author expected to do if this is not possible on their environment? It wasn't listed in the
CapabilitiesResponse...@ -0,0 +85,4 @@string working_dir = 4;repeated string cap_add = 5;repeated string cap_drop = 6;repeated ServiceContainer services = 7;What are the expectations if I authored my plugin and indicated
supports_service_containers = false?@ -0,0 +86,4 @@repeated string cap_add = 5;repeated string cap_drop = 6;repeated ServiceContainer services = 7;map<string, string> backend_options = 8;What are
backend_options?@ -0,0 +89,4 @@map<string, string> backend_options = 8;// force_pull asks the plugin to re-fetch the image. Plugins that cannot// honor it should still succeed using the cached image.bool force_pull = 9;I'm not sure that this belongs in the protocol; it doesn't seem like a generically meaningful parameter. It implies a lot about the nature of the executor and the image.
force_pull maps 1:1 to the runner's existing Pull(forcePull) contract that the built-in Docker/host backends already honor
@ -0,0 +92,4 @@bool force_pull = 9;// platform is the OS/arch (e.g. "linux/amd64") the runner label selected for// image pulls and container creation. Empty means auto-detect.string platform = 10;This requires the backend to parse a docker-specific platform string (which, aside, contains an optional third parameter in the architecture variant). I'd suggest (a) separating this out into separate fields so it doesn't need to be parsed by a non-docker backend, and (b) maybe turning it into structured data like an enum? I'm not so sure about (b); I don't want to be updating the protocol for new OSes, but, I'm not loving the idea of a plugin author having no idea what is coming here.
Or the field can be described less in terms of
linux/amd64, and more in terms of "this is an execution-environment specific value; the runner and the protocol treat it opaquely; whatever is passed in over here arrives over here at the plugin."Empty means auto-detect-- I'd prefer marking the fieldoptionaland omitting it, what do you think?@ -0,0 +97,4 @@message CreateResponse {string environment_id = 1;// delegate is set iff CapabilitiesResponse.delegates_to_docker is true.I assume
iffis intended aif and only if; please elaborate it@ -0,0 +100,4 @@// delegate is set iff CapabilitiesResponse.delegates_to_docker is true.// Carries the Docker daemon endpoint and TLS material the runner uses// to drive containers inside the plugin-managed environment.DockerDelegate delegate = 2;This field should be marked
optional?@ -0,0 +111,4 @@string endpoint = 1;bytes tls_ca = 2;bytes tls_cert = 3;bytes tls_key = 4;Having a TLS private key transferred is surprising....
What kind of trust model are we trying to establish here? Like... this feels a bit like we connected all the dots required to connect to a TLS-encrypted docker container, but without any thought put into whether any real security is involved in doing so. CA private keys floating around in-memory between are effectively compromised.
This ends up being, why are we using TLS, what security do we want to gain from it, and are we meeting that objective?
I don't see anything that addresses this comment -- the
DockerDelegatemessage still contains a TLS private keyYeah, you're right, the current design does not establish a meaningful trust boundary.
For v1alpha (which i think we should rename the proto to that), we should either:
@ -0,0 +123,4 @@}message StartResponse {map<string, string> image_env = 1;What is this?
@ -0,0 +130,4 @@message ExecRequest {string environment_id = 1;repeated string command = 2;map<string, string> env = 3;Here you've gone for
map<string, string>forenv, where earlier it wasrepeated string.I'm overall inclined to think that, before we can land this plugin capability, it might be reasonable to have two independent implementations of plugins built on it. The protocol is going to be important and long-standing, so that might be the only way to gain a lot of confidence that it hits the right notes... 🤔
ce1c26f5936e5e2dc3566e5e2dc356e0cc068092@mfenniak wrote in #1500 (comment):
Thanks for the review. Pushed a rework addressing the structural points:
(Create/Remove + returns the daemon endpoint). No more no-op methods to stub. Matches the VM-delegate direction from
#107.
creation).
the runner. Default is unix/vsock with no key transfer; networked mode uses ephemeral per-env client certs.
delegate POC.
@eleboucher As you've noted in chat that you've made changes, I pulled this into my review queue again. But I'm confused looking at this -- I've started to go through my last comments and bring up the first two commits, b199e0678d978e8cbb3031556200e95470d62041 and 34ef1fb68211c535b5d6971e7c1690c68c822b7d, and all my comments sem to be unaddressed relative to the code (or questions that weren't answered).
I think the problem here is that you've previously split the work into reviewable commits, but, now the changes aren't in those commits. So the original plan of reviewing this commit-by-commit won't work if you haven't incorporated changes into those commits.
Please help me understand what you're expecting for a workflow to collaborate on this. It doesn't make sense, to me, to review commits that are based upon an implementation that changes later in the PR... what did you have in mind here?
e0cc068092fdf5ce3f3cfdf5ce3f3ccba3cfcd05cba3cfcd056bd7a04ae4@mfenniak wrote in #1500 (comment):
my bad i'm sorry, I've rewritten the branch so each commit reflects the final design: the proto commit now has the two-service layout your comments were about, Please re-review from the top.
6bd7a04ae4bdcbd91518I can see that you've put a lot of work into this, but I'm quite uncertain about this development direction. I want to have a plugin-based approach for extension. 👍 The problem is that as I review this, it feels like a hundred things are incomplete or underspecified in this protocol.
This makes is very hard to review comprehensively; it's mentally exhausting to not be able to see how all the pieces fit together, and to see dead ends (like
manages_own_networking) where it seems like there's an idea but it is incomplete.I'm tempted to say that there is a much smaller protocol that should be a "v1", with simpler inputs, simpler requirements, and we can get a very basic version of this done. This revision right now is a gigantic chunk of work that makes it very difficult to get a solid, well designed protocol defined.
@ -0,0 +84,8 @@opt(&cfg)}if _, ok := ctx.Deadline(); !ok {var cancel context.CancelFuncctx, cancel = context.WithTimeout(ctx, cfg.dialTimeout)defer cancel()}Why is
cfg.dialTimeoutonly used here if the context passed intoNewClienthas a timeout? That doesn't seem to make much sense to me.@ -0,0 +29,4 @@// BackendPlugin owns the full lifecycle of an execution environment and every// container operation within it.service BackendPlugin {Missing, in my opinion, is some way for the runner and the plugin to manage cleanup failures.
If the plugin crashes, or the runner crashes, when restarted the plugin may have resources that were created and are no longer being managed by the runner. e.g. we started a job, then crashed. We have no mechanism then to query from the plugin which jobs are currently running and perform cleanup when the runner knows that they aren't valid.
@ -0,0 +50,4 @@// CopyLocal copies a path from a volume shared with the runner into the// environment. Only called when CapabilitiesResponse.supports_local_copy is// true; a faster alternative to streaming the same bytes through CopyIn.Is the performance difference here worth having a more complicated plugin API and capabilities declaration? Would it maybe make sense to defer this complication to a future protocol addition, and keep things simple in this revision?
@ -0,0 +54,4 @@rpc CopyLocal(CopyLocalRequest) returns (CopyLocalResponse);// CopyOut transfers a tar archive out of the environment.rpc CopyOut(CopyOutRequest) returns (stream CopyOutChunk);How does this interact with CopyLocal, is there an equivalent capability for copying out of the container, or does the same capability get reused, or is CopyLocal just one-way (and if so, why?)
@ -0,0 +58,4 @@// UpdateEnv reads an env file inside the environment and returns the parsed// variables merged over the ones the runner already knows.rpc UpdateEnv(UpdateEnvRequest) returns (UpdateEnvResponse);Why not use
CopyOut? Simplify the protocol and the requirements of writing a plugin?Removed CopyLocal and supports_local_copy for v1alpha. CopyDir now always streams through CopyIn, so there's one copy-in path and CopyOut for the other direction.
@ -0,0 +64,4 @@rpc IsHealthy(IsHealthyRequest) returns (IsHealthyResponse);// Remove tears down the environment and releases all resources.rpc Remove(RemoveRequest) returns (RemoveResponse);In some execution environments this might be a time consuming operation. Is there a specific expectation that all the cleanup is completed immediately? Or is it possible that some cleanup can be deferred (maybe as long as any resources referenced by name are freed?)
Remove is expected to release the named resources (so the runner won't reference them again), but it doesn't have to block on full teardown.
@ -0,0 +88,4 @@message CapabilitiesRequest {}message CapabilitiesResponse {reserved 14; // was delegates_to_docker; delegation is now DockerTunnelPlugin.As this protocol is still under development, it doesn't seem necessary to mark old fields as reserved. They can just be removed and the fields renumbered.
@ -0,0 +93,9 @@// name identifies the backend (e.g. "kubernetes"); used in logs and as the// container back-end name.string name = 1;// root_path is the base directory the runner lays workflow files out under.string root_path = 2;// act_path is where the runner stages its helper binaries and action code.string act_path = 3;// tool_cache_path is exposed to jobs as RUNNER_TOOL_CACHE.string tool_cache_path = 4;These are responses from the plugin?
I'm quite confused as to why the plugin would need to communicate this back to the runner... for example,
tool_cache_path-- the usage just seems to be that it gets passed back to the execution environment asRUNNER_TOOL_CACHE.root_pathdoesn't seem to be used at all in the runner side of this implementation.What is the vision for why these are part of the capabilities, and how the runner would use them?
These back the ExecutionsEnvironment interface the runner already uses: root_path→GetRoot() (used when staging job files), act_path→GetActPath() (where the runner uploads its helper binaries), tool_cache_path→RUNNER_TOOL_CACHE. The plugin owns the environment's filesystem layout, so it has to tell the runner where those live. Kept, and documented each field in the proto.
CapabilitiesResponseis invoked once, and must returnroot_path,act_path,tool_cache_path, etc. Then later, Runner combines these into paths and calls CopyIn. If the plugin is not a plugin that internally creates isolated filesystems, then every invocation ofCopyInit is going to get the same path -- even for differentenvironment_id. A plugin of this nature would have difficulty keeping files apart for different environments.CopyIncould manage this by parsing the path, and rebuilding it with theenvironment_id, but that feels strange.How would you propose to solve this problem, if you were authoring a plugin?
One alternative design might be to:
CapabilitiesResponse.CopyRoot, with valuesActPath,ToolCachePath, ...CopyInChunkaCopyRoot.CopyOutChunkaCopyRoot.This would allow the plugin to construct the path based upon a unique prefix for the
environment_id, and add subpaths for each enum value. But, I haven't evaluated how complex the implementation changes in the runner would be. Please let me know if you have an alternative approach to solving this problem with the existing design.@ -0,0 +100,5 @@// tool_cache_path is exposed to jobs as RUNNER_TOOL_CACHE.string tool_cache_path = 4;// path_variable_name is the search-path environment variable ("PATH" on// POSIX, "Path" on Windows). Defaults to "PATH" when empty.string path_variable_name = 5;Defaults to "PATH"indicates that this should be marked as anoptionalfield.@ -0,0 +106,4 @@string default_path_variable = 6;// path_separator joins entries of path_variable_name (":" or ";"). Defaults// to ":" when empty.string path_separator = 7;Default value -> also means this is
optional.@ -0,0 +110,6 @@// supports_docker_actions gates `uses: docker://` and container actions. When// false, the runner errors upfront on a job that needs them.bool supports_docker_actions = 8;// manages_own_networking tells the runner the backend provides connectivity// itself; the runner then skips creating/attaching a Docker-style network.bool manages_own_networking = 9;Still confused over this field, as noted #1500 (comment). There don't appear to be APIs in the plugin for managing a network. The boolean returned here doesn't seem to ever be used. What is this here for?
@ -0,0 +120,4 @@// case-insensitive (Windows), so the runner de-duplicates accordingly.bool environment_case_insensitive = 11;// runner_context carries backend-provided values for the Actions runner// context (os, arch, temp, tool_cache). Treated as opaque key/values.tool_cache_pathis a different field?Why are these fields unstructured in a map?
@ -0,0 +127,4 @@bool supports_local_copy = 13;// protocol_version is the plugin protocol the server speaks. The runner// rejects a plugin whose version it does not support.uint32 protocol_version = 15;I'm not sure that this field is necessary. We're in a package
v1-- if there was a protocol change that was significant enough that it couldn't be managed through optional field detection, it would just be a separate protocol revisionv2@ -0,0 +165,8 @@// force_pull asks the backend to re-fetch the image rather than use a cached// copy. Backends that cannot honor it should still succeed with the cache.bool force_pull = 9;// platform is an execution-environment-specific value the runner passes// through verbatim (a Docker backend reads it as an OS/arch string like// "linux/amd64"). Omitted when the runner has no selection to convey.// Platform discovery is being reworked; this field is provisional.optional string platform = 10;Passes through verbatim? Where does it get this value from, then? If it's from the backend options... why isn't it just part of
backend_options?@ -0,0 +199,4 @@bytes tls_ca = 2;// tls_cert / tls_key are the client certificate and its private key the// runner presents to the daemon. Empty for non-networked endpoints; when set,// should be ephemeral and scoped to this environment (see message docs).What is
(see message docs)?@ -0,0 +212,4 @@string name = 1;// protocol_version is the plugin protocol the server speaks. The runner// rejects a plugin whose version it does not support.uint32 protocol_version = 2;same comment as previous re:
protocol_version, I don't think these fields are needed.@ -0,0 +222,4 @@// platform is an execution-environment-specific value passed through verbatim// (which VM/OS to boot). Omitted when the runner has no selection to convey.// Platform discovery is being reworked; this field is provisional.optional string platform = 2;Same concern as
platformin theCreateRequest@ -0,0 +254,4 @@// env are environment variables to set for this command.map<string, string> env = 3;// user is the user to run as, when the backend supports it (empty = default).string user = 4;Mark
optional.@ -0,0 +256,4 @@// user is the user to run as, when the backend supports it (empty = default).string user = 4;// workdir overrides the working directory for this command (empty = default).string workdir = 5;Mark
optional.@ -0,0 +269,4 @@// data is a chunk of output bytes.bytes data = 2;// exit_code is the command's exit status; only meaningful when done is true.int32 exit_code = 3;Mark
optional@ -0,0 +274,4 @@bool done = 4;// error_message describes a failure to run the command (as opposed to the// command itself failing); only meaningful when done is true.string error_message = 5;Mark
optional@ -0,0 +281,6 @@// environment_id and dest_path; subsequent chunks carry only data. Servers MUST// reject environment_id or dest_path on later chunks with codes.InvalidArgument.message CopyInChunk {string environment_id = 1;// dest_path is the directory the tar archive is extracted into.string dest_path = 2;as these fields aren't expected on a second chunk,
optional.@ -0,0 +315,5 @@string environment_id = 1;// src_path is the env file inside the environment to read.string src_path = 2;// current_env is the runner's current view, which the file is merged over.map<string, string> current_env = 3;Why is the plugin is responsible for merging the contents into the existing map? Shouldn't this be the runner's responsibility?
@ -0,0 +1,713 @@// Code generated by protoc-gen-go-grpc. DO NOT EDIT.I don't see any updates in this commit to the
Makefile-- is this file generated automatically when the protocol file is changed?@ -343,6 +343,8 @@}workdirParent := r.cfg.Container.WorkdirParentrunnerConfig := &runner.Config{// On Linux, Workdir will be like "/<parent_directory>/<owner>/<repo>"// On Windows, Workdir will be like "\<parent_directory>\<owner>\<repo>"Workdir: filepath.FromSlash(filepath.Clean(fmt.Sprintf("/%s/%s", r.cfg.Container.WorkdirParent, preset.Repository))),Workdir: filepath.FromSlash(filepath.Clean(fmt.Sprintf("/%s/%s", workdirParent, preset.Repository))),Moving
workdirParentseems like an irrelevant change hereremoved
@ -50,9 +50,6 @@ func Parse(str string) (*Label, error) {if len(splits) >= 2 {label.Schema = splits[1]if label.Schema != SchemeHost && label.Schema != SchemeDocker && label.Schema != SchemeLXC {return nil, fmt.Errorf("unsupported schema: %s", label.Schema)}This validation should be relocated, not removed, so that someone can't typo their label URLs
bdcbd91518ed51d1c259ed51d1c259a16f5c90c8a16f5c90c80eb4dc15eb@eleboucher I think we are not finding a way to collaborate well on this PR.
When I return to a PR to review it again, I'm going to go through my previous review comments. When I'm doing that right now, it seems like some of my comments have been missed, ignored, and even marked as resolved when they aren't:
UpdateEnvstill exists in the protocol, and you marked this as "resolved"Please help me understand the workflow you are expecting here. I find it quite frustrating at the moment.
Merge conflicts need to be resolved, and Forgejo Runner is now
v13requiring package naming updates, and the CI is broken.0eb4dc15eb947f7b42e7@mfenniak wrote in #1500 (comment):
Hello,
yes you are right i'm sorry, i was pretty frustrated to strip a good part of my work. but i will make sure i check your thread. sorry again
@eleboucher wrote in #1500 (comment):
Understood.
Let's do this. I have two comments that I think can be resolved in this PR.
Let's get those two comments resolved, and then we'll merge this.
I have started work on a plugin implementation. I will continue that work on and off, which will help me fully understand the protocol. We can both make more PRs, more tweaks and more small changes once this initial version of the protocol is merged. No stability guarantee.
@eleboucher wrote in #1500 (comment):
Opensource collaboration is hard, it's a bit like a couple, but where people only have some vague goals in common. It gets frustrating (and I say that as both a contributor and a maintainer of some projects).
@mfenniak wrote in #1500 (comment):
thank you for the message
i just have a small unrelated note but i guess there is something broken with the permalink for comments because i cannot find the comments of your first link #1500 (comment) it doesn't move me to it so i need to manually compare the id of every comment to find it
@ -1020,0 +1059,4 @@opts := make(map[string]string, len(pluginOpts)+2)maps.Copy(opts, pluginOpts)if labelArg := rc.pluginLabelArg(ctx); labelArg != "" {opts["label_arg"] = labelArgThe documentation for
backend_optionssays that it is "opaque, backend-specific options taken verbatim from the runner's per-label plugin configuration (e.g. namespace, VM flavour).". But here, you are inserting specific values generated by the runner -- thelabel_argandjob_timeout.I would suggest both of these special values should be defined directly in the protocol, in the
CreateRequest. The timeout, in particular, seems like a critical piece of information that should be part of the protocol. The job timeout should not be named "job timeout" either, as "jobs" aren't described in the protocol at all -- it should be named as an "environment timeout".@eleboucher wrote in #1500 (comment):
Ah, my error, sorry. I wrote a comment, and didn't submit it in the review.
The two comments are:
backend_optionshaving things being inserted into it947f7b42e73ee0351a483ee0351a487716b0ec5c@eleboucher Thank you for making the changes related to
backend_options.I see the revisions which now describe the paths are "logical paths". I'm understanding that this means the plugin has the responsibility to convert any logical path into a physical path. But I believe that the impact of this is that the environment variables will now be "logical paths" inside workflows. As these are not physical paths, commands cannot use them.
RUNNER_TOOL_CACHEFORGEJO_OUTPUT,FORGEJO_STATE,FORGEJO_PATH,FORGEJO_ENV,FORGEJO_STEP_SUMMARY, which are all derived from theact_pathIn other words,
run: echo "myvalue=outputvalue1" >> $FORGEJO_OUTPUTwill be a command that references a "logical path", which if my understanding is correct, is not a path that the shell will actually be able to access.By the way, I am experimenting with the protocol here by writing a Rust-based systemd-nspawn plugin. Mostly I'm finding that systemd-nspawn may be a bad fit, due to its limited mechanisms for interacting with processes inside the containers. But I thought I'd share it here for the fun.
I do have feedback from this experimentation, but I'll hold onto it for the moment for further evaluation.
7716b0ec5cd63cccde5a@mfenniak wrote in #1500 (comment):
You are correct. I clarified the protocol and updated the reference plugin to translate canonical paths in both Copy RPCs and Exec environment values. I also added a regression test for writing through $FORGEJO_OUTPUT.
d63cccde5ab0f1d0e37044d85130014e634c017e4e634c017efcf89dc3f4I have pushed a few proposed updates to this branch:
!1500 (commit
db1a90ce71) -- fixes the CI build error (I hope; tested locally, but we'll see the CI output.)!1500 (commit
4b70e45500) -- adds missing license headers to the files- @eleboucher I have assumed you would make this contribution under the GPL licensing terms that Forgejo-Runner is typically distributed under, but if you have an objection please let me know.
!1500 (commit
2cf4439d1f) -- adds missing license header to the plugin.proto file- While most of forgejo/runner is distributed under the terms of GPL-3.0-or-later, this plugin definition file is more permissively licensed under the MIT license. This choice allows plugin authors to embed it, create derived works of it (e.g. generated source files), and distribute derived products under a wider variety of licenses.
- @eleboucher, as the author you would have the absolute right to make this choice, this is just my proposal.
- @aahlenst & @limiting-factor, would like to lean on your licensing expertise and opinion, if you feel this is a good choice.
!1500 (commit
5794237e53) -- updates the protobuf generation makefile rule to be consistent with tooling used in https://code.forgejo.org/forgejo/actions-proto, which also ensures that the tool's dependencies are pinned in theMakefileand can be updated by renovate. Also adds validation during CI that the generated files are up-to-date.!1500 (commit
fcf89dc3f4) -- removes the concept of a "canonical" / "logical" path. Moves the path definitions fromCapabilitiesResponsetoCreateResponse, so that they can simply be defined by the plugin on each environment. @eleboucher I'd propose this as an alternative to "translate canonical paths in both Copy RPCs and Exec environment values", as I feel that behaviour is not something I'd expect to have to do as a plugin author.cascading-pr updated at actions/setup-forgejo#1076
@mfenniak wrote in #1500 (comment):
I think MIT is a good choice for interoperability. I prefer copyleft in general but acknowledge that public domain or permissive licenses can be justified if it helps with interoperability.
MIT is the same license that's already being used for the Actions protocol. That makes sense to me.
(We could also use the GPL with some sort of classpath exception, but I assume that our appetite for experiments is low and I don't see the need for it.)
All good for me
and regarding license i also have some problem with finding the right one on my own projects so i'm happy to let expert decide for me :D
fcf89dc3f46ad9258c7ecascading-pr updated at actions/setup-forgejo#1076
My intent is to merge this soon. I'm working through my systemd-nspawn based plugin with the goal to get all the basics working with the plugin API to ensure there are no immediate blocker bugs.
fcf89dc3f4..6ad9258c7eis a bugfix for an issue that I introduced in my last change.RUNNER_TEMPwas only ever sent to the plugin during thecreategRPC call, so moving it to be initialized after thecreatecall didn't work out in reality. I've adjusted it to be sent with everyexec.Implementing
copy_out, and testing the output capabilities, is my remaining testing work. I expect to be done within a day.feat(plugin): add gRPC v1 plugin backend supportto feat(plugin): add experimental gRPC v1alpha plugin backend supportThanks @eleboucher for all the work on this plugin interface!
I've updated the description of the PR with some notes on what I mean by alpha, and experimental, as this will be linked to the release notes when this is released.
I've created a few issues which represent observations from creating a proof-of-concept implementation with the plugin: #1673, #1674, #1675, #1676, #1677, #1678, #1679, #1680, #1681, #1682, #1683. This may seem like a lot of issues, but none of them were blockers -- either small stumbling blocks or features we should think about and design. No intent that any one person does them either. I intend to look into a few of these as I have time myself.
(My POC is somewhat perfectly working, with a small scope, in systemd-nspawn containers. A fun piece of technical work. https://forgejo.kainnef.com/mfenniak/runner-systemd-nspawn/)