Skip to content

brokkr-agent::work_order_marks

Rust

Which work order a Kubernetes object belongs to (BROKKR-T-0406).

The agent marks what it applies for a work order with brokkr.io/work-order-id: an annotation on each object of a custom work order, and a label on the BuildRun of a build work order. A pod never carries the mark itself, because the agent does not change pod templates. A pod belongs to a work order through its owners: Job → Pod, or BuildRun → TaskRun → Pod.

The pod log tailer and the kube event tailer use this to send the telemetry of a work order with the work order id in place of a stack id.

pub

What a telemetry frame is about: a stack, or a work order. A frame has exactly one of the two ids.

  • Stack
  • WorkOrder

pub

fn ids(self) -> (Option<Uuid>, Option<Uuid>)

(stack_id, work_order_id) for a wire frame.

Source
pub fn ids(self) -> (Option<Uuid>, Option<Uuid>) {
match self {
TelemetryKey::Stack(id) => (Some(id), None),
TelemetryKey::WorkOrder(id) => (None, Some(id)),
}
}

pub

fn stamp(object: &mut DynamicObject, work_order_id: Uuid)

Marks an object that the agent applies for a work order.

Source
pub fn stamp(object: &mut DynamicObject, work_order_id: Uuid) {
object
.metadata
.annotations
.get_or_insert_with(Default::default)
.insert(WORK_ORDER_ID_KEY.to_string(), work_order_id.to_string());
}

pub

fn direct_mark(meta: &ObjectMeta) -> Option<Uuid>

The work order an object is marked with: the label, or the annotation.

Source
pub fn direct_mark(meta: &ObjectMeta) -> Option<Uuid> {
let from = |map: Option<&std::collections::BTreeMap<String, String>>| {
map.and_then(|m| m.get(WORK_ORDER_ID_KEY))
.and_then(|v| Uuid::parse_str(v).ok())
};
from(meta.labels.as_ref()).or_else(|| from(meta.annotations.as_ref()))
}
Name Type Value Description
WORK_ORDER_ID_KEY &str "brokkr.io/work-order-id" The key of the mark, as an annotation or as a label.