summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-17 00:08:12 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-17 00:08:12 +0000
commitf52c68bbac191605f793686c472425b000a0879a (patch)
tree1d85443e61577794ce0df8c28534411c4e2bf979 /scripts
parent9a107fa4c14448945a3189fef35b11e0cafb0285 (diff)
downloadgitlab-ce-f52c68bbac191605f793686c472425b000a0879a.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/review_apps/automated_cleanup.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/review_apps/automated_cleanup.rb b/scripts/review_apps/automated_cleanup.rb
index 40dd81e071d..5fff7f4ff88 100755
--- a/scripts/review_apps/automated_cleanup.rb
+++ b/scripts/review_apps/automated_cleanup.rb
@@ -36,8 +36,6 @@ module ReviewApps
@api_endpoint = api_endpoint
@dry_run = options[:dry_run]
@environments_not_found_count = 0
-
- puts "Dry-run mode." if dry_run
end
def gitlab
@@ -65,6 +63,7 @@ module ReviewApps
end
def perform_gitlab_environment_cleanup!(days_for_delete:)
+ puts "Dry-run mode." if dry_run
puts "Checking for Review Apps not updated in the last #{days_for_delete} days..."
checked_environments = []
@@ -106,6 +105,7 @@ module ReviewApps
end
def perform_gitlab_docs_environment_cleanup!(days_for_stop:, days_for_delete:)
+ puts "Dry-run mode." if dry_run
puts "Checking for Docs Review Apps not updated in the last #{days_for_stop} days..."
checked_environments = []
@@ -140,6 +140,7 @@ module ReviewApps
end
def perform_helm_releases_cleanup!(days:)
+ puts "Dry-run mode." if dry_run
puts "Checking for Helm releases that are failed or not updated in the last #{days} days..."
threshold = threshold_time(days: days)
@@ -162,12 +163,14 @@ module ReviewApps
end
def perform_stale_namespace_cleanup!(days:)
+ puts "Dry-run mode." if dry_run
kubernetes_client = Tooling::KubernetesClient.new(namespace: nil)
kubernetes_client.cleanup_review_app_namespaces(created_before: threshold_time(days: days), wait: false) unless dry_run
end
def perform_stale_pvc_cleanup!(days:)
+ puts "Dry-run mode." if dry_run
kubernetes.cleanup_by_created_at(resource_type: 'pvc', created_before: threshold_time(days: days), wait: false) unless dry_run
end
@@ -257,7 +260,11 @@ module ReviewApps
end
def threshold_time(days:)
- Time.now - days * 24 * 3600
+ days_integer = days.to_i
+
+ raise "days should be an integer between 1 and 365 inclusive! Got #{days_integer}" unless days_integer.between?(1, 365)
+
+ Time.now - days_integer * 24 * 3600
end
def ignore_exception?(exception_message, exceptions_ignored)