Repository navigation
Run checks as builds - #6022
Merged
Merged
Run checks as builds#6022
Conversation
vito
force-pushed
the
checks-as-builds
branch
3 times, most recently
from
August 28, 2020 00:12
243a13f to
07ad3c5
Compare
vito
force-pushed
the
checks-as-builds
branch
5 times, most recently
from
September 12, 2020 23:34
f6f7beb to
9ff72a8
Compare
vito
marked this pull request as ready for review
September 12, 2020 23:38
vito
force-pushed
the
checks-as-builds
branch
from
September 17, 2020 19:17
8ef4fb7 to
e667119
Compare
aoldershaw
added a commit
that referenced
this pull request
Sep 21, 2020
Previously, we were constructing step delegates and passing them into the step directly. This commit instead passes in a step delegate factory, and the steps construct the step delegate at runtime. p.s. there was a delegate factory that existed before, but it was kinda useless - #6022 got rid of it entirely. This may seem like a useless change, and for the time being it is. The motivation for this is to allow the step delegate to be constructed using information that can only exist at runtime. In particular, the step delegates currently require vars.BuildVariables in order to: 1. Expose creds and local variables to the steps 2. Perform secret redaction In coming commits, I plan to extend the `RunState` that's passed into every `Step` to also deal with variables, rather than relying on a step delegate to expose this. This are a few motivations for this: 1. Allow things to be interpolated more easily - a big driving force behind this change is to make it possible to interpolate most everything in a build plan. This could've been done by injecting a step delegate into every step type, but that felt awkward 2. Make the across step construction less awkward - since step delegates had to be constructed statically with their local vars at build time, we needed some tricky logic in the builder to figure out what to run in parallel. This proved to be difficult to test, leading to a lack of test coverage. 3. Opens the door for the across step to run with a dynamic list of values. This is definitely down the line, and requires other changes to make it work, but requiring the variables to be set at build time makes this impossible. It also would mean you can't interpolate individual values (i.e. not the full list), which *is* something that should be possible with the static across step p.s. this commit removes some test coverage for the across step around properly setting the variable scopes. I'll add this back in a later commit Signed-off-by: Aidan Oldershaw <[email protected]>
3 of 11 tasks
vito
force-pushed
the
checks-as-builds
branch
from
September 22, 2020 18:26
e667119 to
61411ab
Compare
vito
added a commit
to concourse/ci
that referenced
this pull request
Sep 23, 2020
just grep for 'succeeded', which should continue to work with concourse/concourse#6022 Signed-off-by: Alex Suraci <[email protected]>
this seems to unnecessarily complicate the codebase, and i don't think many people use it or even know it exists or what it's for. this field makes it so that, with global resources enabled, resources using the type will have their own unique history, rather than being global. this is really just to support the time resource, so that all jobs don't run on the same interval. but the time resource is built in, not a custom type, so let's just reserve this behavior for built-in resource types only until we eventually remove it. note: i did a code search to see if i could find anyone using this in the wild, and there was only result, and it was for the cron resource, which doesn't benefit from unique history anyway (unlike the time resource). Signed-off-by: Alex Suraci <[email protected]>
checks are turning into builds, so clients can use the builds api to monitor checks instead. remove Check and AllCheckables methods from CheckFactory, since this was the only place they were used Signed-off-by: Alex Suraci <[email protected]>
this will no longer be necessary, as checks will be queued as builds, and thus go through the regular old build tracker removing this so that the StartedChecks method along with the engine checking code can be removed. note: will need to add rate limiting to the build tracker to preserve rate limiting behavior Signed-off-by: Alex Suraci <[email protected]>
previously the check step was completely reliant on the delegate and metadata to figure out the resource config and scope to save to. now the check step constructs its own config and scope at runtime based on the evaluated config. this makes the check step more independent, and makes it easier to have multiple check steps in one build plan; previously it would only save to the scope associated with the db.Check, but now that it's decoupled it should easier to run multiple in a db.Build. Signed-off-by: Alex Suraci <[email protected]>
* switch everything from db.Check to db.Build now that it's not used in the delegate. * when building a plan, check for .Check field in plan and construct a check step - previously this was only respected when constructing a step for a db.Check. Signed-off-by: Alex Suraci <[email protected]>
as long as we're still using VersionedResourceTypes, we need to make sure that the resource_config_id column gets updated on resource_types. right now this happens in TryCreateCheck, which is technically fine as long as we're queuing up checks for resource types too, but that's not the plan forever: the goal is to push all the image checking and fetching into the build plan, including resource type images, so that everything works the same way. in the future, there will be builds for resources, but not resource types. builds will check-and-fetch their types as needed, whether they're a build for a resource check or a build for a job. the UpdateResourceType field should be able to go away once this is all farther along - in particular, once we're able to remove VersionedResourceTypes by having steps refer to previous 'check' and/or 'get' steps which determine their type version and image. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
as-is, this will be pretty wasteful: it'll end up queueing a bunch of redundant checks for resources with the same config/scope, and they'll all run their checks, pretty much undoing the benefits of global resources. the next step is to mitigate this by having the 'check' step regulate itself by skipping the check if its interval has not elapsed, while locking to prevent concurrent checks of the same scope. with that mitigation, there will still be the overhead of queueing and builds for all resources for each scope to check, but at least the build will do something useful: its check step will update the config/scope on the resource or resource type. Signed-off-by: Alex Suraci <[email protected]>
* if the interval has not elapsed since the last check end time, skip the check * if the build is manually triggered, ignore the interval and run immediately note: the method is called WaitAndRun because this is where we can add back the rate limiting, which used to be done in the resource checker. interestingly, this also lets us consider having it wait until the interval elapses. then there'd be two kinds of rate limiting: limit each scope to once every interval, and limit all checking overall just so things aren't so spikey. one neat thing that might enable in the future is to have much more responsive webhook handling: rather than webhooks triggering builds, they could just wake up a goroutine in a build that's already running. that shoud have much lower latency - great for snappy webhook responsiveness. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
this could be avoided by showing the resource's check build output and/or status in the UI instead, which would also allow the resource to still be pointed to its old scope, so at least the version history doesn't get wiped out. Signed-off-by: Alex Suraci <[email protected]>
Signed-off-by: Alex Suraci <[email protected]>
also remove no-longer-used secretManager field and AcquireScanningLock method, which was replaced by the generic component locking system. Signed-off-by: Alex Suraci <[email protected]>
the checker no longer exists! (this commit also removes the now-unused component const.) note that this notification is no longer needed because (db.Build).Start, called by TryCreateCheck, already notifies the build tracker. this can be verified by the fact that `fly check-resource` runs pretty much immediately even while this notification was going nowhere. slight behavior difference from before this refactor: we now send N notifications instead of 1 per scanner tick, but we'll see if that's problematic. (guessing not.) Signed-off-by: Alex Suraci <[email protected]>
no longer used; checks are builds now Signed-off-by: Alex Suraci <[email protected]>
aoldershaw
approved these changes
Oct 4, 2020
aoldershaw
left a comment
Contributor
There was a problem hiding this comment.
I can't find anything wrong with it - seems like a pretty awesome cleanup, and I really like the new streaming check output and the implications this brings for running checks in regular build plans
Contributor
Author
|
@aoldershaw thanks for the feedback + review! |
11 tasks
muntac
added a commit
to concourse/concourse-bosh-release
that referenced
this pull request
Oct 5, 2020
removed in concourse/concourse#6022 Signed-off-by: Muntasir Chowdhury <[email protected]>
2 of 11 tasks
vito
added a commit
to vito/concourse
that referenced
this pull request
Oct 6, 2020
this ain't a thing anymore with concourse#6022 Signed-off-by: Alex Suraci <[email protected]>
vito
added a commit
that referenced
this pull request
Oct 6, 2020
this ain't a thing anymore with #6022 Signed-off-by: Alex Suraci <[email protected]>
3 of 11 tasks
This was referenced Oct 22, 2020
aoldershaw
added a commit
that referenced
this pull request
Oct 26, 2020
With #6022, we delete the previous build for a resource/resource type check when we create a new one. However, since there's no foreign key contraint on build_events.build_id, the build events never actually get deleted. We actually don't want a cascading delete on build_events, though, since deleting pipelines would become super slow (currently, we're able to just truncate/drop the pipeline_build_events table, but if deletes cascaded, we'd end up performing a ton of row deletions, which is much slower in postgres). So instead, let's just delete the build events when we delete the corresponding build. Signed-off-by: Aidan Oldershaw <[email protected]>
11 tasks
aoldershaw
added a commit
to aoldershaw/docs
that referenced
this pull request
May 17, 2021
it was removed in concourse/concourse#6022 Signed-off-by: Aidan Oldershaw <[email protected]>
kcbimonte
pushed a commit
to Aviator-Labs/docs-ci
that referenced
this pull request
Sep 26, 2026
it was removed in concourse/concourse#6022 Signed-off-by: Aidan Oldershaw <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR accomplish?
Feature
This PR removes the
checkstable and LIDAR checker and runs checks as builds instead. They can now be viewed in the web UI, andfly check-resourceandfly check-resource-typewill stream the build logs. It's kind of neat!TODO
builds.idabigintChanges proposed by this PR:
Side note: I would recommend reading each commit's message.
The following is a broad overview of the changes.
Removes
resource_types.unique_version_history. This is a breaking change but it should have little to no real-world impact.atc.VersionedResourceTypesaround. This felt unnecessarily complicated for something that's never really used.Modifies the
checkstep to adopt more of the functionality previously implemented by the LIDAR checker or other components.checkstep more liberally, for example for image resource fetching. By pushing more behavior down into it, we can reuse it more easily while having it "do the right thing."Removes the LIDAR checker, the checks API, the
checkstable, and thedb.Checktype.Motivation: in order to use the
checkstep for image fetching it needs to be able to exist in anatc.Planwhich also has agetstep (for fetching the image) and whatever step needs to run (ataskor a resource using a resource type).They way the code was structured before, a
checkstep could only be run for adb.Check, and the LIDAR checker could only run if the plan had a singleCheckPlanas the only step. (It would actually panic if it was anything but.)Modifies the LIDAR scanner (and check factory) to create a
db.Buildinstead ofdb.Check.db.CheckFactorytype now creates adb.Build. I think this can be cleaned up in a future refactor which cleans up the job + resource/resource type build scheduling patterns.checkstep capable of doing all that on its own, all LIDAR has to do is queue up a build that runs it. The build will be run by the build tracker.Simplifies resource config GC - rather than referencing
resource_config_check_sessions, add a time-based "last referenced" GC.checkstep creates its own config + scope, I needed a way to ensure the config doesn't get GC'd before it's assigned to the resource. A simple timestamp seems to do the trick, and allows the config GC query to be simplified a bit - we don't need to referenceresource_config_check_sessionsanymore, because the "last referenced" timestamp will always be bumped by thecheckstep anyway.Adds support for rendering
checksteps in the web UI and sending check output to the build event stream.Consolidates build tracing/logging data into
(db.Build).TracingAttrsand(db.Build).LagerData.Notes to reviewer:
Sorry this is so big - this is actually split out from a bigger refactor to replace the special-cased image fetching path with a composition of
checkandgetsteps. I found that this was not possible to do becausechecksteps could only be run for adb.Checkand not within adb.Build, so here I am!There are a ton of changes here - I would recommend reviewing commit-by-commit. I spent a lot of time rebasing and amending to make sure each commit can be reviewed in isolation.
Release Note
unique_version_historycan no longer be configured on resource types. No one seemed to be using it, and it made internal architecture unnecessarily complicated. The need for it should go away entirely as we make progress on the v10 roadmap.checkoperations, which collect and save versions for pipeline resources, are now run as builds.fly check-resourceandfly check-resource-typenow stream the checking output to the user, just likefly watchandfly trigger-job.idcolumn of thebuildstable and all tables referencingbuild_idto abigint. This is unfortunately a slow migration, so please anticipate downtime proportional to the amount of builds in your database.deadlock detected, shut down the otherwebnodes first.Contributor Checklist
Reviewer Checklist
BOSH and
Helm packaging; otherwise, ignored for
the integration
tests
(for example, if they are Garden configs that are not displayed in the
--helptext).