diff options
author | James Lopez <james@jameslopez.es> | 2016-06-16 15:07:49 +0300 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-06-16 15:07:49 +0300 |
commit | 2a747d386dbdc05453fce6b8be3f483e8cd9e796 (patch) | |
tree | 5530f2fb8856c4e29a33afb128843108e2bb5834 /app/workers | |
parent | 862b359b9a3f271b23f393932fb0e85d65c56c6b (diff) | |
parent | 778d72664f386dfee45dab171f137395739958f6 (diff) |
fixed merge conflicts
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/expire_build_artifacts_worker.rb | 13 | ||||
-rw-r--r-- | app/workers/stuck_ci_builds_worker.rb | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/app/workers/expire_build_artifacts_worker.rb b/app/workers/expire_build_artifacts_worker.rb new file mode 100644 index 00000000000..c64ea108d52 --- /dev/null +++ b/app/workers/expire_build_artifacts_worker.rb @@ -0,0 +1,13 @@ +class ExpireBuildArtifactsWorker + include Sidekiq::Worker + + def perform + Rails.logger.info 'Cleaning old build artifacts' + + builds = Ci::Build.with_expired_artifacts + builds.find_each(batch_size: 50).each do |build| + Rails.logger.debug "Removing artifacts build #{build.id}..." + build.erase_artifacts! + end + end +end diff --git a/app/workers/stuck_ci_builds_worker.rb b/app/workers/stuck_ci_builds_worker.rb index ca594e77e7c..6828013b377 100644 --- a/app/workers/stuck_ci_builds_worker.rb +++ b/app/workers/stuck_ci_builds_worker.rb @@ -6,7 +6,7 @@ class StuckCiBuildsWorker def perform Rails.logger.info 'Cleaning stuck builds' - builds = Ci::Build.running_or_pending.where('updated_at < ?', BUILD_STUCK_TIMEOUT.ago) + builds = Ci::Build.joins(:project).running_or_pending.where('ci_builds.updated_at < ?', BUILD_STUCK_TIMEOUT.ago) builds.find_each(batch_size: 50).each do |build| Rails.logger.debug "Dropping stuck #{build.status} build #{build.id} for runner #{build.runner_id}" build.drop |