Repository navigation
Smarter resource checking - Only check triggering resources - #9492
Conversation
83ad44f to
fdb2b15
Compare
and have the BuildStarter in the atc/scheduler/ package create check builds for input resources, if necessary. Overall this should result in a lot less checks happening, which means less hammaring of external systems (i.e. Git servers). When a job is triggered, then all of its inputs will be checked. We skip inputs that are pinned or have passed constraints on them. In both of those cases, checking the resource will not change the list of possible input versions for the job. I debated if the BuildStarter should create in-memory or DB checks. DB checks are de-duplicated at the db level, but will grow the size of that table faster. In-memory checks are de-duplicated at the individual web node. So in multi-web node setups there is a chance that duplicate check builds are made. The only negative consequence of this is that the check runs twice instead of once. I decided to use in-memory builds since it maintains current behaviour best. Most checks run as in-memory checks currently via lidar, so I decided to stick with this approach. This PR is mostly shifting who creates the check workloads from Lidar to the Schedular, so I think it makes sense to keep using in-memory checks. Signed-off-by: Taylor Silva <[email protected]>
this is now done in the scheduler, if necessary. Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
We'd do the join and not use it for filtering. I'm guessing we added this thinking we needed it for getting put-only resources. That ended up not being the case though since we use rs.last_check_succeeded and rs.last_check_build_id to get put-only resources. Signed-off-by: Taylor Silva <[email protected]>
We now track when the next check of a resource _should_ occur. This allows us, in the scheduler, to issue checks for resources that have exceeded their check interval. It also allows us to be smarter about which resources we check by inspecting the nextCheckTime of the resource. Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
it was part of the system used before Lidar was made Signed-off-by: Taylor Silva <[email protected]>
because logically it made no difference to what the query would return. The main thing we want to check is if the next_check_time is before the build's created_time. If next_check_time is before the created_time, then last_check_end_time would also be before, we don't need to check it. Signed-off-by: Taylor Silva <[email protected]>
Signed-off-by: Taylor Silva <[email protected]>
f3cf9e6 to
ce99939
Compare
Signed-off-by: Taylor Silva <[email protected]>
For some reason this test is flaky in CI. I haven't gotten it to fail locally (`ginkgo --until-it-fails`) and even `fly intercept`'ing and re-running the test has always resulted in it passing. My gut says this is related to CPU/Memory pressure causing the test to flake, but I'm not 100% sure about that. We also set `--flake-attempts` to 3 and this test fails all three times, which is VERY surprising to me. This makes me think the setup of the test is bad, but I can't see where it could be messing up. The error I keep seeing is that `resources` has a length of three instead of two. I'd expect this to happen if the `BeforeEach()` didn't run. Maybe ginkgo is messing up the parallelization some how?? I'm going to mark the test as `Serial`; maybe we're somehow conflicting with other tests?? I don't see how that would happen, but having it flake like this is very annoying. If setting it to `Serial` makes it pass consistently then I'll do it. Signed-off-by: Taylor Silva <[email protected]>
| It("returns the triggering, and errored put-only resource", func() { | ||
| Expect(resources).To(HaveLen(2)) | ||
| Expect(resources[0].Name()).To(Equal("some-resource-trigger")) | ||
| Expect(resources[1].Name()).To(Equal("some-put-only-resource")) |
There was a problem hiding this comment.
For some reason this test is flaky in CI. I haven't gotten it to fail locally (ginkgo --until-it-fails) and even fly intercept'ing and re-running the test has always resulted in it passing.
My gut says this is related to CPU/Memory pressure causing the test to flake, but I'm not 100% sure about that. We also set --flake-attempts to 3 and this test fails all three times, which is VERY surprising to me. This makes me think the setup of the test is bad, but I can't see where it could be messing up.
The error I keep seeing is that resources has a length of three instead of two. I'd expect this to happen if the BeforeEach() didn't run. Maybe ginkgo is messing up the parallelization some how??
I'm going to mark the test as Serial; maybe we're somehow conflicting with other tests?? I don't see how that would happen, but having it flake like this is very annoying. If setting it to Serial makes it pass consistently then I'll do it.
|
I updated ci.concourse-ci.org to see if anything breaks from this PR. So far everything seems normal. Upgrade was done at 11:08am UTC-4. |
documents concourse/concourse#9492 Signed-off-by: Taylor Silva <[email protected]>
documents concourse/concourse#9492 Signed-off-by: Taylor Silva <[email protected]>


Changes proposed by this PR
closes #1445
The goal of this PR is to reduce the number of resource checks that currently happen in Concourse. I'm going to describe the current behaviour of Concourse and then explain what this PR changes.
Current Behaviour
There are three main ways a build is started: manually triggered, automatic trigger, and rerun of previous build.
In parallel, there is also Lidar running every 10s, looking for any resources that have surpassed their
check_everyinterval. Lidar performs this check for every resource in unpaused pipelines, except resources that are only used in put steps.Manually triggered builds: These happen when a user starts a new build via the web UI or
fly trigger-job. In both of these cases, Concourse will create resource checks for all inputs of the job, overriding the check interval of all resources. The job will only start once all input resources have been checked.Automatically triggered builds: These happen when a check started by Lidar finds a new version of an input to a job. In this case, no extra resource checks are made and the job is started with the latest set of input versions available from all resources of the job.
Rerun builds: These never create checks because they use the previous builds input versions. These are manually created.
With this setup, we end up with a system that is constantly running checks, more than it really needs to. The benefit of this is that when a job is automatically triggered, we don't need to wait for any other resource checks to run, we can just start the build. The con with this approach is that we waste a lot of compute checking resources and end up hammering external systems constantly.
Behaviour Proposed by this PR
Lidar only creates checks for resources that are triggers for jobs, excluding triggers that also have passed constraints. This alone should drop the number of checks regularly occurring in a Concourse cluster.
The API endpoint used to manually trigger new builds no longer creates checks. That is now done by the BuildStarter.
We now move the creation of most resource checks into the
atc/scheduler/package, specifically the BuildStarter.Behaviour is the same for rerun builds, and mostly the same for manually triggered builds. Automatically triggered builds are slightly different.
Manually triggered builds: The check interval of all input resources is overridden, same as previous behaviour when checks were made in the
atc/api/layer. The build is started once all input resources have been checked. The big change here is which resources the job waits to check; only resources that are inputs with no passed constraints.Automatically triggered builds: These builds start after all non-triggering input resources have been checked, if they have passed their check interval. We don't check triggering resources because Lidar will check them, which is the same behaviour as before.
In all cases, when the
BuildStartercreates checks, it won't create checks for resources that are pinned to a specific version, and any that have passed constraints.With checks not constantly running for as many resources, the baseline amount of compute required for a Concourse cluster should be lower on average. External systems will also be hammered much less, though they will see spikes whenever a job starts and all it's non-triggering resources are checked. The con with this approach is that jobs will take longer to start if they need to wait for any resources to be checked.
Migration
There is a migration in this PR that adds a column to help us track when the next check of a resource should occur. The default value this column has for all resources after the migration is applied is Unix epoch. I don't think this should have any adverse affects. Lidar will only check
trigger: truejobs, and whenever a job is scheduled, then all of its inputs will be checked. I don't expect there to be a "stampeding herd" of checks being run after the migration is applied.