crate.operator.change_compute module

class crate.operator.change_compute.AfterChangeComputeSubHandler(namespace, name, ref, context, depends_on=None, run_on_dep_failures=False, operation=None)

Bases: StateBasedSubHandler

A handler which depends on``restart`` having finished successfully and sends a success notification of the change compute process.

Parameters:
async handle(namespace, name, body, old, logger, **kwargs)
Parameters:
class crate.operator.change_compute.ChangeComputeSubHandler(namespace, name, ref, context, depends_on=None, run_on_dep_failures=False, operation=None)

Bases: StateBasedSubHandler

Parameters:
async handle(namespace, name, body, old, logger, **kwargs)
Parameters:
async crate.operator.change_compute.change_cluster_compute(apps, namespace, name, old, body, logger)

Patch the StatefulSet of every node group whose compute changed – the dedicated masters and/or any data group – each with its own resources. Pods pick up the new cpu/memory on the subsequent restart.

Parameters:
crate.operator.change_compute.compute_payload_for_specs(old_spec, new_spec)

Build a compute-change payload from a single node group’s old/new specs. The same StatefulSet patch is derived from this payload for masters and data groups alike (resources are read per group, since master CPU/mem may differ from data).

Return type:

WebhookChangeComputePayload

async crate.operator.change_compute.generate_body_patch(apps, name, namespace, compute_change_data, logger, sts_name=None)

Generates a dict representing the patch that will be applied to the statefulset. That patch modifies cpu/memory requests/limits based on compute_change_data. It also patches affinity as needed based on the existence or not of requests data.

Parameters:
  • sts_name (Optional[str]) – The StatefulSet to patch. Defaults to the first data group’s StatefulSet when omitted (callers patching the master or a specific data group pass it explicitly).

  • apps (AppsV1Api)

  • name (str)

  • namespace (str)

  • compute_change_data (WebhookChangeComputePayload)

  • logger (Logger)

Return type:

dict

crate.operator.change_compute.generate_change_compute_payload(old, body)
async crate.operator.change_compute.update_cprocessor_crate_settings(apps, namespace, sts_name, processors)

Call the Kubernetes API, update the -Cprocessors value in the crate container command, and return the updated command list.

Parameters:
  • apps (AppsV1Api) – An instance of the Kubernetes Apps V1 API.

  • namespace (str) – The Kubernetes namespace for the CrateDB cluster.

  • sts_name (str) – The name of the Kubernetes StatefulSet to update.

  • processors (float) – The new number of processors; fractional values are rounded up (ceil) to match how create bakes -Cprocessors.

Return type:

List[str]

Returns:

The updated command list.