Introduce Redis store to track last destroyed old pipeline's created_at
What does this MR do and why?
Introduce Redis store to track the last processed pipeline's created_at
to optimize Ci::DestroyOldPipelinesWorker
References
How to set up and validate locally
timestamp = Time.current
tracker = Ci::RetentionPolicies::ProjectPipelineDeletionTracker.instance
project = Project.first
# set project `ci_delete_pipelines_in_seconds`
project.ci_delete_pipelines_in_seconds= 86400
project.save
# to set the redis key
tracker.add_or_update(project, timestamp)
# to fetch the value
result = tracker.fetch_timestamp(project)
timestamp.to_i == result
# to delete the redis key
tracker.delete(project)
# validate if it's deleted
tracker.fetch_timestamp(project)
# should return nil
# validate project retention policy update settings
tracker.add_or_update(project, timestamp)
# update project `ci_delete_pipelines_in_seconds`
project.ci_delete_pipelines_in_seconds= 172800
project.save
# validate by fetch
tracker.fetch_timestamp(project)
# should return nil
# add value to new retention policy setting
tracker.add_or_update(project, timestamp)
result = tracker.fetch_timestamp(project)
result == timestamp.to_i
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.