MigratorStorage#

class nublado.controller.storage.kubernetes.migrator.MigratorStorage(*, metadata_storage, api_client, reconnect_timeout, logger)#

Bases: object

Kubernetes storage layer for a migrator pod.

Parameters:
  • metadata_storage (MetadataStorage) – Holds namespace information.

  • api_client (ApiClient) – Kubernetes API client.

  • reconnect_timeout (timedelta) – How long to wait before explictly restarting Kubernetes watches. This can prevent the connection from getting unexpectedly getting closed, resulting in 400 errors, or worse, events silently stopping.

  • logger (BoundLogger) – Logger to use.

Notes

This class isn’t strictly necessary; instead, the migrator service could call the storage layers for individual Kubernetes objects directly. Even though there are not many objects, having a wrapper layer might be easier to follow.

Create, delete, and get_status will all be called with the service manager’s lock asserted. They are not concurrency-safe.

The lock in here is used to control access to the cache; the cache only tracks exited (and then cleaned-up) pods, not pods in progress.

Methods Summary

create(old_user, new_user, objects, timeout)

Create all of the Kubernetes objects for a migrator instance.

delete(old_user, new_user, objects, timeout)

Delete the migrator instance.

get_status(old_user, new_user, objects, ...)

Return the status of the migrator environment for a particular user pair, or None if there has been no migration attempt.

Methods Documentation

async create(old_user, new_user, objects, timeout)#

Create all of the Kubernetes objects for a migrator instance.

Create the objects in Kubernetes and then wait for the migrator pod to start.

Parameters:
  • old_user (str) – Username for source user to copy from.

  • new_user (str) – Username for target user to copy to.

  • objects (MigratorObjects) – Kubernetes objects making up the fsadmin environment.

  • timeout (Timeout) – How long to wait for the migrator pod to start.

Returns:

Pod status.

Return type:

MigratorStatus

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

  • TimeoutError – Raised if migrator is not ready before the timeout expires.

async delete(old_user, new_user, objects, timeout)#

Delete the migrator instance. Leave any of its information in the cache.

Parameters:
  • old_user (str) – Username for source user to copy from.

  • new_user (str) – Username for target user to copy to.

  • objects (MigratorObjects) – Kubernetes objects making up the migrator environment.

  • timeout (Timeout) – Timeout on operation.

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

  • TimeoutError – Raised if fsadmin objects are not deleted within provided timeout.

Return type:

None

async get_status(old_user, new_user, objects, timeout, *, clean=True)#

Return the status of the migrator environment for a particular user pair, or None if there has been no migration attempt.

Parameters:
  • old_user (str) – Name of source user to copy from.

  • new_user (str) – Name of target user to copy to.

  • timeout (Timeout) – Timeout on operation.

  • objects (Optional[MigratorObjects])

  • clean (bool, default: True)

Returns:

Pod status.

Return type:

MigratorStatus

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

  • TimeoutError – Raised if fsadmin is not ready before the provided timeout expires.