mirror of
https://gitea.com/gitea/runner.git
synced 2026-11-11 10:24:09 +00:00
fix!: remove the dbfs log workaround and require Gitea 1.26.2 (#1395)
Gitea 1.26.2 finalizes logs on an empty `UpdateLog` with `NoMore` (https://github.com/go-gitea/gitea/pull/37687), so the sentinel row is no longer needed. On older servers, the final log of most jobs would never be archived and stays in `dbfs_data`, so this raises the minimum Gitea version. It lives in `ver.MinGiteaVersion`, which the error for servers without `Declare` now names. Fixes: https://gitea.com/gitea/runner/issues/953 Co-authored-by: silverwind <[email protected]> Reviewed-on: https://gitea.com/gitea/runner/pulls/1395 Reviewed-by: silverwind <[email protected]> Co-authored-by: bircni <[email protected]>
This commit is contained in:
1 parent
c59caa9689
commit
84c0fcd1fa
6 files changed
+6
-20
No files matched your search
@@ -7,6 +7,7 @@ Gitea Runner runs the jobs of Gitea Actions workflows. Register it with a Gitea
|
|||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- Linux, macOS or Windows, or FreeBSD.
|
- Linux, macOS or Windows, or FreeBSD.
|
||||||
|
- Gitea 1.26.2 or newer.
|
||||||
- `git` 2.34.1 or newer.
|
- `git` 2.34.1 or newer.
|
||||||
- `docker`, or `podman` with `podman.socket` enabled, for `docker` labels and Docker actions. See Docker's [install instructions](https://docs.docker.com/engine/install/).
|
- `docker`, or `podman` with `podman.socket` enabled, for `docker` labels and Docker actions. See Docker's [install instructions](https://docs.docker.com/engine/install/).
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ This uses the recommended Docker-in-Docker image, see [image flavours](../../REA
|
|||||||
timeout: 10s
|
timeout: 10s
|
||||||
environment:
|
environment:
|
||||||
# GITEA_RUNNER_REGISTRATION_TOKEN can be used to set a global runner registration token.
|
# GITEA_RUNNER_REGISTRATION_TOKEN can be used to set a global runner registration token.
|
||||||
# The Gitea version must be v1.23 or higher.
|
|
||||||
# It's also possible to use GITEA_RUNNER_REGISTRATION_TOKEN_FILE to pass the location.
|
# It's also possible to use GITEA_RUNNER_REGISTRATION_TOKEN_FILE to pass the location.
|
||||||
# - GITEA_RUNNER_REGISTRATION_TOKEN=<user-defined registration token>
|
# - GITEA_RUNNER_REGISTRATION_TOKEN=<user-defined registration token>
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ func runDaemon(ctx context.Context, daemArgs *daemonArgs, configFile *string) fu
|
|||||||
case err != nil && ctx.Err() != nil && !client.IsRegistrationRejected(err):
|
case err != nil && ctx.Err() != nil && !client.IsRegistrationRejected(err):
|
||||||
return nil
|
return nil
|
||||||
case err != nil && connect.CodeOf(err) == connect.CodeUnimplemented:
|
case err != nil && connect.CodeOf(err) == connect.CodeUnimplemented:
|
||||||
logging.Errorf("Your Gitea version is too old to support runner declare, please upgrade to v1.21 or later")
|
logging.Errorf("Your Gitea version is too old to support runner declare, please upgrade to v%s or later", ver.MinGiteaVersion)
|
||||||
return err
|
return err
|
||||||
case err != nil:
|
case err != nil:
|
||||||
logging.WithError(err).Error("fail to invoke Declare")
|
logging.WithError(err).Error("fail to invoke Declare")
|
||||||
|
|||||||
@@ -691,22 +691,6 @@ func (r *Reporter) Close(lastWords string) error {
|
|||||||
logging.Errorf("No Response from RunDaemon for %s, continue best effort", r.daemonWait)
|
logging.Errorf("No Response from RunDaemon for %s, continue best effort", r.daemonWait)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gitea's UpdateLog short-circuits on len(Rows)==0 before honoring NoMore,
|
|
||||||
// so a final empty request never runs TransferLogs and dbfs_data leaks.
|
|
||||||
// Inject a sentinel row after the daemon has exited so it can't be flushed
|
|
||||||
// before ReportLog(true).
|
|
||||||
// TODO: Remove after https://github.com/go-gitea/gitea/pull/37631 is in all
|
|
||||||
// supported branches, e.g. v1.28+.
|
|
||||||
r.stateMu.Lock()
|
|
||||||
if len(r.logRows) == 0 {
|
|
||||||
// Not appendLogRow: the sentinel is not job output and has no place in job.log.
|
|
||||||
r.logRows = append(r.logRows, &runnerv1.LogRow{
|
|
||||||
Time: timestamppb.Now(),
|
|
||||||
Content: "",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
r.stateMu.Unlock()
|
|
||||||
|
|
||||||
// Separate budgets so a slow ReportLog can't starve the ReportState that
|
// Separate budgets so a slow ReportLog can't starve the ReportState that
|
||||||
// carries the cancel acknowledgement.
|
// carries the cancel acknowledgement.
|
||||||
err := errors.Join(
|
err := errors.Join(
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ func TestReporter_StateNotifyFlush(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReporter_CloseAlwaysSendsRowsWithNoMore(t *testing.T) {
|
func TestReporter_CloseFinalizesLogWithoutRows(t *testing.T) {
|
||||||
var lastReq atomic.Pointer[runnerv1.UpdateLogRequest]
|
var lastReq atomic.Pointer[runnerv1.UpdateLogRequest]
|
||||||
var noMoreCalls atomic.Int64
|
var noMoreCalls atomic.Int64
|
||||||
|
|
||||||
@@ -400,7 +400,7 @@ func TestReporter_CloseAlwaysSendsRowsWithNoMore(t *testing.T) {
|
|||||||
final := lastReq.Load()
|
final := lastReq.Load()
|
||||||
require.NotNil(t, final)
|
require.NotNil(t, final)
|
||||||
assert.True(t, final.NoMore, "final UpdateLog must carry NoMore=true")
|
assert.True(t, final.NoMore, "final UpdateLog must carry NoMore=true")
|
||||||
assert.NotEmpty(t, final.Rows, "final UpdateLog must carry at least one row")
|
assert.Empty(t, final.Rows, "a job without output must not get a log row")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReporter_StateHeartbeat(t *testing.T) {
|
func TestReporter_StateHeartbeat(t *testing.T) {
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ package ver
|
|||||||
// go build -ldflags "-X gitea.com/gitea/runner/internal/pkg/ver.version=1.2.3"
|
// go build -ldflags "-X gitea.com/gitea/runner/internal/pkg/ver.version=1.2.3"
|
||||||
var version = "dev"
|
var version = "dev"
|
||||||
|
|
||||||
|
const MinGiteaVersion = "1.26.2" // also in the README.md prerequisites
|
||||||
|
|
||||||
func Version() string {
|
func Version() string {
|
||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user