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
36d1b596
Commit
36d1b596
authored
5 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
use sentinel to find master
parent
59f3543d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/tasks/config.py
+28
-17
28 additions, 17 deletions
inventory_provider/tasks/config.py
with
28 additions
and
17 deletions
inventory_provider/tasks/config.py
+
28
−
17
View file @
36d1b596
import
json
from
os
import
getenv
import
logging
import
os
import
re
import
redis.sentinel
logger
=
logging
.
getLogger
(
__name__
)
broker_url
=
getenv
(
'
CELERY_BROKER_URL
'
,
default
=
'
redis://test-dashboard02.geant.org:6379/1
'
)
broker_hostname
=
os
.
getenv
(
'
BROKER_HOSTNAME
'
)
assert
broker_hostname
is
not
None
broker_port
=
int
(
os
.
getenv
(
'
BROKER_PORT
'
))
broker_db_index
=
int
(
os
.
getenv
(
'
BROKER_DB_INDEX
'
))
broker_scheme
=
os
.
getenv
(
'
BROKER_SCHEME
'
,
'
redis
'
)
assert
broker_scheme
in
(
'
redis
'
,
'
sentinel
'
),
'
unsupported broker scheme
'
if
broker_scheme
==
'
sentinel
'
:
master_name
=
os
.
getenv
(
'
SENTINEL_MASTER_NAME
'
)
assert
master_name
is
not
None
sentinel
=
redis
.
sentinel
.
Sentinel
(
[(
broker_hostname
,
broker_port
)],
socket_timeout
=
0.1
)
master
=
sentinel
.
discover_master
(
master_name
)
assert
master
broker_hostname
=
master
[
0
]
broker_port
=
master
[
1
]
if
re
.
match
(
'
^[\d:]+$
'
,
broker_hostname
):
# handle case where hostname is an ipv6 address
broker_hostname
=
'
[%s]
'
%
broker_hostname
broker_url
=
'
redis://%s:%d/%d
'
%
(
broker_hostname
,
broker_port
,
broker_db_index
)
result_backend
=
broker_url
if
result_backend
:
# bugfix workaround
result_backend
=
result_backend
.
split
(
'
;
'
)[
0
]
tmp_options
=
getenv
(
'
BROKER_TRANSPORT_OPTIONS
'
,
default
=
''
)
if
tmp_options
:
broker_transport_options
=
json
.
loads
(
tmp_options
)
else
:
broker_transport_options
=
{}
task_eager_propagates
=
True
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