Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
dashboardv3
inventory-provider
Commits
3d5153c1
Commit
3d5153c1
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
clear log keys in a separate thread
parent
7c95ebfb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/tasks/monitor.py
+5
-1
5 additions, 1 deletion
inventory_provider/tasks/monitor.py
inventory_provider/tasks/worker.py
+13
-1
13 additions, 1 deletion
inventory_provider/tasks/worker.py
with
18 additions
and
2 deletions
inventory_provider/tasks/monitor.py
+
5
−
1
View file @
3d5153c1
...
...
@@ -114,14 +114,18 @@ def run():
t
[
'
thread
'
].
join
()
def
clear_joblog
(
r
):
def
clear_joblog
(
r
,
keys_read_event
=
None
):
"""
:param r: connection to a redis database
:param keys_read_event: optional event to signal after all keys are read
:return:
"""
rp
=
r
.
pipeline
()
for
key
in
r
.
scan_iter
(
'
joblog:*
'
):
rp
.
delete
(
key
)
if
keys_read_event
:
assert
isinstance
(
keys_read_event
,
threading
.
Event
)
# sanity
keys_read_event
.
set
()
rp
.
execute
()
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/tasks/worker.py
+
13
−
1
View file @
3d5153c1
import
json
import
logging
import
os
import
threading
import
time
from
redis.exceptions
import
RedisError
...
...
@@ -554,7 +555,18 @@ def launch_refresh_cache_all(config):
_erase_next_db
(
config
)
update_latch_status
(
config
,
pending
=
True
)
monitor
.
clear_joblog
(
get_current_redis
(
config
))
# call monitor.clear_joblog in a thread, since
# deletion might be slow and can be done in parallel
def
_clear_log_proc
(
wait_event
):
monitor
.
clear_joblog
(
get_current_redis
(
config
),
wait_event
)
keys_captured_event
=
threading
.
Event
()
threading
.
Thread
(
target
=
_clear_log_proc
,
args
=
[
keys_captured_event
]).
start
()
if
not
keys_captured_event
.
wait
(
timeout
=
60.0
):
# wait a reasonable time
logging
.
error
(
'
timed out waiting for log keys to be read
'
)
# first batch of subtasks: refresh cached opsdb data
subtasks
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment