FileserverManager#

class controller.services.fileserver.FileserverManager(*, config, fileserver_builder, fileserver_storage, slack_client, logger)#

Bases: object

Manage user file servers.

Unlike with labs, file servers are not normally explicitly shut down. Instead, the file server has an internal idle timeout and exits once that has expired with no activity. A background task watches for exited file servers, deletes the associated resources, and updates the internal state.

This class is a process-wide singleton that manages that background task and the user file server state.

Parameters:

Methods Summary

create(user)

Ensure a file server exists for the given user.

delete(username)

Delete the file server for a user.

get_status(username)

Get the status of a user's file server.

list()

List users with running file servers.

reconcile()

Reconcile internal state with Kubernetes.

watch_servers()

Watch the file server namespace for completed file servers.

Methods Documentation

async create(user)#

Ensure a file server exists for the given user.

If the user doesn’t have a fileserver, create it. If the user already has a fileserver, just return. This gets called by the handler when a user comes in through the /files ingress.

Parameters:

user (GafaelfawrUserInfo) – User for which to create a file server.

Raises:
Return type:

None

async delete(username)#

Delete the file server for a user.

Parameters:

username (str) – Username of user.

Raises:

KubernetesError – Raised if there is some failure in a Kubernetes API call.

Return type:

None

get_status(username)#

Get the status of a user’s file server.

Returns:

Status of the user’s file server.

Return type:

FileserverStatus

Parameters:

username (str) –

async list()#

List users with running file servers. :rtype: list[str]

async reconcile()#

Reconcile internal state with Kubernetes.

Runs at Nublado controller startup to reconcile internal state with the content of Kubernetes. This picks up changes made in Kubernetes outside of the controller, and is also responsible for building the internal state from the current state of Kubernetes during startup. It is called during startup and from a background task. :rtype: None

async watch_servers()#

Watch the file server namespace for completed file servers.

Each file server has a timeout, after which it exits. When one exits, we want to clean up its Kubernetes objects and update its state. This method runs as a background task watching for changes and triggers the delete when appropriate. :rtype: None