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:
config (
EnabledFileserverConfig
) – Configuration for file servers. File servers are guaranteed to be enabled by ~controller.factory.ProcessContext.fileserver_builder (
FileserverBuilder
) – Builder that constructs file server Kubernetes objects.fileserver_storage (
FileserverStorage
) – Kubernetes storage layer for file servers.logger (
BoundLogger
) – Logger to use.slack_client (
Optional
[SlackWebhookClient
]) –
Methods Summary
create
(user)Ensure a file server exists for the given user.
delete
(username)Delete the file server for a user.
list
()List users with running file servers.
start
()Start the background file server tasks.
stop
()Stop background file server tasks.
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:
controller.exceptions.ControllerTimeoutError – Raised if the file server could not be created within its creation timeout.
KubernetesError – Raised if there is some failure in a Kubernetes API call.
- Return type:
- 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:
- async start()#
Start the background file server tasks.
Reconstructs the user state map in the foreground before backgrounding the reconciliation and monitor tasks.
- Return type: