Groups
A group keeps workers, triggers and child groups together (openspec resource-groups): what a
script, notebook or client deployed, a schedule several groups share, a scenario under several
scenario sets. A group is an infra concept: what it stands for is known only to its creator. How to
use them: Use groups.
The record
| Field | Meaning |
|---|---|
id |
A UUID in canonical form (lower case, hyphenated), generated (version 7) or given at creation; never changes |
parents |
The groups it belongs to, possibly none, possibly several; each existed when added |
owners |
Principals: user:<sub> (the identity provider's subject) or idp-group:<name> |
scopes |
Name prefixes of state keys and topics, each ending with . (e.g. sc.S1.) |
tags |
Free-form metadata; the display name is the name tag |
created |
When it was created |
deleting |
A DeleteGroup started and has not finished |
Members are not listed on the group: membership is a field of each member (WorkerInfo.groups,
the api's TriggerDetail.groups, a child's parents), changed by a compare-and-swap on that
member's own record. So two scripts changing one member at once never lose a change, and a group's
members are computed (ListWorkers{group}, the api's ListTriggers{group}, ListGroups{parent}).
Membership is never a tag (Properties, config and tags).
Calls
| Call | What it does |
|---|---|
CreateGroup{id?, tags, parents, owners, scopes} → {id} |
A given id must be a canonical UUID (INVALID_FIELD) and free (ALREADY_EXISTS/ID_EXISTS, nothing changed); every parent must exist (FAILED_PRECONDITION/GROUP_NOT_FOUND) |
GetGroup{id} |
The group; NOT_FOUND when there is none |
ListGroups{parent?, tag_filters} |
Oldest first; with parent only its children, with tag_filters only those carrying every key with its value |
UpdateGroupTags{id, set, remove} |
One atomic merge; a key in both is refused |
SetGroupOwners{id, owners} |
Replaces the owners |
SetGroupScopes{id, scopes} |
Replaces the scopes |
AddToGroup{group, workers, triggers, groups} |
Puts members in; child groups get group among their parents. Everything named is checked first (a missing worker is NOT_FOUND, a child that would close a loop CYCLE); a member already in is left as it is. Triggers go through the api's AddTriggerToGroup |
RemoveFromGroup{group, workers, triggers, groups} |
Takes members out. Never deletes: a member left in no group stays, ungrouped |
DeleteGroup{id, recursive} |
See below |
ResolveGroupOwners{id} |
The union of the group's owners and every ancestor's, sorted |
GroupsCovering{name} |
The ids of the groups with a scope that is a prefix of a state key or topic |
A worker can also be created into groups (CreateWorkerRequest.groups), and a trigger scheduled
into them (the api's ScheduleTrigger{groups}).
Owners and scopes are stored and resolved here; whether a call is allowed is decided by access-control. Scopes are not inherited by child groups.
Deleting a group
DeleteGroup removes the group and every member that then belongs to no group:
- The group is marked
deleting: nothing more can be added to it (DELETING). - Every member loses this membership, by a compare-and-swap on its own record.
- A member still in another group is kept, running, without this membership.
- The removal that takes a member's last membership decides its deletion: the member is
marked deleting (it keeps that last group until it is gone, and joins nothing else), then a
worker is stopped and deleted, a trigger deleted through the api (
DeleteTrigger). Two group deletions racing on a shared member delete it exactly once. - With
recursive, child groups are members like the others: a child with another parent only loses this one and is kept, members and all; every other child is deleted first, by the same rules. Withoutrecursive, a group with children is refused (FAILED_PRECONDITION, the child asresource).
- When every member is done, the group's record goes (
deletedevent).
The answer lists every member's outcome: kind (worker, trigger, group), id, result
(DELETED, KEPT with its remaining_groups, FAILED with its reason). When a member failed,
the call fails with ABORTED (PARTIAL_FAILURE), its details carry that DeleteGroupResponse,
and the group stays deleting; repeating DeleteGroup finishes the work (members already done
are skipped).
Deleting a worker directly (DeleteWorker) takes it out of all its groups; a group may become
empty and stays until it is deleted. When a worker is deleted, the triggers it owns that are in no
group are deleted, and those in a group keep firing with their owner cleared.
Events
Every change publishes a GroupEvent (workmanager_events.proto) on
sys.workmanager.group.lifecycle (ce-type com.virtufin.workmanager.group.lifecycle, subject
group/<id>, content type application/x-virtufin-group-event+protobuf). state names the
change, and the event carries the group as stored after it:
state |
When | Extra |
|---|---|---|
created |
CreateGroup |
|
tags, owners, scopes |
the matching call changed them | |
parents |
the group was added to or removed from a parent | |
members |
workers, triggers or child groups joined or left | added_workers, removed_workers, added_triggers, removed_triggers, added_groups, removed_groups |
deleting |
DeleteGroup started |
|
deleted |
DeleteGroup finished |
the group as it was |
A worker's membership change also publishes its lifecycle updated with changed = ["groups"]
(Worker lifecycle). Delivery is best effort: a client reads ListGroups
again after a resubscription.
Storage
sys.workmanager.group.<id> (one group's JSON record) and sys.workmanager.group.index (the ids,
in creation order), in the WorkManager's State service; names from the virtufin.service.workmanager
naming fragment (Naming).