Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fixed issues with starting Docker images for consumer test sessions #78

Merged
merged 2 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/vng/testsession/gemma_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

NRC_CELERY = Container(
name='celery',
image='vngr/gemma-notifications',
image='vngr/notificaties-api:develop',
public_port=None,
private_port=None,
variables={
Expand All @@ -39,25 +39,20 @@
'DB_USER': 'postgres',
'DB_PASSWORD': 'postgres',
'DJANGO_SETTINGS_MODULE': 'nrc.conf.docker',
'UWSGI_PORT': '8004',
'IS_HTTPS': '0',
'SECRET_KEY': '^6gn!(9zn%h(-u0t=iq3f(7izgi-#a2n6@fxlh5z7fxp=#evf#',
'PUBLISH_BROKER_URL': 'amqp://guest@localhost:5672//',
'CELERY_BROKER_URL': 'amqp://guest@localhost:5672//',
'CELERY_RESULT_BACKEND': 'amqp://guest@localhost:5672//',
},
command=[
'celery',
'worker',
'-A',
'nrc',
'--workdir=src'
'../celery_worker.sh'
]
)

NRC = Container(
name='nrc',
image='vngr/gemma-notifications',
image='vngr/notificaties-api:develop',
public_port=8004,
private_port=8004,
variables={
Expand Down
22 changes: 15 additions & 7 deletions src/vng/testsession/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def ZGW_deploy(session):
exposed_urls = []
for c in containers:
vng_endpoint = VNGEndpoint.objects.filter(session_type=session.session_type).filter(name__icontains=c.name)
c.variables['DB_HOST'] = db_IP_address
if len(vng_endpoint) != 0:
bind_url = ExposedUrl.objects.create(
session=session,
Expand All @@ -127,7 +128,6 @@ def ZGW_deploy(session):
)
exposed_urls.append(bind_url)
c.name = '{}-{}'.format(session.name, c.name)
c.variables['DB_HOST'] = db_IP_address

Deployment(
name=session.name,
Expand All @@ -143,7 +143,7 @@ def ZGW_deploy(session):
app=session.name,
containers=containers
).execute()
ip = external_ip_pooling(k8s, session, n_trial=30, max_percentage=40)
ip = external_ip_pooling(k8s, session, n_trial=150, max_percentage=40)
if ip is None:
update_session_status(session, _('Impossible to deploy successfully, IP address not allocated'))
session.status = choices.StatusChoices.error_deploy
Expand All @@ -154,12 +154,20 @@ def ZGW_deploy(session):
ex.save()

# check migrations status
while len(uwsgi_containers) != 0:
uwsgi_containers = [c for c in uwsgi_containers if 'spawned uWSGI' not in k8s.get_pod_log(c.name)]
for i in range(60):
spawned = [c for c in uwsgi_containers if 'spawned uWSGI' in k8s.get_pod_log(c.name)]
update_session_status(session, _('Check migration status'), int(40 + (6 - len(uwsgi_containers)) * 45 / 6))
if len(spawned) == len(uwsgi_containers):
break
time.sleep(5)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wellicht dat het handig om hier een soort timeout in te maken? Dat na bijvoorbeeld 60x proberen de taak wordt afgebroken. Ik hou niet echt van oneindige loops zonder failsafe, zeker niet wanneer je afhankelijk bent van een ander systeem.


update_session_status(session, _('Loading preconfigured models', 85))
if len(spawned) != len(uwsgi_containers):
update_session_status(session, _('Not all uWSGI containers have spawned'))
session.status = choices.StatusChoices.error_deploy
session.save()
return

update_session_status(session, _('Loading preconfigured models'), 85)
filename = str(uuid.uuid4())
file_location = os.path.join(os.path.dirname(__file__), 'kubernetes/data/dump.sql')
new_file = os.path.join(os.path.dirname(__file__), 'kubernetes/data/{}'.format(filename))
Expand All @@ -179,7 +187,7 @@ def ZGW_deploy(session):
'-U',
'postgres'
])
update_session_status(session, _('Installation succesful'), 100)
update_session_status(session, _('Installation successful'), 100)
session.status = choices.StatusChoices.running
session.save()

Expand All @@ -199,7 +207,7 @@ def external_ip_pooling(k8s, session, n_trial=15, purge=True, percentage=36, max
return None
for i in range(n_trial):
time.sleep(10)
update_session_status(session, _('Installatione progress ') + '{}'.format(i + 1), min(percentage + i * 6, max_percentage))
update_session_status(session, _('Installation progress ') + '{}'.format(i + 1), min(percentage + i * 6, max_percentage))
ip = k8s.service_status()
if ip is not None:
return ip
Expand Down