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
240bfbdd
Commit
240bfbdd
authored
Jan 08, 2020
by
Craig Miskell
Committed by
Sean McGivern
Jan 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bug with monotonic_time, updates for style in tests
Per feedback on MR
parent
afe208aa
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
8 deletions
+14
-8
ee/lib/gitlab/sidekiq_cluster/cli.rb
ee/lib/gitlab/sidekiq_cluster/cli.rb
+8
-4
ee/spec/lib/gitlab/sidekiq_cluster/cli_spec.rb
ee/spec/lib/gitlab/sidekiq_cluster/cli_spec.rb
+6
-4
No files found.
ee/lib/gitlab/sidekiq_cluster/cli.rb
View file @
240bfbdd
...
...
@@ -68,17 +68,21 @@ module Gitlab
SidekiqCluster
.
write_pid
(
@pid
)
if
@pid
end
def
monotonic_time
Process
.
clock_gettime
(
Process
::
CLOCK_MONOTONIC
,
:float_second
)
end
def
continue_waiting?
(
deadline
)
SidekiqCluster
.
any_alive?
(
@processes
)
&&
Gitlab
::
Metrics
::
System
.
monotonic_time
<
deadline
SidekiqCluster
.
any_alive?
(
@processes
)
&&
monotonic_time
<
deadline
end
def
hard_stop_stuck_pids
SidekiqCluster
.
signal_processes
(
SidekiqCluster
.
pids_alive
(
@processes
),
:KILL
)
end
def
wait_for_termination
(
check_interval
=
CHECK_TERMINATE_INTERVAL_SECONDS
,
terminate_timeout
=
TERMINATE_TIMEOUT_SECONDS
)
deadline
=
Gitlab
::
Metrics
::
System
.
monotonic_time
+
terminate_timeout
sleep
(
check_interval
)
while
continue_waiting?
(
deadline
)
def
wait_for_termination
deadline
=
monotonic_time
+
TERMINATE_TIMEOUT_SECONDS
sleep
(
CHECK_TERMINATE_INTERVAL_SECONDS
)
while
continue_waiting?
(
deadline
)
hard_stop_stuck_pids
end
...
...
ee/spec/lib/gitlab/sidekiq_cluster/cli_spec.rb
View file @
240bfbdd
...
...
@@ -95,8 +95,9 @@ describe Gitlab::SidekiqCluster::CLI do
expect
(
Gitlab
::
SidekiqCluster
).
to
receive
(
:signal_processes
)
.
with
([],
:KILL
)
# Check every 0.1s, for no more than 1 second total
cli
.
wait_for_termination
(
0.1
,
1
)
stub_const
(
"Gitlab::SidekiqCluster::CLI::CHECK_TERMINATE_INTERVAL_SECONDS"
,
0.1
)
stub_const
(
"Gitlab::SidekiqCluster::CLI::TERMINATE_TIMEOUT_SECONDS"
,
1
)
cli
.
wait_for_termination
end
context
'with hanging workers'
do
...
...
@@ -123,8 +124,9 @@ describe Gitlab::SidekiqCluster::CLI do
cli
.
run
(
%w(foo)
)
# Check every 0.1s, for no more than 1 second total
cli
.
wait_for_termination
(
0.1
,
1
)
stub_const
(
"Gitlab::SidekiqCluster::CLI::CHECK_TERMINATE_INTERVAL_SECONDS"
,
0.1
)
stub_const
(
"Gitlab::SidekiqCluster::CLI::TERMINATE_TIMEOUT_SECONDS"
,
1
)
cli
.
wait_for_termination
end
end
end
...
...
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