Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public method stop should not be called from private method _start #764

Open
mbelak-dtml opened this issue Aug 16, 2023 · 1 comment
Open

Comments

@mbelak-dtml
Copy link

Proposed change

Reasoning

TL;DR: The stop method is assumed to only delete the JupyterLab server pod, although the inheritance contract should be that the method deletes any resources associated with the server.

The current implemenation makes extending KubeSpawner with additional resources very difficult. It assumes that the stop method just stops the JupyterLab server pod. This is, however, problematic in case additional Kubernetes resources are being cleared in an override of the method stop.

The stop method is called for example here:

except ApiException as e:
pod_name = pod.metadata.name
if e.status != 409:
# We only want to handle 409 conflict errors
self.log.exception("Failed for %s", pod.to_str())
raise
self.log.info(f'Found existing pod {pod_name}, attempting to kill')
# TODO: this should show up in events
await self.stop(True)

This is problematic since it's called from the start method. However, the overridden start and stop method might look something like this:

def start(self):
    self._deploy_my_custom_resources()
    return super().start()  
async def stop(self):
    self._destroy_my_custom_resources()
    super().stop()

In that case the call to stop also destroys the custom resources, although it should really just delete the pod.

Alternative options

Who would use this feature?

Anyone creating a custom subclass of KubeSpawner which deploys additional Kubernetes resources in the start method.

(Optional): Suggest a solution

Add a private _stop method and make the public stop method just a thin wrapper around the private method, similar to what's already done with start and _start. Only call the _stop method in the implementation.

@welcome
Copy link

welcome bot commented Aug 16, 2023

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant