mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2024-11-24 21:58:46 +03:00
Merge pull request 'add combined labels back to registry' (#176) from thefox/runner:label_loading_patch into main
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/176 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
This commit is contained in:
commit
5e51d8ed42
4 changed files with 48 additions and 0 deletions
|
@ -1,5 +1,11 @@
|
||||||
# Release Notes
|
# Release Notes
|
||||||
|
|
||||||
|
## 3.4.2
|
||||||
|
|
||||||
|
* [Fix label declaration](https://code.forgejo.org/forgejo/runner/pulls/176): Runner in daemon mode now takes labels found in config.yml into account when declaration was successful.
|
||||||
|
* [Fix the docker compose example](https://code.forgejo.org/forgejo/runner/pulls/175) to workaround the race on labels.
|
||||||
|
* [Fix the kubernetes dind example](https://code.forgejo.org/forgejo/runner/pulls/169).
|
||||||
|
|
||||||
## 3.4.1
|
## 3.4.1
|
||||||
|
|
||||||
* Fixes a regression introduced in 3.4.0 by which a job with no image explicitly set would
|
* Fixes a regression introduced in 3.4.0 by which a job with no image explicitly set would
|
||||||
|
|
|
@ -111,6 +111,7 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command,
|
||||||
log.Infof("runner: %s, with version: %s, with labels: %v, declared successfully",
|
log.Infof("runner: %s, with version: %s, with labels: %v, declared successfully",
|
||||||
resp.Msg.Runner.Name, resp.Msg.Runner.Version, resp.Msg.Runner.Labels)
|
resp.Msg.Runner.Name, resp.Msg.Runner.Version, resp.Msg.Runner.Labels)
|
||||||
// if declared successfully, override the labels in the.runner file with valid labels in the config file (if specified)
|
// if declared successfully, override the labels in the.runner file with valid labels in the config file (if specified)
|
||||||
|
runner.Update(ctx, ls)
|
||||||
reg.Labels = ls.ToStrings()
|
reg.Labels = ls.ToStrings()
|
||||||
if err := config.SaveRegistration(cfg.Runner.File, reg); err != nil {
|
if err := config.SaveRegistration(cfg.Runner.File, reg); err != nil {
|
||||||
return fmt.Errorf("failed to save runner config: %w", err)
|
return fmt.Errorf("failed to save runner config: %w", err)
|
||||||
|
|
|
@ -242,3 +242,7 @@ func (r *Runner) Declare(ctx context.Context, labels []string) (*connect.Respons
|
||||||
Labels: labels,
|
Labels: labels,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Runner) Update(ctx context.Context, labels labels.Labels) {
|
||||||
|
r.labels = labels
|
||||||
|
}
|
||||||
|
|
37
internal/app/run/runner_test.go
Normal file
37
internal/app/run/runner_test.go
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package run
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"gitea.com/gitea/act_runner/internal/pkg/labels"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestLabelUpdate(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
ls := labels.Labels{}
|
||||||
|
|
||||||
|
initialLabel, err := labels.Parse("testlabel:docker://alpine")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
ls = append(ls, initialLabel)
|
||||||
|
|
||||||
|
newLs := labels.Labels{}
|
||||||
|
|
||||||
|
newLabel, err := labels.Parse("next label:host")
|
||||||
|
assert.NoError(t, err)
|
||||||
|
newLs = append(newLs, initialLabel)
|
||||||
|
newLs = append(newLs, newLabel)
|
||||||
|
|
||||||
|
runner := Runner{
|
||||||
|
labels: ls,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.Contains(t, runner.labels, initialLabel)
|
||||||
|
assert.NotContains(t, runner.labels, newLabel)
|
||||||
|
|
||||||
|
runner.Update(ctx, newLs)
|
||||||
|
|
||||||
|
assert.Contains(t, runner.labels, initialLabel)
|
||||||
|
assert.Contains(t, runner.labels, newLabel)
|
||||||
|
}
|
Loading…
Reference in a new issue