Commit 76798d8f authored by Albert Salim's avatar Albert Salim

Fix broken review-cleanup job

The automated clean up job required ruby 3.0.0.
However, the image with ruby 3.0.0 does not contain
`gcloud`, which is also needed in the job.

This changes the script to be compatible with
ruby that is lower than 3.0.0 and reverts the image used.
parent d6f264fc
......@@ -2,7 +2,7 @@ review-cleanup:
extends:
- .default-retry
- .review:rules:review-cleanup
image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-helm3.5-kubectl1.17
image: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-helm3-kubectl1.14
stage: prepare
environment:
name: review/auto-cleanup
......
......@@ -142,10 +142,13 @@ module Tooling
def resources_created_before_date(response, date)
items = JSON.parse(response)['items'] # rubocop:disable Gitlab/Json
items.filter_map do |item|
items.each_with_object([]) do |item, result|
item_created_at = Time.parse(item.dig('metadata', 'creationTimestamp'))
item.dig('metadata', 'name') if item_created_at < date
if item_created_at < date
resource_name = item.dig('metadata', 'name')
result << resource_name
end
end
rescue ::JSON::ParserError => ex
puts "Ignoring this JSON parsing error: #{ex}\n\nResponse was:\n#{response}" # rubocop:disable Rails/Output
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment