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
af277012
Commit
af277012
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
don't delete log records in another thread
much simpler, hopefully the scan_iter count param helps
parent
190ac489
Branches
Branches containing commit
Tags
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
+1
-5
1 addition, 5 deletions
inventory_provider/tasks/monitor.py
inventory_provider/tasks/worker.py
+1
-13
1 addition, 13 deletions
inventory_provider/tasks/worker.py
with
2 additions
and
18 deletions
inventory_provider/tasks/monitor.py
+
1
−
5
View file @
af277012
...
...
@@ -114,19 +114,15 @@ def run():
t
[
'
thread
'
].
join
()
def
clear_joblog
(
r
,
keys_read_event
=
None
):
def
clear_joblog
(
r
):
"""
:param r: connection to a redis database
:param keys_read_event: optional event to signal after all keys are read
:return:
"""
rp
=
r
.
pipeline
()
# scan with bigger batches, to mitigate network latency effects
for
key
in
r
.
scan_iter
(
'
joblog:*
'
,
count
=
1000
):
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
+
1
−
13
View file @
af277012
import
json
import
logging
import
os
import
threading
import
time
from
redis.exceptions
import
RedisError
...
...
@@ -563,18 +562,7 @@ def launch_refresh_cache_all(config):
_erase_next_db
(
config
)
update_latch_status
(
config
,
pending
=
True
)
# 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
'
)
monitor
.
clear_joblog
(
get_current_redis
(
config
))
# 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