
nodecleanup-activities
Index
- func HumanBytes(n int64) string
- type Activities
- func New(cfg Config) *Activities
- func (a *Activities) CleanupNodeViaSSH(ctx context.Context, node NodeInfo, config CleanupConfig) (CleanupResult, error)
- func (a *Activities) FindRegistryNode(ctx context.Context, jobName string) (NodeInfo, error)
- func (a *Activities) GetAllNomadClientNodes(ctx context.Context) ([]NodeInfo, error)
- func (a *Activities) MeasureRegistryDataDir(ctx context.Context, node NodeInfo, dataDir string) (int64, error)
- func (a *Activities) RunRegistryGarbageCollect(ctx context.Context, node NodeInfo, config RegistryGCConfig) (RegistryGCRunResult, error)
- func (a *Activities) ScaleRegistry(ctx context.Context, jobName, groupName string, count int) error
- func (a *Activities) WaitRegistryAllocRunning(ctx context.Context, jobName string) error
- func (a *Activities) WaitRegistryAllocsDrained(ctx context.Context, jobName string) error
- type CleanupConfig
- type CleanupResult
- type Config
- type NodeInfo
- type RegistryGCConfig
- type RegistryGCResult
- type RegistryGCRunResult
func HumanBytes
HumanBytes renders a byte count in a compact human-friendly form (KiB, MiB, GiB) matching the shape of `du -h`. Exported so the workflow can format the before/after/reclaimed sizes consistently.
type Activities
Activities holds shared dependencies for node cleanup activities. Register an instance with the Temporal worker to expose all exported methods as activity implementations.
func New
New creates an Activities instance with validated configuration.
func (*Activities) CleanupNodeViaSSH
CleanupNodeViaSSH connects to a node over SSH and executes a cleanup script that identifies and optionally removes orphaned job data directories. Returns detailed results including counts and any errors.
func (*Activities) FindRegistryNode
FindRegistryNode queries the Nomad API for the running alloc of the registry job and returns the NodeInfo for SSH dialing. Wraps a “no running alloc” condition as a non-retryable error so the workflow fails fast instead of retry-storming on a terminally-misconfigured cluster.
func (*Activities) GetAllNomadClientNodes
GetAllNomadClientNodes retrieves all ready Nomad client nodes with their SSH addresses and node metadata. Creates a client span to Nomad for service graph visibility.
func (*Activities) MeasureRegistryDataDir
MeasureRegistryDataDir returns the size in bytes of the registry’s bind-mounted storage directory on the given node. Used for before/after reporting. SSH-only because /mnt/gdrive is host-side; the Nomad API doesn’t expose disk usage.
func (*Activities) RunRegistryGarbageCollect
RunRegistryGarbageCollect SSHes to the registry host and runs the docker garbage-collect command against the bind-mounted storage. This is the long-running step (multi-GB registries take minutes); it heartbeats periodically and reports the count of “blob eligible for deletion” lines emitted by the registry tool.
Configured with MaxAttempts=1 by the workflow — a partial GC run shouldn’t be repeated; let the deferred scale-back put the registry online instead and surface the failure.
func (*Activities) ScaleRegistry
ScaleRegistry scales the named Nomad job’s task group to the target count. Idempotent — Nomad accepts the call when the job is already at the requested count and returns success. Used both to scale down to 0 before GC and to scale back to 1 in the deferred compensation. A “job not found” error is wrapped as non-retryable; transient API errors surface plain so Temporal retries per the activity’s RetryPolicy.
func (*Activities) WaitRegistryAllocRunning
WaitRegistryAllocRunning polls the Nomad API until the named job has at least one running allocation (i.e. the scale-up succeeded and a new alloc passed its start sequence). Bounded by the activity’s StartToCloseTimeout.
func (*Activities) WaitRegistryAllocsDrained
WaitRegistryAllocsDrained polls the Nomad API until the named job has zero running allocations. Heartbeats every poll. Bounded by the activity’s StartToCloseTimeout (set on the workflow side); returns ctx.Err() when exceeded.
type CleanupConfig
CleanupConfig holds workflow-level configuration passed as input.
type CleanupResult
CleanupResult holds the outcome of a cleanup operation on a single node.
type Config
Config holds SSH-related settings for node cleanup activities.
func (*Config) Validate
Validate applies defaults for optional fields.
type NodeInfo
NodeInfo contains information about a Nomad client node needed for SSH connection and cleanup script execution.
type RegistryGCConfig
RegistryGCConfig holds workflow-level configuration passed as input.
func (*RegistryGCConfig) ApplyDefaults
ApplyDefaults fills in unset fields with their defaults. Called by the workflow before any activities run so every activity sees a fully populated config and the values are deterministic across replay.
type RegistryGCResult
RegistryGCResult holds the workflow-level outcome reported back to the trigger / caller.
type RegistryGCRunResult
RegistryGCRunResult is the small struct returned by RunRegistryGarbageCollect. The workflow folds it into RegistryGCResult.
Generated by gomarkdoc