Skip to content

Commit 42b5b28

Browse files
committed
Fix usage of old ip/port when a server is restarting
- This would result in failure to start single-user server by requesting it to bind to the wrong IP/port. - Closes: #76
1 parent 2fc68b4 commit 42b5b28

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ clusters, as well as an option to run a local notebook directly on the jupyterhu
141141

142142
### v0.8.1 (bugfix release)
143143

144+
* Fix regression: single-user server binding address is overwritten by previous session server address, resulting in failure to start. Issue #76
145+
144146
### v0.8.0 (compatible with JupyterHub 0.5.0 through 0.8.1/0.9dev)
145147

146148
* SlurmSpawner: Remove `--uid` for (at least) Slurm 17.11 compatibility. If you use `sudo`, this should not be necessary, but because this is security related you should check that user management is as you expect. If your configuration does not use `sudo` then you may need to add the `--uid` option in a custom `batch_script`.
@@ -158,6 +160,7 @@ clusters, as well as an option to run a local notebook directly on the jupyterhu
158160
* WrapSpawner and ProfilesSpawner, which provide mechanisms for runtime configuration of spawners, have been split out and moved to the [`wrapspawner`](https://github.com/jupyterhub/wrapspawner) package
159161
* Enable CI testing via Travis-CI
160162

163+
161164
### v0.3 (tag: jhub-0.3, compatible with JupyterHub 0.3.0)
162165

163166
* initial release containing `TorqueSpawner` and `SlurmSpawner`

batchspawner/batchspawner.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ def _req_keepvars_default(self):
155155
# Will get the raw output of the job status command unless overridden
156156
job_status = Unicode()
157157

158+
# Will get the address of the server as reported by job manager
159+
current_ip = Unicode()
160+
158161
# Prepare substitution variables for templates using req_xyz traits
159162
def get_req_subvars(self):
160163
reqlist = [ t for t in self.trait_names() if t.startswith('req_') ]
@@ -317,17 +320,17 @@ def start(self):
317320
assert self.state_ispending()
318321
yield gen.sleep(self.startup_poll_interval)
319322

320-
self.ip = self.state_gethost()
323+
self.current_ip = self.state_gethost()
321324
if jupyterhub.version_info < (0,7):
322325
# store on user for pre-jupyterhub-0.7:
323326
self.user.server.port = self.port
324-
self.user.server.ip = self.ip
327+
self.user.server.ip = self.current_ip
325328
self.db.commit()
326329
self.log.info("Notebook server job {0} started at {1}:{2}".format(
327-
self.job_id, self.ip, self.port)
330+
self.job_id, self.current_ip, self.port)
328331
)
329332

330-
return self.ip, self.port
333+
return self.current_ip, self.port
331334

332335
@gen.coroutine
333336
def stop(self, now=False):
@@ -347,7 +350,7 @@ def stop(self, now=False):
347350
yield gen.sleep(1.0)
348351
if self.job_id:
349352
self.log.warn("Notebook server job {0} at {1}:{2} possibly failed to terminate".format(
350-
self.job_id, self.ip, self.port)
353+
self.job_id, self.current_ip, self.port)
351354
)
352355

353356
import re

batchspawner/tests/test_spawners.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def check_ip(spawner, value):
5454
if version_info < (0,7):
5555
assert spawner.user.server.ip == value
5656
else:
57-
assert spawner.ip == value
57+
assert spawner.current_ip == value
5858

5959
def test_spawner_start_stop_poll(db, io_loop):
6060
spawner = new_spawner(db=db)

0 commit comments

Comments
 (0)