minitrino.core.cluster.ops module#

Cluster operations and resource management for Minitrino clusters.

class minitrino.core.cluster.ops.ClusterOperations(ctx: MinitrinoContext, cluster: Cluster)[source][source]#

Bases: object

Cluster operations manager for the current cluster.

Parameters:
  • ctx (MinitrinoContext) – An instantiated MinitrinoContext object with user input and context.

  • cluster (Cluster) – An instantiated Cluster object.

provision()[source][source]#

Provisions the cluster.

reconcile_workers(workers: int)[source][source]#

Provisions or adjusts worker containers based on the specified number.

down(sig_kill: bool = False, keep: bool = False)[source][source]#

Stops and optionally removes all containers for the current cluster.

restart()[source][source]#

Restarts all cluster containers (coordinator and workers).

restart_containers(c_restart: Optional[list[str]] = None, log_level:
LogLevel = LogLevel.DEBUG)

Restarts all the containers in the provided list. Can apply to any container in the environment, not just the coordinator and workers.

remove(obj_type: str, force: bool, labels: Optional[list[str]] =
None)

Removes Docker objects (images, volumes, or networks) associated with the current cluster.

rollback()[source][source]#

Terminates the provision operations and removes the cluster.

provision(modules: list[str], image: str, workers: int, no_rollback: bool) None[source][source]#

Provision the cluster and environment dependencies.

Dependencies include any service/configuration that is defined in the module(s) that are to be provisioned.

Parameters:
  • modules (list[str]) – One or more modules to provision in the cluster.

  • image (str) – Cluster image type (trino or starburst).

  • workers (int) – Number of cluster workers to provision.

  • no_rollback (bool) – If True, disables rollback on failure.

Notes

  • If no options are provided, a standalone coordinator is provisioned.

  • Supports Trino or Starburst distributions.

  • Dependent modules are automatically added to the environment.

  • Dependent clusters are automatically provisioned after the primary cluster is launched.

reconcile_workers(workers: int = 0) None[source][source]#

Reconcile the number of workers in the cluster.

Notes

Handles five scenarios:

  1. No workers value is provided and no workers are currently running — does nothing.

  2. A positive workers value is provided and no workers exist — provisions new workers.

  3. No workers value is provided but some are already running — uses current count.

  4. Provided workers value is greater than running workers — provisions more workers.

  5. Provided workers value is less than running workers — removes excess workers.

Parallelism is set to 4 for worker provisioning.

down(sig_kill: bool = False, keep: bool = False) None[source][source]#

Stop and optionally remove all containers from the cluster.

Parameters:
  • sig_kill (bool, optional) – If True, containers will be stopped using SIGKILL instead of SIGTERM.

  • keep (bool, optional) – If True, containers will be stopped but not removed.

restart() None[source][source]#

Restart all cluster containers (coordinator and workers).

restart_containers(c_restart: list[str] | None = None) None[source][source]#

Restart all the containers in the provided list.

Parameters:

c_restart (Optional[list[str]], optional) – List of fully-qualified container names to restart, by default None.

remove(obj_type: str, force: bool, modules: list[str] | None = None) None[source][source]#

Remove Docker objects associated with the current cluster.

Parameters:
  • obj_type (str) – Type of Docker object to remove. Must be an image, volume, or network.

  • force (bool) – If True, forces removal even if the resource is in use.

  • modules (list[str], optional) – Module names to filter which resources should be removed.

Raises:

UserError – If attempting to remove images for a specific cluster or module.

Notes

This method deletes the specified Docker resource type(s) filtered by labels (sourced from provided modules, cluster name, or the project root label).

Because images are global project resources (they are not tied to any one cluster or module), they can only be removed as a global operation (using –cluster all and omitting –module).

rollback() None[source][source]#

Terminate the provision operations and remove the cluster.