Repository navigation
Follow-up for #7876 - #7914
Follow-up for #7876#7914
Conversation
got rid of the stupid second query! Thanks Clara! Signed-off-by: Taylor Silva <[email protected]>
The last_scheduled column represents the last time that the job was checked by the scheduler/algorithm, which does not always result in a new build being made. The updated query now checks when the latest_completed_build_id for jobs in a pipeline was last finished. Signed-off-by: Taylor Silva <[email protected]>
|
@clarafu made a change to the query to not use I have an idea for integration tests that I'll add soon. |
|
Vague idea of running an integration test that relies on changing postgres's time:
|
|
@taylorsilva I just read the original PR #7876, can you please add a info log when pauses a pipeline? When user reports any issue, for example, if a user escalates that his pipeline is pauses, the first we do would search for ATC logs for clues. |
|
@evanchaoli That's fine, can add that. In that PR though, when this component pauses a pipeline it does show that it was paused by this component: concourse/atc/db/pipeline_pauser.go Line 52 in 312aa55 So a user will see |
We don't even assert anything after running it. Must have been a bad copy-paste. Signed-off-by: Taylor Silva <[email protected]>
A user will see on the UI "Paused by automatic-pipeline-pauser <some-date>" Signed-off-by: Taylor Silva <[email protected]>
It will log each pipeline that it pauses. Logs at the info level for successful pipelines. Logs at the error level if it failes to pause the pipeline. Signed-off-by: Taylor Silva <[email protected]>
This commit contains a failing test. I realized that a pipeline that was set but never ran, like a newly set pipeline, would result in the pipeline being paused. I wrote a test and made a change to the query to fix that. I then realized that this change makes it so any pipeline that has a job with zero builds impossible for the pauser to ever pause the pipeline. I added a test for this and it is the failing test in this commit. I currently can't think of a query to get around this issue. Depending on discussion this test or the first test may be removed. For the first test I added I see this as kinda an edge case. I feel like it's extremely unlikely that someone will set a pipeline AND unpause it at the exact time the pauser runs, which is currently once every 24hrs. I ran into this when trying to setup an integration test for the pauser and found that the pauser kept pausing my newly set pipeline before I could trigger my pipelines job. That's the context on how I found this issue. Signed-off-by: Taylor Silva <[email protected]>
|
@clarafu My idea to use libfaketime worked for postgres but doesn't work for golang: wolfcw/libfaketime#195 I did end up finding other issues while building out the integration. From my latest commit: Any ideas for a query that can pass both tests? |
That's cool, didn't realize that, while I think a log line will be still helpful for daily OPs. |
|
Hmm I'm not too familiar with how to fake it out but one thing I can think (but might not be the best if you don't want to add more flags) is to add a flag that allows the user to configure the interval time for this pipeline pauser component. For example, we have the build tracker that runs every 10s on default but you can change that interval time concourse/atc/atccmd/command.go Line 201 in 2edd994 |
|
yeahhh I had that thought earlier too. I think there's a flag for that library that lets me hide it too. That'll probably be the way to go for that. |
The pipeline pauser will pause any pipelines that have zero builds across all active jobs. This is unlikely to be an issue for most users since the pauser is designed to only run once per day. Signed-off-by: Taylor Silva <[email protected]>
WHAT A PAIN IT WAS TO WRITE THIS. So first, getting faketime with postgres was an ADVENTURE. Faketime only works the first time you bring prostgres up, after that it borks and time goes back to now instead of whatever future/present time you set. Therefore the test HAS to start in the past. Second PIA was that having the db in the past breaks the component runner because it uses the date from postgres and go's time.Now() to deteremine if the interval has elapsed. So having postgres in the past means EVERY component runs every 10s. I had to set the pauser interval to a crazy high number to ensure it'll only run once on startup and then not run again. Also Go doesn't work with faketime so that's why postgres is using it and not Concourse. Apparently Go does some assembly nonsense to figure out the time instead of making kernel syscalls tldr: time is really hard to fake Signed-off-by: Taylor Silva <[email protected]>
|
@clarafu I DID IT! This was the biggest PIA test to write 😭 but it works! It passes! This is good to review and imo good to ship. |
| ResourceWithWebhookCheckingInterval time.Duration `long:"resource-with-webhook-checking-interval" default:"1m" description:"Interval on which to check for new versions of resources that has webhook defined."` | ||
| MaxChecksPerSecond int `long:"max-checks-per-second" description:"Maximum number of checks that can be started per second. If not specified, this will be calculated as (# of resources)/(resource checking interval). -1 value will remove this maximum limit of checks per second."` | ||
| PausePipelinesAfter int `long:"pause-pipelines-after" default:"0" description:"The number of days after which a pipeline will be automatically paused if none of its jobs have run in more than the given number of days. A value of zero disables this component."` | ||
| PipelinePauserInterval time.Duration `long:"pipeline-pauser-interval" default:"24h" hidden:"true" description:"The frequency on which the Pipeline Pauser component will be run to check if any pipelines need to be paused."` |
There was a problem hiding this comment.
this flag is hidden so it doesn't need to be added to the chart and bosh release. Only exposed to make integration testing possible.
After many days of this being in the back of my mind I thought of a solution I liked to fix the edge case where someone just set a pipeline and none of its builds have run. Previously a pipeline in that state would be paused. This is no longer the case. I added an additional clause to the query to only get pipelines that were also last_updated more than 24hrs ago. 24hrs should be long enough for someone to have created at least one build for their pipeline. Also made the integration test simpler, no more goroutine to continously pause the pipeline. I also realized this was a race condition for any test if the pauser was configured. This should make the pauser friendlier to use. Signed-off-by: Taylor Silva <[email protected]>
|
Went back to that edge case and fixed it. Added a clause so it only pauses pipelines that were updated more than 24hrs ago. |
clarafu
left a comment
There was a problem hiding this comment.
Wow thanks for all the work for adding the integration test for this!! :D
j.next_build_id contains the ID of the currently running build. This ID is cleared when the build is marked as finished. Signed-off-by: Taylor Silva <[email protected]>
|
Good catch @clarafu |
|
Tests are failing with |
clarafu
left a comment
There was a problem hiding this comment.
Thanks for all the work on the tests and fixes!! I just ran some acceptance testing against it and everything works great :D
These were the cases that I covered in my manual testing:
- pipeline was paused for job that had a build older than configured pause pipelines after interval
- pipeline was not paused when they had a running/pending build
- pipeline was not paused when configured within 1 day
Follow-up for #7876
Implement Clara's suggestion. Got rid of the stupid second query! Thanks @clarafu!
TODO: