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
ed402238
Commit
ed402238
authored
Jan 20, 2015
by
Feanil Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wait up to 2 minutes for instance tags.
parent
890dcdee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
+31
-12
playbooks/roles/supervisor/files/pre_supervisor_checks.py
+31
-12
No files found.
playbooks/roles/supervisor/files/pre_supervisor_checks.py
View file @
ed402238
...
...
@@ -7,6 +7,7 @@ import os
import
subprocess
import
traceback
import
socket
import
time
# Services that should be checked for migrations.
MIGRATION_COMMANDS
=
{
...
...
@@ -16,6 +17,9 @@ MIGRATION_COMMANDS = {
}
HIPCHAT_USER
=
"PreSupervisor"
# Max amount of time to wait for tags to be applied.
MAX_BACKOFF
=
120
def
services_for_instance
(
instance_id
):
"""
Get the list of all services named by the services tag in this
...
...
@@ -106,16 +110,31 @@ if __name__ == '__main__':
# Needs to exit with 1 instead of 0 to prevent
# services from starting.
exit
(
1
)
try
:
environment
,
deployment
,
play
=
edp_for_instance
(
instance_id
)
prefix
=
"{environment}-{deployment}-{play}-{instance_id}"
.
format
(
environment
=
environment
,
deployment
=
deployment
,
play
=
play
,
instance_id
=
instance_id
)
except
:
print
(
"Failed to get EDP for {}"
.
format
(
instance_id
))
time_left
=
MAX_BACKOFF
backoff
=
INITIAL_BACKOFF
environment
=
None
deployment
=
None
play
=
None
while
time_left
>
0
:
try
:
environment
,
deployment
,
play
=
edp_for_instance
(
instance_id
)
prefix
=
"{environment}-{deployment}-{play}-{instance_id}"
.
format
(
environment
=
environment
,
deployment
=
deployment
,
play
=
play
,
instance_id
=
instance_id
)
break
except
:
print
(
"Failed to get EDP for {}"
.
format
(
instance_id
))
time
.
sleep
(
backoff
)
backoff
=
backoff
*
2
if
environment
is
None
or
deployment
is
None
or
play
is
None
:
msg
=
"Unable to retrieve environment, deployment, or play tag."
print
(
msg
)
notify
(
"{} : {}"
.
format
(
prefix
,
msg
))
exit
(
0
)
#get the hostname of the sandbox
hostname
=
socket
.
gethostname
()
...
...
@@ -130,7 +149,7 @@ if __name__ == '__main__':
"cluster"
:
play
,
"instance-id"
:
instance_id
,
"created"
:
volume
.
create_time
})
try
:
for
service
in
services_for_instance
(
instance_id
):
if
service
in
MIGRATION_COMMANDS
:
...
...
@@ -153,7 +172,7 @@ if __name__ == '__main__':
output
=
subprocess
.
check_output
(
cmd
,
shell
=
True
)
if
'Migrating'
in
output
:
raise
Exception
(
"Migrations have not been run for {}"
.
format
(
service
))
# Link to available service.
available_file
=
os
.
path
.
join
(
args
.
available
,
"{}.conf"
.
format
(
service
))
link_location
=
os
.
path
.
join
(
args
.
enabled
,
"{}.conf"
.
format
(
service
))
...
...
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