1
0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2026-10-24 16:59:19 +03:00
Files
runner/act/plugin/errors.go
Erwan Leboucher 55b6724479 feat(plugin): add experimental gRPC v1alpha plugin backend support (#1500)
Implements an experimental gRPC protocol for plugable backend systems, per https://code.forgejo.org/forgejo/forgejo-actions-feature-requests/issues/107#issuecomment-85284.

---

(Notes from @mfenniak, Forgejo merger):

Implements an experimental gRPC protocol for plugable backend systems, per https://code.forgejo.org/forgejo/forgejo-actions-feature-requests/issues/107#issuecomment-85284.  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.

---

<!--start release-notes-assistant-->
<!--URL:https://code.forgejo.org/forgejo/runner-->
- features
  - [PR](https://code.forgejo.org/forgejo/runner/pulls/1500): <!--number 1500 --><!--line 0 --><!--description ZmVhdChwbHVnaW4pOiBhZGQgZXhwZXJpbWVudGFsIGdSUEMgdjFhbHBoYSBwbHVnaW4gYmFja2VuZCBzdXBwb3J0-->feat(plugin): add experimental gRPC v1alpha plugin backend support<!--description-->
<!--end release-notes-assistant-->

Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/1500
Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org>
2026-08-16 00:37:20 +00:00

44 lines
982 B
Go

// Copyright 2026 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: GPL-3.0-or-later
package plugin
import (
"errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// StatusCode walks the wrap chain and returns the first gRPC status code,
// or codes.Unknown if none is present.
func StatusCode(err error) codes.Code {
if err == nil {
return codes.OK
}
for cur := err; cur != nil; cur = errors.Unwrap(cur) {
if st, ok := status.FromError(cur); ok {
return st.Code()
}
}
return codes.Unknown
}
// IsRetryable reports whether err is worth retrying against the same plugin.
// ExecError is never retryable; it carries an exit code from user code.
func IsRetryable(err error) bool {
if err == nil {
return false
}
var execErr *ExecError
if errors.As(err, &execErr) {
return false
}
switch StatusCode(err) {
case codes.Unavailable, codes.DeadlineExceeded, codes.Aborted:
return true
default:
return false
}
}