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
e674e20b
Commit
e674e20b
authored
5 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added pending & failure to latch struct
parent
66ae1856
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/common.py
+20
-2
20 additions, 2 deletions
inventory_provider/tasks/common.py
inventory_provider/tasks/worker.py
+17
-7
17 additions, 7 deletions
inventory_provider/tasks/worker.py
with
37 additions
and
9 deletions
inventory_provider/tasks/common.py
+
20
−
2
View file @
e674e20b
...
...
@@ -13,7 +13,9 @@ DB_LATCH_SCHEMA = {
"
properties
"
:
{
"
current
"
:
{
"
type
"
:
"
integer
"
},
"
next
"
:
{
"
type
"
:
"
integer
"
},
"
this
"
:
{
"
type
"
:
"
integer
"
}
"
this
"
:
{
"
type
"
:
"
integer
"
},
"
pending
"
:
{
"
type
"
:
"
boolean
"
},
"
failure
"
:
{
"
type
"
:
"
boolean
"
}
},
"
required
"
:
[
"
current
"
,
"
next
"
,
"
this
"
],
"
additionalProperties
"
:
False
...
...
@@ -35,6 +37,20 @@ def get_latch(r):
return
latch
def
update_latch_status
(
config
,
pending
=
False
,
failure
=
False
):
logger
.
debug
(
'
updating latch status: pending={}, failure={}
'
.
format
(
pending
,
failure
))
for
db
in
config
[
'
redis-databases
'
]:
r
=
_get_redis
(
config
,
dbid
=
db
)
latch
=
get_latch
(
r
)
if
not
latch
:
continue
latch
[
'
pending
'
]
=
pending
latch
[
'
failure
'
]
=
failure
r
.
set
(
'
db:latch
'
,
json
.
dumps
(
latch
))
def
set_latch
(
config
,
new_current
,
new_next
):
logger
.
debug
(
'
setting latch: new current={}, new next={}
'
.
format
(
...
...
@@ -44,7 +60,9 @@ def set_latch(config, new_current, new_next):
latch
=
{
'
current
'
:
new_current
,
'
next
'
:
new_next
,
'
this
'
:
db
'
this
'
:
db
,
'
pending
'
:
False
,
'
failure
'
:
False
}
r
=
_get_redis
(
config
,
dbid
=
db
)
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/tasks/worker.py
+
17
−
7
View file @
e674e20b
...
...
@@ -13,7 +13,7 @@ import jsonschema
from
inventory_provider.tasks.app
import
app
from
inventory_provider.tasks.common
\
import
get_next_redis
,
latch_db
,
get_latch
,
set_latch
import
get_next_redis
,
latch_db
,
get_latch
,
set_latch
,
update_latch_status
from
inventory_provider
import
config
from
inventory_provider
import
environment
from
inventory_provider.db
import
db
,
opsdb
...
...
@@ -473,6 +473,8 @@ def launch_refresh_cache_all(config):
"""
_erase_next_db
(
config
)
update_latch_status
(
config
,
pending
=
True
)
# first batch of subtasks: refresh cached opsdb data
subtasks
=
[
update_junosspace_device_list
.
apply_async
(),
...
...
@@ -556,14 +558,22 @@ def refresh_finalizer(self, pending_task_ids_json):
'
message
'
:
s
})
task_ids
=
json
.
loads
(
pending_task_ids_json
)
logger
.
debug
(
'
task_ids: %r
'
%
task_ids
)
jsonschema
.
validate
(
task_ids
,
input_schema
)
_wait_for_tasks
(
task_ids
,
update_callback
=
_update
)
_build_subnet_db
(
update_callback
=
_update
)
try
:
task_ids
=
json
.
loads
(
pending_task_ids_json
)
logger
.
debug
(
'
task_ids: %r
'
%
task_ids
)
jsonschema
.
validate
(
task_ids
,
input_schema
)
_wait_for_tasks
(
task_ids
,
update_callback
=
_update
)
_build_subnet_db
(
update_callback
=
_update
)
except
(
jsonschema
.
ValidationError
,
json
.
JSONDecodeError
,
InventoryTaskError
)
as
e
:
update_latch_status
(
InventoryTask
.
config
,
failure
=
True
)
raise
e
_update
(
'
latching current/next dbs
'
)
latch_db
(
InventoryTask
.
config
)
_update
(
'
latched current/next dbs
'
)
logger
.
debug
(
'
<<< refresh_finalizer
'
)
...
...
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