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
1714c47f
Commit
1714c47f
authored
Apr 09, 2021
by
Matthias Käppler
Committed by
Michael Kozono
Apr 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a chaos endpoint that signals QUIT
parent
b68cada0
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
12 deletions
+60
-12
app/controllers/chaos_controller.rb
app/controllers/chaos_controller.rb
+5
-1
app/workers/chaos/kill_worker.rb
app/workers/chaos/kill_worker.rb
+2
-2
changelogs/unreleased/mk-chaos-quit.yml
changelogs/unreleased/mk-chaos-quit.yml
+5
-0
config/routes.rb
config/routes.rb
+1
-0
doc/development/chaos_endpoints.md
doc/development/chaos_endpoints.md
+24
-4
lib/gitlab/chaos.rb
lib/gitlab/chaos.rb
+3
-3
spec/controllers/chaos_controller_spec.rb
spec/controllers/chaos_controller_spec.rb
+20
-2
No files found.
app/controllers/chaos_controller.rb
View file @
1714c47f
...
...
@@ -20,7 +20,11 @@ class ChaosController < ActionController::Base
end
def
kill
do_chaos
:kill
,
Chaos
::
KillWorker
do_chaos
:kill
,
Chaos
::
KillWorker
,
'KILL'
end
def
quit
do_chaos
:kill
,
Chaos
::
KillWorker
,
'QUIT'
end
def
gc
...
...
app/workers/chaos/kill_worker.rb
View file @
1714c47f
...
...
@@ -7,8 +7,8 @@ module Chaos
sidekiq_options
retry:
false
def
perform
Gitlab
::
Chaos
.
kill
def
perform
(
signal
)
Gitlab
::
Chaos
.
kill
(
signal
)
end
end
end
changelogs/unreleased/mk-chaos-quit.yml
0 → 100644
View file @
1714c47f
---
title
:
Add a chaos endpoint that signals QUIT
merge_request
:
58755
author
:
type
:
changed
config/routes.rb
View file @
1714c47f
...
...
@@ -179,6 +179,7 @@ Rails.application.routes.draw do
get
:db_spin
get
:sleep
get
:kill
get
:quit
post
:gc
end
end
...
...
doc/development/chaos_endpoints.md
View file @
1714c47f
...
...
@@ -146,10 +146,10 @@ curl "http://localhost:3000/-/chaos/sleep?duration_s=60&token=secret"
## Kill
This endpoint simulates the unexpected death of a worker process using
a
`kill
`
signal.
This endpoint simulates the unexpected death of a worker process using
the
`KILL
`
signal.
Because this endpoint uses the
`KILL`
signal, the
worker
isn't given an
opportunity to clean
up or shut
down.
Because this endpoint uses the
`KILL`
signal, the
process
isn't given an
opportunity to clean
up or shut
down.
```
plaintext
GET /-/chaos/kill
...
...
@@ -158,13 +158,33 @@ GET /-/chaos/kill?async=true
| Attribute | Type | Required | Description |
| ------------ | ------- | -------- | ---------------------------------------------------------------------- |
|
`async`
| boolean | no | Set to true to
kill a Sidekiq background worker process
|
|
`async`
| boolean | no | Set to true to
signal a Sidekiq background worker process
|
```
shell
curl
"http://localhost:3000/-/chaos/kill"
--header
'X-Chaos-Secret: secret'
curl
"http://localhost:3000/-/chaos/kill?token=secret"
```
## Quit
This endpoint simulates the unexpected death of a worker process using the
`QUIT`
signal.
Unlike
`KILL`
, the
`QUIT`
signal will also attempt to write a core dump.
See
[
core(5)
](
https://man7.org/linux/man-pages/man5/core.5.html
)
for more information.
```
plaintext
GET /-/chaos/quit
GET /-/chaos/quit?async=true
```
| Attribute | Type | Required | Description |
| ------------ | ------- | -------- | ---------------------------------------------------------------------- |
|
`async`
| boolean | no | Set to true to signal a Sidekiq background worker process |
```
shell
curl
"http://localhost:3000/-/chaos/quit"
--header
'X-Chaos-Secret: secret'
curl
"http://localhost:3000/-/chaos/quit?token=secret"
```
## Run garbage collector
This endpoint triggers a GC run on the worker handling the request and returns its worker ID
...
...
lib/gitlab/chaos.rb
View file @
1714c47f
...
...
@@ -43,9 +43,9 @@ module Gitlab
Kernel
.
sleep
(
duration_s
)
end
# Kill will send
a SIGKILL signal to the current process
def
self
.
kill
Process
.
kill
(
"KILL"
,
Process
.
pid
)
# Kill will send
the given signal to the current process.
def
self
.
kill
(
signal
)
Process
.
kill
(
signal
,
Process
.
pid
)
end
def
self
.
run_gc
...
...
spec/controllers/chaos_controller_spec.rb
View file @
1714c47f
...
...
@@ -109,7 +109,7 @@ RSpec.describe ChaosController do
describe
'#kill'
do
it
'calls synchronously'
do
expect
(
Gitlab
::
Chaos
).
to
receive
(
:kill
).
with
(
no_args
)
expect
(
Gitlab
::
Chaos
).
to
receive
(
:kill
).
with
(
'KILL'
)
get
:kill
...
...
@@ -117,7 +117,7 @@ RSpec.describe ChaosController do
end
it
'calls asynchronously'
do
expect
(
Chaos
::
KillWorker
).
to
receive
(
:perform_async
).
with
(
no_args
)
expect
(
Chaos
::
KillWorker
).
to
receive
(
:perform_async
).
with
(
'KILL'
)
get
:kill
,
params:
{
async:
1
}
...
...
@@ -125,6 +125,24 @@ RSpec.describe ChaosController do
end
end
describe
'#quit'
do
it
'calls synchronously'
do
expect
(
Gitlab
::
Chaos
).
to
receive
(
:kill
).
with
(
'QUIT'
)
get
:quit
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
it
'calls asynchronously'
do
expect
(
Chaos
::
KillWorker
).
to
receive
(
:perform_async
).
with
(
'QUIT'
)
get
:quit
,
params:
{
async:
1
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
describe
'#gc'
do
let
(
:gc_stat
)
{
GC
.
stat
.
stringify_keys
}
...
...
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