Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: Make context handling for log streaming more explicit #317

Merged
merged 14 commits into from
Apr 28, 2022

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Apr 20, 2022

Part of go-vela/community#562

Overview

This PR comes from my question: "What is responsible for ensuring that all log streaming go routines have returned?"

It addresses two related issues:

  • monitoring stream goroutines to make sure they exit, and do so consistently for Step/Detach Step/Service/secret.
  • allow the log capture go routine to go (at least slightly) longer than the exec even if exec goes past the deadline and gets canceled.

Current state

Nothing is monitoring the log streaming go routines to make sure they exit. ExecStep/ExecService each run StreamStep/StreamService in an errgroup goroutine, but nothing monitors to make sure the goroutine cooperatively exits when the context is canceled (secret.exec+secret.stream are very similar but without using the errgroup). Detached Steps and Services cannot be monitored from within ExecStep/ExecService, so we need to monitor the errgroup somewhere else.

Passing the ctx from ExecBuild through ExecService/ExecStage/ExecStep/secret.exec is problematic because we need to apply a timeout/deadline to that execution, but we want logging capture to continue (at least a bit longer) even when the execution exceeds the deadline to ensure all the logs get captured.

This PR

The exec timeout/deadline context is derived from another context - we make that context have its own cancel function (not a deadline) and then pass that parent context down to the log streaming methods. To facilitate changing the context like that, we now call StreamService/StreamStep/secret.stream from within a new StreamBuild function that runs concurrently with ExecBuild. Exec* signals when to begin streaming logs for a given container using a streamRequests channel.

In other words, this PR implements the idea outlined in go-vela/community#562 (comment), but instead of adding the channel to various function signatures, this adds a streamRequests channel as an internal field on the linux/local executor engine.

How Streaming Starts

Here is the interface for StreamBuild():

// StreamBuild defines a function that receives a StreamRequest
// and then runs StreamService or StreamStep in a goroutine.
StreamBuild(context.Context) error

Here is where ExecStep() sends a message that StreamBuild() listens for (it is similar for service and secret):

// trigger StreamStep goroutine with logging context
c.streamRequests <- message.StreamRequest{
Key: "step",
Stream: c.StreamStep,
Container: ctn,
}

Here is where StreamBuild() receives the message and calls StreamStep() (or StreamService() or secret.stream()):

