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
96195d4f
Commit
96195d4f
authored
Nov 21, 2019
by
Albert Salim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle `Gitlab::Error::Forbidden`
parent
5fad8112
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
scripts/review_apps/automated_cleanup.rb
scripts/review_apps/automated_cleanup.rb
+11
-3
No files found.
scripts/review_apps/automated_cleanup.rb
View file @
96195d4f
...
@@ -75,9 +75,11 @@ class AutomatedCleanup
...
@@ -75,9 +75,11 @@ class AutomatedCleanup
deployed_at
=
Time
.
parse
(
last_deploy
)
deployed_at
=
Time
.
parse
(
last_deploy
)
if
deployed_at
<
delete_threshold
if
deployed_at
<
delete_threshold
delete_environment
(
environment
,
deployment
)
environment
=
delete_environment
(
environment
,
deployment
)
release
=
Quality
::
HelmClient
::
Release
.
new
(
environment
.
slug
,
1
,
deployed_at
.
to_s
,
nil
,
nil
,
review_apps_namespace
)
if
environment
releases_to_delete
<<
release
release
=
Quality
::
HelmClient
::
Release
.
new
(
environment
.
slug
,
1
,
deployed_at
.
to_s
,
nil
,
nil
,
review_apps_namespace
)
releases_to_delete
<<
release
end
elsif
deployed_at
<
stop_threshold
elsif
deployed_at
<
stop_threshold
stop_environment
(
environment
,
deployment
)
stop_environment
(
environment
,
deployment
)
else
else
...
@@ -116,11 +118,17 @@ class AutomatedCleanup
...
@@ -116,11 +118,17 @@ class AutomatedCleanup
def
delete_environment
(
environment
,
deployment
)
def
delete_environment
(
environment
,
deployment
)
print_release_state
(
subject:
'Review app'
,
release_name:
environment
.
slug
,
release_date:
deployment
.
created_at
,
action:
'deleting'
)
print_release_state
(
subject:
'Review app'
,
release_name:
environment
.
slug
,
release_date:
deployment
.
created_at
,
action:
'deleting'
)
gitlab
.
delete_environment
(
project_path
,
environment
.
id
)
gitlab
.
delete_environment
(
project_path
,
environment
.
id
)
rescue
Gitlab
::
Error
::
Forbidden
puts
"Review app '
#{
environment
.
slug
}
' is forbidden: skipping it"
end
end
def
stop_environment
(
environment
,
deployment
)
def
stop_environment
(
environment
,
deployment
)
print_release_state
(
subject:
'Review app'
,
release_name:
environment
.
slug
,
release_date:
deployment
.
created_at
,
action:
'stopping'
)
print_release_state
(
subject:
'Review app'
,
release_name:
environment
.
slug
,
release_date:
deployment
.
created_at
,
action:
'stopping'
)
gitlab
.
stop_environment
(
project_path
,
environment
.
id
)
gitlab
.
stop_environment
(
project_path
,
environment
.
id
)
rescue
Gitlab
::
Error
::
Forbidden
puts
"Review app '
#{
environment
.
slug
}
' is forbidden: skipping it"
end
end
def
helm_releases
def
helm_releases
...
...
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