Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: install go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: install go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
Expand All @@ -55,7 +55,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
uses: github/codeql-action/init@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -66,7 +66,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
uses: github/codeql-action/autobuild@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -80,4 +80,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@51f77329afa6477de8c49fc9c7046c15b9a4e79d # v3.29.5
uses: github/codeql-action/analyze@3c3833e0f8c1c83d449a7478aa59c036a9165498 # v3.29.11
12 changes: 6 additions & 6 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
# ensures we fetch tag history for the repository
fetch-depth: 0
Expand All @@ -43,14 +43,14 @@ jobs:
make build-static-ci

- name: login to dockerhub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: extract metadata
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
with:
images: target/vela-worker
tags: |
Expand All @@ -72,7 +72,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
# ensures we fetch tag history for the repository
fetch-depth: 0
Expand All @@ -98,14 +98,14 @@ jobs:
make build-static-ci

- name: login to dockerhub
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: extract metadata
id: meta
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
with:
images: target/vela-worker
tags: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
# ensures we fetch tag history for the repository
fetch-depth: 0
Expand Down Expand Up @@ -66,7 +66,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
# ensures we fetch tag history for the repository
fetch-depth: 0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: install go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: install go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: install go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: install go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
Expand All @@ -35,7 +35,7 @@ jobs:
make test

- name: coverage
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
uses: codecov/codecov-action@fdcc8476540edceab3de004e990f80d881c6cc00 # v5.5.0
with:
use_oidc: true
files: coverage.out
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- name: install go
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
Expand Down
6 changes: 5 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ linters:
- unparam
- unused
- whitespace
- wsl
- wsl_v5
settings:
dupl:
threshold: 100
Expand All @@ -51,6 +51,10 @@ linters:
require-explanation: true
require-specific: true
allow-unused: false
wsl_v5:
allow-first-in-block: true
allow-whole-block: false
branch-max-lines: 2
exclusions:
generated: lax
presets:
Expand Down
7 changes: 4 additions & 3 deletions cmd/vela-worker/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
// exec is a helper function to poll the queue
// and execute Vela pipelines for the Worker.
//
//nolint:nilerr,funlen // ignore returning nil - don't want to crash worker
//nolint:gocyclo,funlen // ignore cyclomatic complexity and function length
func (w *Worker) exec(index int, config *api.Worker) error {
var err error

Expand Down Expand Up @@ -347,6 +347,7 @@ func (w *Worker) exec(index int, config *api.Worker) error {
// log/event streaming uses buildCtx so that it is not subject to the timeout.
go func() {
defer wg.Done()

logger.Info("streaming build logs")
// execute the build with the executor
err = _executor.StreamBuild(buildCtx)
Expand All @@ -372,9 +373,9 @@ func (w *Worker) getWorkerStatusFromConfig(config *api.Worker) string {
switch rb := len(config.GetRunningBuilds()); {
case rb == 0:
return constants.WorkerStatusIdle
case rb < w.Config.Build.Limit:
case rb < int(w.Config.Build.Limit):
return constants.WorkerStatusAvailable
case rb == w.Config.Build.Limit:
case rb == int(w.Config.Build.Limit):
return constants.WorkerStatusBusy
default:
return constants.WorkerStatusError
Expand Down
2 changes: 1 addition & 1 deletion cmd/vela-worker/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func flags() []cli.Flag {

// Build Flags

&cli.IntFlag{
&cli.Int32Flag{
Name: "build.limit",
Usage: "maximum amount of builds that can run concurrently",
Sources: cli.EnvVars("WORKER_BUILD_LIMIT", "VELA_BUILD_LIMIT", "BUILD_LIMIT"),
Expand Down
6 changes: 3 additions & 3 deletions cmd/vela-worker/operate.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (w *Worker) operate(ctx context.Context) error {
registryWorker.SetHostname(w.Config.API.Address.Hostname())
registryWorker.SetAddress(w.Config.API.Address.String())
registryWorker.SetActive(true)
registryWorker.SetBuildLimit(int32(w.Config.Build.Limit))
registryWorker.SetBuildLimit(w.Config.Build.Limit)

// set routes from config if set or defaulted to `vela`
if (len(w.Config.Queue.Routes) > 0) && (w.Config.Queue.Routes[0] != "NONE" && w.Config.Queue.Routes[0] != "") {
Expand Down Expand Up @@ -131,7 +131,6 @@ func (w *Worker) operate(ctx context.Context) error {
}

w.QueueCheckedIn, err = w.queueCheckIn(gctx, registryWorker)

if err != nil {
// queue check in failed, retry
logrus.Errorf("unable to ping queue %v", err)
Expand Down Expand Up @@ -162,7 +161,7 @@ func (w *Worker) operate(ctx context.Context) error {
})

// iterate till the configured build limit
for i := 0; i < w.Config.Build.Limit; i++ {
for i := 0; i < int(w.Config.Build.Limit); i++ {
// evaluate and capture i at each iteration
//
// https://github.com/golang/go/wiki/CommonMistakes#using-goroutines-on-loop-iterator-variables
Expand Down Expand Up @@ -193,6 +192,7 @@ func (w *Worker) operate(ctx context.Context) error {

continue
}

select {
case <-gctx.Done():
logrus.WithFields(logrus.Fields{
Expand Down
6 changes: 3 additions & 3 deletions cmd/vela-worker/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ func run(ctx context.Context, c *cli.Command) error {
},
// build configuration
Build: &Build{
Limit: int(c.Int("build.limit")),
Limit: c.Int32("build.limit"),
Timeout: c.Duration("build.timeout"),
},
// build configuration
CheckIn: c.Duration("checkIn"),
// executor configuration
Executor: &executor.Setup{
Driver: c.String("executor.driver"),
MaxLogSize: uint(c.Uint("executor.max_log_size")),
MaxLogSize: c.Uint("executor.max_log_size"),
LogStreamingTimeout: c.Duration("executor.log_streaming_timeout"),
EnforceTrustedRepos: c.Bool("executor.enforce-trusted-repos"),
OutputCtn: outputsCtn,
Expand Down Expand Up @@ -172,5 +172,5 @@ func run(ctx context.Context, c *cli.Command) error {
}

// start the worker
return w.Start()
return w.Start(ctx)
}
10 changes: 8 additions & 2 deletions cmd/vela-worker/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (
// serve traffic for web and API requests. The
// operator subprocess enables the Worker to
// poll the queue and execute Vela pipelines.
func (w *Worker) Start() error {
func (w *Worker) Start(ctx context.Context) error {
// create the context for controlling the worker subprocesses
ctx, done := context.WithCancel(context.Background())
ctx, done := context.WithCancel(ctx)
// create the errgroup for managing worker subprocesses
//
// https://pkg.go.dev/golang.org/x/sync/errgroup#Group
Expand All @@ -47,17 +47,21 @@ func (w *Worker) Start() error {
select {
case sig := <-signalChannel:
logrus.Infof("Received signal: %s", sig)

err := server.Shutdown(ctx)
if err != nil {
logrus.Error(err)
}

done()
case <-gctx.Done():
logrus.Info("Closing signal goroutine")

err := server.Shutdown(ctx)
if err != nil {
logrus.Error(err)
}

return gctx.Err()
}

Expand All @@ -67,7 +71,9 @@ func (w *Worker) Start() error {
// spawn goroutine for starting the server
g.Go(func() error {
var err error

logrus.Info("starting worker server")

if tlsCfg != nil {
if err := server.ListenAndServeTLS(w.Config.Certificate.Cert, w.Config.Certificate.Key); !errors.Is(err, http.ErrServerClosed) {
// log a message indicating the start of the server
Expand Down
2 changes: 1 addition & 1 deletion cmd/vela-worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type (

// Build represents the worker configuration for build information.
Build struct {
Limit int
Limit int32
Timeout time.Duration
}

Expand Down
2 changes: 1 addition & 1 deletion executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ var (
ID: "step_github_octocat_1_init",
Directory: "/home/github/octocat",
Image: "#init",
Name: "init",
Name: constants.InitName,
Number: 1,
Pull: "always",
},
Expand Down
Loading
Loading