case req := <-c.streamRequests:
streams.Go(func() error {
// update engine logger with step metadata
//
// https://pkg.go.dev/github.com/sirupsen/logrus?tab=doc#Entry.WithField
logger := c.Logger.WithField(req.Key, req.Container.Name)
logger.Debugf("streaming %s container %s", req.Key, req.Container.ID)
err := req.Stream(streamCtx, req.Container)

Context overview

Here is the build context and the deadline context derived from it. Note that the build context still gets canceled to ensure we don't have zombie log streaming goroutines after the build completes.

// create a background context
buildCtx, done := context.WithCancel(context.Background())
defer done()
// add to the background context with a timeout
// built in for ensuring a build doesn't run forever
ctx, timeout := context.WithTimeout(buildCtx, t)
defer timeout()

The deadline context is used in ExecBuild() (and most other executor.*Build() functions):

logger.Info("executing build")
// execute the build with the executor
err = _executor.ExecBuild(ctx)
if err != nil {
logger.Errorf("unable to execute build: %v", err)
return nil
}

The build context gets passed to StreamBuild() so that it is not subject to the deadline. It is only subject to the end of the build (when exec() returns):

// log streaming uses buildCtx so that it is not subject to the timeout.
go func() {
logger.Info("streaming build logs")
// execute the build with the executor
err = _executor.StreamBuild(buildCtx)
if err != nil {
logger.Errorf("unable to stream build logs: %v", err)
}
}()

Tests

Pretty much all new code is tested (or at least it registers in codecov).

Testing StreamBuild() was interesting because it is designed to run concurrently with AssembleBuild() (which calls secret.exec()) and ExecBuild() (which calls PlanService()/PlanStep() and ExecService()/ExecStep()). So, I used a goroutine to simulate/mock the primary bits of ExecBuild():

// simulate ExecBuild() which runs concurrently with StreamBuild()
go func() {
// ExecBuild calls PlanService()/PlanStep() before ExecService()/ExecStep()
// (ExecStage() calls PlanStep() before ExecStep()).
_engine.err = test.planFunc(_engine)(buildCtx, test.ctn)
// ExecService()/ExecStep()/secret.exec() send this message
streamRequests <- message.StreamRequest{
Key: test.messageKey,
Stream: test.streamFunc(_engine),
Container: test.ctn,
}
// simulate exec build duration
time.Sleep(100 * time.Microsecond)
// signal the end of the build so StreamBuild can terminate
done()
}()

NOTE: The test I added for Linux.WithLogger() is slightly orthogonal to this PR, but it is still "logging" so it works to leave it here.

Utilities

In order to accomplish all of the above, I needed to add a type for the messages that go from ExecStep() and friends to StreamBuild(). I did that in the internal/message package.

// StreamRequest is the message used to begin streaming for a container
// (requests goes from ExecService / ExecStep to StreamBuild in executor).
type StreamRequest struct {
// Key is either "service" or "step".
Key string
// Stream is either Engine.StreamService or Engine.StreamStep.
Stream StreamFunc
// Container is the container for the service or step to stream logs for.
Container *pipeline.Container
}

Initially I tried modifying the signature of various Exec* and Stream* methods, but that meant using an internal type on an exported interface, so I moved the stream to an internal property. Here is the streamRequests channel on the executor:

streamRequests chan message.StreamRequest

Sadly, this broke some of the existing tests because reflect.DeepEqual() couldn't handle the channel. I ended up using cmp.Diff() with a custom Equal(a, b *client) to fix those tests. Here's the Equal function:

// Equal returns true if the other client is the equivalent.
func Equal(a, b *client) bool {
// handle any nil comparisons
if a == nil || b == nil {
return a == nil && b == nil
}
return reflect.DeepEqual(a.Logger, b.Logger) &&
reflect.DeepEqual(a.Vela, b.Vela) &&
reflect.DeepEqual(a.Runtime, b.Runtime) &&
reflect.DeepEqual(a.Secrets, b.Secrets) &&
a.Hostname == b.Hostname &&
a.Version == b.Version &&
reflect.DeepEqual(a.init, b.init) &&
a.logMethod == b.logMethod &&
a.maxLogSize == b.maxLogSize &&
reflect.DeepEqual(a.build, b.build) &&
reflect.DeepEqual(a.pipeline, b.pipeline) &&
reflect.DeepEqual(a.repo, b.repo) &&
reflect.DeepEqual(&a.secrets, &b.secrets) &&
reflect.DeepEqual(&a.services, &b.services) &&
reflect.DeepEqual(&a.serviceLogs, &b.serviceLogs) &&
reflect.DeepEqual(&a.steps, &b.steps) &&
reflect.DeepEqual(&a.stepLogs, &b.stepLogs) &&
// do not compare streamRequests channel
reflect.DeepEqual(a.user, b.user) &&
reflect.DeepEqual(a.err, b.err)
}

And here's a test that uses it:

// Comparing with reflect.DeepEqual(x, y interface) panics due to the
// unexported streamRequests channel.
if diff := cmp.Diff(want, got, cmp.Comparer(linux.Equal)); diff != "" {
t.Errorf("linux Engine mismatch (-want +got):\n%v", diff)
}

Visual Overview

I have a map of methods in the Worker to help myself navigate through the callstack.

This is the relevant section that shows how we're moving the Stream*() calls from Exec*() (the ❌ (red x) marks where these are removed) to StreamBuild() which is now called in a goroutine (the top layer in the diagram).

image

@cognifloyd cognifloyd added the enhancement Indicates an improvement to a feature label Apr 20, 2022
@cognifloyd cognifloyd self-assigned this Apr 20, 2022
@codecov
Copy link

codecov bot commented Apr 22, 2022

Codecov Report

Merging #317 (ebd5738) into master (1518490) will increase coverage by 0.81%.
The diff coverage is 94.07%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #317      +/-   ##
==========================================
+ Coverage   79.68%   80.49%   +0.81%     
==========================================
  Files          67       67              
  Lines        4962     5081     +119     
==========================================
+ Hits         3954     4090     +136     
+ Misses        862      847      -15     
+ Partials      146      144       -2     
Impacted Files Coverage Δ
executor/local/build.go 77.27% <78.57%> (+0.14%) ⬆️
executor/linux/build.go 74.57% <90.90%> (+1.41%) ⬆️
executor/linux/linux.go 100.00% <100.00%> (ø)
executor/linux/opts.go 100.00% <100.00%> (+8.33%) ⬆️
executor/linux/secret.go 71.84% <100.00%> (+1.38%) ⬆️
executor/linux/service.go 63.06% <100.00%> (+0.52%) ⬆️
executor/linux/step.go 65.68% <100.00%> (+0.57%) ⬆️
executor/local/local.go 100.00% <100.00%> (ø)
executor/local/opts.go 100.00% <100.00%> (ø)
executor/local/service.go 93.87% <100.00%> (+3.06%) ⬆️
... and 7 more

kneal
kneal previously approved these changes Apr 25, 2022
Copy link
Contributor

@kneal kneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐬

@cognifloyd
Copy link
Member Author

I renamed logCtx to streamCtx because I will probably use StreamBuild to stream events as well as logs in the Kubernetes runtime (in a future PR).

I did the rename now since I was also merging in master, and that'll reduce the diff for the next PR without changing the diff/functionality of this one.

I will probably use StreamBuild to stream events as well as logs
in the Kubernetes runtime, so let's just add rename this var now
for clarity.
kneal
kneal previously approved these changes Apr 27, 2022
Copy link
Contributor

@kneal kneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐬

executor/linux/build.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@wass3r wass3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm as well - thanks for all the work! if you want to make that one log level change, i think we're good.

i do see some inconsistencies with logging mentioned somewhere else too, sometimes using .WithFields and duplicating info in the actual message and sometimes not, but that's outside of the scope of this PR.

@cognifloyd cognifloyd requested review from wass3r and kneal April 28, 2022 01:10
@cognifloyd
Copy link
Member Author

@wass3r Fixed the log entry. :) This should be ready when you are.

Copy link
Contributor

@kneal kneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐬

@wass3r wass3r merged commit c0823e8 into go-vela:master Apr 28, 2022
plyr4 added a commit that referenced this pull request Aug 31, 2023
* chore: update go version to 1.16 (#202)

* chore: upgrade dependencies for v0.9.0-rc2 (#203)

* chore: upgrade dependencies for v0.9.0-rc3 (#204)

* chore: upgrade dependencies for v0.9.0 (#207)

* fix(deps): update module github.com/gin-gonic/gin to v1.7.4 (#205)

Co-authored-by: Renovate Bot <[email protected]>

* docs - remove use at your own risk language (#208)

* fix(deps): update module github.com/joho/godotenv to v1.4.0 (#209)

Co-authored-by: Renovate Bot <[email protected]>

* feat(log streaming): add ability to stream step and service logs (#211)

* chore: release v0.10.0-rc1 (#212)

* chore: release v0.10.0-rc2 (#213)

* chore: release v0.10.0-rc3 (#214)

* chore: release v0.10.0 (#216)

* fix(register): handle nil response (#217)

* chore(deps): update postgres docker tag to v14 (#210)

Co-authored-by: Renovate Bot <[email protected]>

* remove/fix broken links (#218)

* feat(internal): add internal logic from pkg-executor (#219)

* feat(internal): add logic from pkg-executor

* chore: clean go dependencies

* chore: address linter feedback

* feat(executor): add executor logic from pkg-executor (#220)

* feat(executor): add logic from pkg-executor

* chore: clean go dependencies

* feat(internal): add logic from pkg-runtime (#221)

* feat(runtime): add logic from pkg-runtime (#222)

* fix(deps): update module github.com/docker/docker to v20.10.10 (#226)

Co-authored-by: Renovate Bot <[email protected]>

* refactor: update queue packge to get from server (#225)

Co-authored-by: Neal Coleman <[email protected]>

* fix(deps): update deps (patch) (#227)

Co-authored-by: Renovate Bot <[email protected]>

* refactor: update compiler package to get from server (#228)

* feat(mock): add logic from go-vela/mock (#229)

Co-authored-by: Kelly Merrick <[email protected]>

* refactor: pull server mock package from server (#230)

* feat: enable streaming logs for container (#233)

* revert: stream container logs

* feat: add flag to enable streaming logs

* feat(executor): add logic to stream logs if enabled

* enhance: make log publishing method configurable

* enhance: use configurable log publishing method

* chore: configure time log publish method for local

* chore: address linter feedback

* chore: fix tests for code changes

* chore: address linter feedback v2

* chore: release v0.11.0-rc1 (#234)

* fix: compare time chunks against zero (#235)

* chore: release v0.11.0-rc3 (#236)

* chore(v0.11.0): update dependencies for v0.11.0 (#238)

* fix(deps): update module github.com/opencontainers/image-spec to v1.0.2 (#237)

Co-authored-by: Renovate Bot <[email protected]>

* enhance: setting version information (#240)

* enhance(version): add fallback for empty tag

* enhance(version): use go version from runtime library

* chore: clean go code

* fix(deps): update deps (patch) to v0.22.4 (#241)

* fix: move Step init logic to library (#239)

* StepFromContainer -> StepFromContainerEnvironment

* Use library.StepFromBuildContainer to create new Steps

* update go-vela/types

* go mod tidy

Co-authored-by: David May <[email protected]>

* fix(deps): update module github.com/gin-gonic/gin to v1.7.6 (#242)

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Jordan Brockopp <[email protected]>

* fix(deps): update module github.com/gin-gonic/gin to v1.7.7 (#243)

Co-authored-by: Renovate Bot <[email protected]>

* fix: local setup with server (#245)

* feat(logs): allow setting max log size (#244)

* chore: update go-vela/server dependency (#252)

* enhance: use application logger (#246)

* fix(docker): pulling images without output (#253)

* chore(deps): update go to 1.17 (#255)

* fix(deps): update kubernetes packages to v0.23.1 (#250)

* feat(secrets): mask secrets in logs (#254)

* initial changes

* add some replace logic for secret masking

* bringing in new types

* fix go mod validate

* multi line compatibility and initial testing work

* added testing for internal secret masking

* add back accidental deletion of error checking

Co-authored-by: Jordan Brockopp <[email protected]>

* fix(deps): update module gotest.tools/v3 to v3.1.0 (#256)

Co-authored-by: Renovate Bot <[email protected]>

* chore: update copyright year to 2022 (#257)

* update copyright year to 2022

* fix quotes

* fix(deps): update module github.com/prometheus/client_golang to v1.12.0 (#259)

Co-authored-by: Renovate Bot <[email protected]>

* fix(deps): update module github.com/google/go-cmp to v0.5.7 (#260)

Co-authored-by: Renovate Bot <[email protected]>

* fix(deps): update deps (patch) to v0.23.2 (#262)

Co-authored-by: Renovate Bot <[email protected]>

* chore(step): clean up masking routine due to types change (#261)

* first commit

* adding new name due to types change

* enhance(spec): automate worker api spec generation (#258)

* chore(release): v0.12.0-rc1 (#264)

* fix(deps): update deps (patch) (#265)

Co-authored-by: Renovate Bot <[email protected]>

* fix(deps): update module github.com/prometheus/client_golang to v1.12.1 (#266)

Co-authored-by: Renovate Bot <[email protected]>

* chore(deps): bump server and sdk to latest rc (#268)

* chore(release): v0.12.0 (#269)

* fix(deps): update module github.com/docker/distribution to v2.8.0 (#270)

Co-authored-by: Renovate Bot <[email protected]>

* fix(step): add catch block for disallowed secrets (#272)

* add catch block for unallowed secrets

* adding test case

* fix(deps): update deps (patch) to v0.23.4 (#273)

Co-authored-by: Renovate Bot <[email protected]>

* fix(deps): update module github.com/go-vela/server to v0.12.1 (#276)

Co-authored-by: Renovate Bot <[email protected]>

* chore(dep): update containerd to 1.4.8 (#278)

* refactor: docs for local setup (#275)

* chore(deps): update actions/checkout action to v3 (#281)

Co-authored-by: Renovate Bot <[email protected]>

* chore: update Golangci config & clean repo (#282)

* add new yml config

* lint wsl

* replace golint fals pos with revive false pos

* remove nolintlints

* lint funlen

* noctx

* govet -> goheader

* errorlint

* remove lll false pos, lint contextcheck

* lint dupl

* lint nilerr

* remove false positives

* clean

* remove changelog code

* chore(dep): update containerd to 1.4.13 (#283)

* fix(deps): update module github.com/docker/distribution to v2.8.1 (#284)

Co-authored-by: Renovate Bot <[email protected]>

* chore: release v0.13.0-rc1 (#285)

* refactor(logs): Replace "Pulling" with "Preparing" in init step logs (#287)

* refactor(kubernetes): Refactor watch related code (#288)

* test(kubernetes): Test TailContainer happy path (#289)

* fix(deps): update module github.com/urfave/cli/v2 to v2.4.0 (#290)

* chore: update contributing (#291)

* chore(release): updates for v0.13.0-rc2 (#292)

* fix(deps): update deps (patch) to v0.23.5 (#293)

Co-authored-by: Renovate Bot <[email protected]>

* chore: Add tests for runtime WithLogger opt (#295)

* chore(release): dependency updates for v0.13.0 (#297)

* feat(kubernetes): Add PipelinePodsTemplate CRD to define worker-specific Pod defaults for Kubernetes Runtime (#294)

* chore(deps): update codecov/codecov-action action to v3 (#298)

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: David May <[email protected]>

* fix(deps): update module sigs.k8s.io/yaml to v1.3.0 (#301)

* refactor: silence lint issues (#307)

* bugfix(k8s): add newline to init step output (#309)

* revert(k8s): Revert go-vela/pkg-runtime#151 (#306)

* bugfix(k8s): avoid InspectContainer panic where container is not Terminated (#308)

* tests: Convert runtime tests to subtests (#312)

* refactor: drop duplicate executor.DestroyBuild call (#313)

* bugfix(k8s): avoid "index out of range" panic by replacing magic indexes with containerLookup map (#311)

* refactor: cleanup context passing in kubernetes runtime (#314)

* tests: Convert executor tests to subtests (#315)

* tests: Convert internal/ tests to subtests (#316)

* fix(ci): Fix silent failures in GHA reviewdog workflow (#319)

* fix(deps): update deps (patch) (#310)

Co-authored-by: Renovate Bot <[email protected]>

* fix(deps): update module gotest.tools/v3 to v3.2.0 (#321)

* fix(deps): update module github.com/urfave/cli/v2 to v2.4.8 (#320)

* enhancement: Make context handling for log streaming more explicit (#317)

* bugfix(k8s): skip false error in logs correctly (#323)

* chore(deps): update dependency redis to v7 (#328)

* chore(deps): update github/codeql-action action to v2 (#322)

* fix(deps): update module github.com/urfave/cli/v2 to v2.5.1 (#325)

* fix(deps): update module github.com/google/go-cmp to v0.5.8 (#327)

* bugfix: make sure kubernetes log streaming gets canceled with build (#329)

* refactor(executor): clarify why use different contexts (#304)

* feat(internal/skip): add event action handling for skip method (#326)

* fix(deps): update deps (patch) (#330)

* enhance(kubernetes): Add podTracker and containerTracker to use k8s API more like a k8s controller (#302)

* fix(executor): tests from compiler changes (#332)

* chore(release): dependency updates for v0.14.0-rc1 (#333)

* fix(deps): update kubernetes packages to v0.24.0 (#334)

Co-authored-by: Renovate Bot <[email protected]>

* fix(deps): update module github.com/urfave/cli/v2 to v2.6.0 (#335)

* bugfix(k8s): Drop TailContainer's logsContext to avoid early cancel (#337)

* fix(deps): update module github.com/prometheus/client_golang to v1.12.2 (#341)

* fix(deps): update golang.org/x/sync digest to 0976fa6 (#342)

* fix(deps): update module github.com/urfave/cli/v2 to v2.8.1 (#343)

* fix(deps): update deps (patch) to v0.24.1 (#344)

* test: add API mock for Vela Worker (#338)

* fix(deps): update module github.com/gin-gonic/gin to v1.8.0 (#345)

* fix(deps): update golang.org/x/sync digest to 0de741c (#346)

* add tag to ruleset for deployment event, if it is from a tag #606 (#347)

* chore(release): v0.14.0-rc2 (#348)

* fix(deps): update module github.com/gin-gonic/gin to v1.8.1 (#349)

* chore(release): v0.14.0-rc3 (#350)

* fix(deps): update module gotest.tools/v3 to v3.3.0 (#352)

* fix(deps): update deps (patch) to v0.24.2 (#351)

* chore(release): dependency updates for v0.14.0 (#353)

* enhance(local executor): print to stdout via client field (#339)

* fix(deps): update module github.com/sirupsen/logrus to v1.9.0 (#356)

* fix(deps): update module github.com/urfave/cli/v2 to v2.11.1 (#354)

* fix(deps): update golang.org/x/sync digest to 886fb93 (#358)

* fix(deps): update module github.com/prometheus/client_golang to v1.13.0 (#362)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update deps (patch) to v0.14.3 (#355)

* Allow creating mocks via `runtime.New()` (#340)

* fix(deps): update module github.com/google/go-cmp to v0.5.9 (#369)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(go): update to 1.19 (#370)

* fix(deps): update golang.org/x/sync digest to f12130a (#364)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(lint): fix linter errors in worker codebase (#371)

* chore(lint): fix linter errors in worker codebase

* go mod tidy

* fixing struct check

Co-authored-by: David May <[email protected]>
Co-authored-by: dave vader <[email protected]>

* feat(start/server): add minimum TLS version of 1.2 with option to set it differently (#368)

* fix(deps): update kubernetes packages to v0.25.0 (#365)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/docker/go-units to v0.5.0 (#366)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/docker/docker to v20.10.18+incompatible (#373)

* fix(deps): update module github.com/docker/docker to v20.10.18+incompatible

* fix it

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: wass3r <[email protected]>

* chore: change default branch to main (#378)

* fix(deps): update deps (patch) to v0.25.1 (#377)

* fix(deps): update deps (patch) to v0.25.2 (#379)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update golang.org/x/sync digest to 7f9b162 (#380)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore: v0.15.0-rc1 prep (#381)

* fix(deps): update module github.com/urfave/cli/v2 to v2.17.1 (#383)

* fix(deps): update golang.org/x/sync digest to 8fcdb60 (#382)

* chore: v0.15.0-rc2 (#384)

* chore: v0.15.0 release prep (#385)

* fix(actions): make sure to use latest Go version (#386)

* chore: update deps for v0.15.1 (#387)

* wip: queue public key for opening signed items

* revert: changes for testing

* fix: tidy

* refactor: move kubernetes runtime mock code to separate file (#389)

* Merge pull request from GHSA-2w78-ffv6-p46w

* feat!: gate privileged images behind trusted repos (#391)

* chore(release): v0.16.0 prep (#399)

* fix(deps): update module gotest.tools/v3 to v3.4.0 (#388)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update deps (patch) (#392)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update postgres docker tag to v15 (#393)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module golang.org/x/sync to v0.1.0 (#394)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(release): v0.16.1 prep (#400)

* chore(release): 0.16.2 prep (#402)

* refactor(k8s): move test logic to MockKubernetesRuntime interface (#395)

* refactor(executor tests): cleanup test names and errors (#396)

* fix: Allow log streaming to take longer than build execution (#390)

* fix(deps): update module github.com/urfave/cli/v2 to v2.23.6 (#401)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/masterminds/semver/v3 to v3.2.0 (#404)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update elgohr/publish-docker-github-action action to v5 (#406)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update kubernetes packages to v0.26.0 (#407)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix: revert log streaming commit (#409)

* feat(stage): stages fail independently when continue is set to true (#318)

* first draft

* changing dependent to continue and ditching print statements

* changing continue to independent and linter work

* adding new types in go mod

* go mod tidy

* adding additional stop check in stage loop and more comments

Co-authored-by: David May <[email protected]>

* fix: move trusted repos check to handle dynamic images (#405)

* chore: remove code of conduct in favor of global version (#403)

Co-authored-by: dave vader <[email protected]>

* chore(release): dependency updates for v0.17.0-rc1 (#412)

* fix: improve streaming coordination so it does not hang (#410)

* fix(deps): update deps (patch) (#413)

* chore(release): update dependencies for v0.17.0 (#415)

* refactor(executor tests): Make runtime a test arg (#418)

* enhance(executor tests): test StreamBuild logging during build tests (#419)

* enhance(executor tests): Sanitize pipelines to handle runtime specific differences (#422)

* enhance(executor tests): Add test helpers to generate test Pods (#424)

* test: add kubernetes baseline for Create funcs

* test: add kubernetes runtime for stages

* test: prepare for test specific pod in executor test

* test: add testPod helper method

* test: add testPodFor(pipeline) helper method

* test: mark secret containers terminated in test Pods

* test: use pipeline-specific runtime instances

* test: Create runtime for each executor build test

* test: Adds several new test helpers.

---------

Co-authored-by: JordanBrockopp <[email protected]>

* enhance(executor tests): Call k8s SetupMock method after CreateBuild in tests (#425)

* enhance: extract kubernetes runtime mock setup

In order to run the PodTracker mock setup in executor tests,
we need to export something

* Call k8s SetupMock in executor Build test

* test: Add kubernetes SetupMock to executor StreamBuild test

* mark exported k8s Mock functions as test-only functions

* fix(tests): accommodate clone image change in server (#417)

* feat(build_token): worker changes for build token implementation (#427)

* enhance(executor tests): Manage k8s mocks for Executor exec tests (#431)

* enhance(executor tests):  Manage k8s mocks for Executor AssembleBuild test (#432)

* test: Fix kubernetes tests for executor AssembleBuild

Adds some new WaitForPod* test helpers.

* sort imports in runtime/kubernetes/kubernetes.go

* test: add pause to simulate step execution

* AssembleBuild test does not need to mark steps running

* fix(deps): update deps (patch) (#414)

* Update spec.yml (#416)

Co-authored-by: David May <[email protected]>
Co-authored-by: Kelly Merrick <[email protected]>

* fix(deps): update module github.com/gin-gonic/gin to v1.9.0 (#426)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/joho/godotenv to v1.5.1 (#423)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/urfave/cli/v2 to v2.24.4 (#420)

* chore: upgrade to docker v23 and add new mocked funcs (#433)

* Revert "chore: upgrade to docker v23 and add new mocked funcs (#433)" (#435)

This reverts commit 3a4c3a2.

* chore(release): v0.18.0-rc1 prep (#436)

* chore(release): v0.18.0-rc1 prep

* tidy up

* chore(release): v0.18.0-rc2 prep (#444)

* chore(release): upgrade server, types, sdk to v0.18.0 (#445)

* chore: v0.18.1 (#446)

* chore(log): remove byte-chunks log method (#447)

* enhance(executor tests): Add kubernetes runtime test cases for Build tests (#438)

* test(executor): add kubernetes runtime to CreateBuild test

* test: Use kubernetes runtime in executor build tests

The kubernetes Mock does not support some of the failure modes simulated
by the docker Mock. So, those test cases are commented out with a FIXME.

* cleanup commented blocks

* test(executor): add remaining StreamBuild k8s test cases

---------

Co-authored-by: JordanBrockopp <[email protected]>
Co-authored-by: Easton Crupper <[email protected]>
Co-authored-by: David May <[email protected]>

* enhance(executor tests): Add kubernetes runtime test cases for Opts and Secrets tests (#439)

* enhance(executor tests): Add kubernetes runtime test cases for Step tests (#440)

* enhance(executor tests): Add kubernetes runtime test cases for Stage tests (#441)

* enhance(executor tests): Add kubernetes runtime test cases for Service tests (#442)

* feat: use validate-token endpoint in MustServer (#449)

* enhance(auth): implement registration flow (#452)

* initial work

* more work

* backwards compatibility with comments

* adjust middleware to only use validate-token for server tokens

* more work

* rename auth token channel to RegisterToken

* rename token channel and update api comments

* updating some comments and not loggin token

* fix docker compose

* fix local replace

* token expiration func has two return vals

* docker compose no register

* name register token middleware file correctly

* update swagger for register

* feat(mock): add support for register endpoint (#457)

* feat(runtime/docker): add drop kernel capabilities option to runtime flags (#454)

* capabilities

* docker compose revert + opencontainers version

* revert lots of go mod stuff

* fix copy pasta and add a test in opts

* enhance: operate/exec logging (#461)

* chore(deps): update actions/setup-go action to v4 (#448)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update deps (patch) (#443)

* fix(deps): update module github.com/urfave/cli/v2 to v2.25.1 (#453)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/docker/docker to v20.10.24+incompatible [security] (#456)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update module github.com/prometheus/client_golang to v1.15.0 (#460)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix(deps): update kubernetes packages to v0.27.1 (#459)

* fix(deps): update kubernetes packages to v0.27.1

* fix(deps): update kubernetes packages to v0.27.1

* update runtime k8s container to use proper type for log func

* gosimple lint fix

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: ecrupper <[email protected]>

* chore(release): upgrade types, server, sdk to v19 rc1 (#463)

* fix: err shadowing (#464)

* fix(register): verify hostname (#465)

* chore(release): upgrade server and sdk to rc2 (#466)

* chore(release): upgrade sdk, server, types to v0.19.0 for release (#467)

* chore(release): upgrade types, server, worker to v0.19.1 (#468)

* chore(release): upgrade server, types, sdk to v0.19.2 (#470)

* enhance(exec): do not kill worker if build has been canceled and build token minting fails (#472)

* enhance(exec): do not kill worker if build has been canceled and build token minting fails

* change status code to 409 conflict

* upgrade server

* chore: add vscode project files to gitignore (#469)

Co-authored-by: Easton Crupper <[email protected]>

* fix: generate example keys

* tweak: env var naming

* feat!: Use queue Item.ItemVersion field to fail stale builds (#478)

* feat: add support for schedules (#479)

* feat: add support for schedules

* chore: update go dependencies

* chore: update go deps

* chore: vscode gitignore from toptal (#476)

* enhance(log): no library log return for update calls (#485)

* chore(deps): bulk update (#487)

* feat(worker-visibility): allow update to worker table with status and build info (#482)

* feat(register-and-operate): add ability for worker to update status to idle and error

* docs(README): showing off commitizen cli

* feat: update worker status and runningBuildIDs

* feat: worker can update runningBuildIDs and status

* chore(exec): clean up logging for worker database updates

* feat(worker): update last_build_ timestamps in the database

* fix(worker-visibility): update error to make logrus happy

* chore(worker_visibility): update deps for types and server

* Update cmd/vela-worker/register.go

Co-authored-by: David May <[email protected]>

* add res nil check

* move res nil above err

* add res nil check

* more accurate logging

* make clean

---------

Co-authored-by: Tim Huynh <[email protected]>
Co-authored-by: David May <[email protected]>

* chore(release): upgrade types, server, sdk to v0.20.0-rc1 (#489)

* fix(compose): use hashicorp/vault docker repo (#490)

* fix(deps): update module gotest.tools/v3 to v3.5.0 (#491)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(release): bump server and sdk to v0.20.0-rc3 (#492)

* chore(release): upgrade types, server, sdk-go to v0.20.0 (#494)

* chore(release): ugprade types, server, sdk to v0.20.1 + other deps (#496)

* chore(release): ugprade types, server, sdk to v0.20.1 + other deps

* pin to alpine version

* chore: go mod tidy

* chore: reorganize compose vars

* chore: simplify queue env variable names

* chore: bump server

* chore: tweak var naming

* todo: build executables types change

* chore: go mod tidy

---------

Co-authored-by: Kelly Merrick <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: David May <[email protected]>
Co-authored-by: Jordan Sussman <[email protected]>
Co-authored-by: kaymckay <[email protected]>
Co-authored-by: Jordan Brockopp <[email protected]>
Co-authored-by: Neal <[email protected]>
Co-authored-by: Neal Coleman <[email protected]>
Co-authored-by: David Vader <[email protected]>
Co-authored-by: Jacob Floyd <[email protected]>
Co-authored-by: Easton Crupper <[email protected]>
Co-authored-by: DaxJohnson <[email protected]>
Co-authored-by: DaxJohnson <[email protected]>
Co-authored-by: JayCeeJr <[email protected]>
Co-authored-by: wass3r <[email protected]>
Co-authored-by: JordanBrockopp <[email protected]>
Co-authored-by: David May <[email protected]>
Co-authored-by: ecrupper <[email protected]>
Co-authored-by: Tim Huynh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Indicates an improvement to a feature
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants