Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Bring Your Own Resources #205

Merged
merged 23 commits into from Jun 30, 2017
Jump to file or symbol
Failed to load files and symbols.
+14 −10
Split
Viewing a subset of changes. View all

fix critical bug in resetting byor settings

commit 23a35300ee87330608c798afdbd7401964a0a78e @StrausMG StrausMG committed Jun 19, 2017
View
@@ -54,20 +54,23 @@ def client(self):
return self._byor_client
return super(CustomDockerSpawner, self).client
+ def _reset_byor(self):
+ self.container_ip = self.__class__.container_ip
+ self._byor_client = None
+
byor_timeout = Int(20, min=1, config=True, help='Timeout for connection to BYOR Docker daemon')
@gen.coroutine
def _set_client(self):
"""Prepare a client for the user."""
- if self.byor_is_used:
- byor_docker_url = self.user_options['byor_docker_url']
- # version='auto' causes a connection to the daemon
- self._byor_client = docker.Client(byor_docker_url,
- version='auto',
- timeout=self.byor_timeout)
- self.container_ip = byor_docker_url.split(':')[0]
- else:
- self.container_ip == self.__class__.container_ip
- self._byor_client = None
+ if not self.byor_is_used:
+ self._reset_byor()
+ return
+ byor_docker_url = self.user_options['byor_docker_url']
+ # version='auto' causes a connection to the daemon
+ self._byor_client = docker.Client(byor_docker_url,
+ version='auto',
+ timeout=self.byor_timeout)
+ self.container_ip = byor_docker_url.split(':')[0]
@anaderi

anaderi Jun 21, 2017

Owner

move to ByorDockerSpawner class

# We override the executor here to increase the number of threads
@property
@@ -111,6 +114,7 @@ def lister(mm):
def clear_state(self):
state = super(CustomDockerSpawner, self).clear_state()
self.container_id = ''
+ self._reset_byor()
def get_state(self):
state = DockerSpawner.get_state(self)