Skip to content

Commit

Permalink
Merge pull request #657 from totycro/serialize-namespace
Browse files Browse the repository at this point in the history
Save the namespace between restarts
  • Loading branch information
yuvipanda committed Nov 9, 2022
2 parents 0446b32 + 84685f9 commit c7dbfe9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kubespawner/spawner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2188,9 +2188,13 @@ def get_state(self):
It's also useful for cases when the `pod_template` changes between
restarts - this keeps the old pods around.
We also save the namespace for use cases where the namespace is
calculated dynamically.
"""
state = super().get_state()
state['pod_name'] = self.pod_name
state['namespace'] = self.namespace
return state

def get_env(self):
Expand All @@ -2215,10 +2219,15 @@ def load_state(self, state):
but if the `pod_template` has changed in between restarts, it will no longer
be the case. This allows us to continue serving from the old pods with
the old names.
For a similar reason, we also save the namespace.
"""
if 'pod_name' in state:
self.pod_name = state['pod_name']

if 'namespace' in state:
self.namespace = state['namespace']

@_await_pod_reflector
async def poll(self):
"""
Expand Down

0 comments on commit c7dbfe9

Please sign in to comment.