Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9463f3a6
Commit
9463f3a6
authored
Aug 26, 2021
by
Marcel Amirault
Committed by
Rémy Coutable
Aug 26, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a cleanup job for docs review apps
parent
2c66e7b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
scripts/review_apps/automated_cleanup.rb
scripts/review_apps/automated_cleanup.rb
+38
-0
No files found.
scripts/review_apps/automated_cleanup.rb
View file @
9463f3a6
...
...
@@ -95,6 +95,40 @@ class AutomatedCleanup
delete_helm_releases
(
releases_to_delete
)
end
def
perform_gitlab_docs_environment_cleanup!
(
days_for_stop
:,
days_for_delete
:)
puts
"Checking for Docs Review Apps not updated in the last
#{
days_for_stop
}
days..."
checked_environments
=
[]
stop_threshold
=
threshold_time
(
days:
days_for_stop
)
delete_threshold
=
threshold_time
(
days:
days_for_delete
)
max_delete_count
=
1000
delete_count
=
0
gitlab
.
deployments
(
project_path
,
per_page:
DEPLOYMENTS_PER_PAGE
,
sort:
'desc'
).
auto_paginate
do
|
deployment
|
environment
=
deployment
.
environment
next
unless
environment
next
unless
environment
.
name
.
start_with?
(
'review-docs/'
)
next
if
checked_environments
.
include?
(
environment
.
slug
)
last_deploy
=
deployment
.
created_at
deployed_at
=
Time
.
parse
(
last_deploy
)
if
deployed_at
<
delete_threshold
delete_environment
(
environment
,
deployment
)
delete_count
+=
1
break
if
delete_count
>
max_delete_count
elsif
deployed_at
<
stop_threshold
environment_state
=
fetch_environment
(
environment
)
&
.
state
stop_environment
(
environment
,
deployment
)
if
environment_state
&&
environment_state
!=
'stopped'
end
checked_environments
<<
environment
.
slug
end
end
def
perform_helm_releases_cleanup!
(
days
:)
puts
"Checking for Helm releases that are failed or not updated in the last
#{
days
}
days..."
...
...
@@ -203,6 +237,10 @@ timed('Review Apps cleanup') do
automated_cleanup
.
perform_gitlab_environment_cleanup!
(
days_for_stop:
5
,
days_for_delete:
6
)
end
timed
(
'Docs Review Apps cleanup'
)
do
automated_cleanup
.
perform_gitlab_docs_environment_cleanup!
(
days_for_stop:
20
,
days_for_delete:
30
)
end
puts
timed
(
'Helm releases cleanup'
)
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment