Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
configuration
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
configuration
Commits
a8cf92d4
Commit
a8cf92d4
authored
Apr 27, 2017
by
Kevin Falcone
Committed by
GitHub
Apr 27, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3835 from edx/jibsheet/multiple-worker-cluster-detection
Jibsheet/multiple worker cluster detection
parents
2656eb9f
f564959c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
playbooks/active_instances_in_asg.py
+11
-6
No files found.
playbooks/active_instances_in_asg.py
View file @
a8cf92d4
...
...
@@ -58,15 +58,20 @@ class ActiveInventory():
active_instances
=
[
instance
[
'InstanceId'
]
for
instance
in
instances
[
'InstanceStates'
]
if
instance
[
'State'
]
==
'InService'
]
for
instance_id
in
active_instances
:
active_groups
[
instances_to_groups
[
instance_id
]]
=
1
if
len
(
active_groups
)
>
1
:
# When we have more than a single active ASG, we need to bail out as we don't know what ASG to pick an instance from
print
(
"Multiple active ASGs - unable to choose an instance"
,
file
=
sys
.
stderr
)
return
# If we found no active groups, because there are no ELBs (edxapp workers normally)
# print a sensible reason why we failed
elbs
=
list
(
chain
.
from_iterable
([
group
[
'LoadBalancerNames'
]
for
group
in
matching_groups
]))
if
not
(
active_groups
or
elbs
):
print
(
"Multiple ASGs and no ELB - unable to choose an instance"
,
file
=
sys
.
stderr
)
# This implies we're in a worker cluster since we have no ELB and we didn't find an active group above
for
group
in
matching_groups
:
# Asgard marks a deleting ASG with SuspendedProcesses
# If the ASG doesn't have those, then it's "Active" and a worker since there was no ELB above
if
not
{
'Launch'
,
'AddToLoadBalancer'
}
<=
{
i
[
'ProcessName'
]
for
i
in
group
[
'SuspendedProcesses'
]}:
active_groups
[
group
[
'AutoScalingGroupName'
]]
=
1
if
len
(
active_groups
)
>
1
:
# When we have more than a single active ASG, we need to bail out as we don't know what ASG to pick an instance from
print
(
"Multiple active ASGs - unable to choose an instance"
,
file
=
sys
.
stderr
)
return
else
:
active_groups
=
{
g
[
'AutoScalingGroupName'
]:
1
for
g
in
matching_groups
}
...
...
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