Skip to content

[builds-api.start] Cleanup old builds when triggering a new one

Raymond Ndibe requested to merge cleanup_old_pipelineruns into main
  • extract pipelineRuns().List operation into a getPipelineRuns function for reusability
  • create cleanupOldPipelineRuns and other helper functions
  • write functional tests

For now the function cleanupOldPipelineRuns is discarding every pipelinerun that is not of the following status ["running", "ok", "cancelled"], and only some pipelineruns of the status "ok" and "cancelled". It is important to note that we don't touch running pipelineruns. This means that if a user submits multiple builds, all those running builds won't be touched until the next build operation after they have completed running. Because of this there exist a period of time between the end of the previous build and the next build where a pipelinerun that should be cleaned up still exists. The duration of this time period can be reduced by moving the cleanupOldPipelineRuns to a higher-order method ( haven't tested it yet but addHandlers in main.go looks like a good candidate )

Bug: T337389 Signed-off-by: Ndibe Raymond Olisaemeka NdibeRaymond1@gmail.com

Merge request reports