utils.storage package

Submodules

utils.storage.constrained module

Decide whether a deploy should prefer free storage space over cache.

The decision compares the free space on the filesystem holding Docker’s data root - where images, volumes and build cache grow - against the storage the deploy actually declares it needs: the sum of min_storage over the services of the applications being deployed, transitive dependencies included. No threshold constant is involved, so the answer follows the declarations rather than a guess about disk sizes.

utils.storage.constrained.docker_data_root() → str

Return Docker’s data root as reported by the local daemon.

Raises:

RuntimeError – the daemon is unreachable or reports no data root. Guessing a path here would silently measure the wrong filesystem and report a roomy host, which is the failure this module exists to prevent.

utils.storage.constrained.docker_root_free_bytes(*, local_vantage: str) → int

Return the free bytes on the filesystem where Docker’s data grows.

Parameters:

local_vantage – a path in the caller’s own mount namespace that sits on the same filesystem as the daemon’s storage. Consulted only when the data root the daemon reports does not resolve here.

utils.storage.constrained.host_storage_constrained(app_ids: list[str], variants: dict[str, int] | None = None, *, local_vantage: str) → bool

Return True when the deploy’s declared storage need exceeds the free space.

Parameters:
  • app_ids – applications the deploy installs; dependencies are walked.

  • variants – per-app variant index, as in required_storage_bytes.

  • local_vantage – measurement point when the daemon’s data root does not resolve in this mount namespace, as in docker_root_free_bytes.

utils.storage.constrained.is_constrained(*, free_bytes: int, required_bytes: int) → bool

Return True when the declared need does not fit into the free space.

utils.storage.constrained.required_storage_bytes(app_ids: list[str], variants: dict[str, int] | None = None) → int

Return the summed min_storage of app_ids and their transitive dependencies.

Parameters:
  • app_ids – applications the deploy installs; dependencies are walked.

  • variants – per-app variant index whose meta/variants.yml overlay decides which services are enabled. Without it the base configuration counts, which over-states a deploy that a variant trims down.

Services that declare no min_storage contribute nothing, so an entirely undeclared deploy yields 0 and is never treated as constrained.

utils.storage.nfs module

utils.storage.nfs.client_src(server, version, flavor, state_path_value)
utils.storage.nfs.fstype(version)
utils.storage.nfs.get_client_version() → int

NFS mount protocol version from the client’s services.yml SPOT.

utils.storage.nfs.get_export_base() → str

NFS export base from the provider’s services.yml SPOT.

utils.storage.nfs.mount_opts(version, runtime)
utils.storage.nfs.state_path(export_base, subdir)
utils.storage.nfs.swarm_nfs_backed(entry, *, application_id, deployment_mode, storage_backend)

True when the swarm NFS rewrite backs this meta/volumes.yml entry.

Parameters:
  • entry – volume entry mapping; nfs: false opts it out of the rewrite.

  • application_id – role the volume belongs to; a manager-pinned role or one forcing a non-swarm mode keeps its volumes node-local.

  • deployment_mode – cluster-wide compose or swarm.

  • storage_backend – the storage.backend value, e.g. local or nfs.

Module contents

Storage helper utilities (NFS client/server derivations).