@startuml machine-controller-reconcile start; :Machine controller; repeat :Reconcile; if (Machine has DeletionTimestamp) then (yes) if (Machine has in-flight task) then (yes) #LightGreen:Requeue; else (no) if (Machine has a ProviderID) then (yes) #edf7de:Find VM by BIOS UUID; else (no) #edf7de:Find VM by instance UUID; endif if (VM exists) then (yes) #edf7de:Delete VM; #edf7de:Assign delete TaskRef to Machine; #LightGreen:Requeue; endif endif else (no) if (Machine has in-flight task) then (yes) #LightGreen:Requeue; else (no) if (Machine has a ProviderID) then (yes) #edf7de:Find VM by BIOS UUID; else (no) #edf7de:Find VM by instance UUID; endif if (VM exists) then (yes) if (VM metadata matches calculated metadata) then (no) #edf7de:Reconfigure VM with calculated metadata; #edf7de:Assign reconfigure TaskRef to Machine; #LightGreen:Requeue; else (yes) #edf7de:Update Machine status with MAC addresses from VM; if (VM powered on) then (no) #edf7de:Power on VM; #edf7de:Assign power TaskRef to Machine; #LightGreen:Requeue; else (yes) if (VM has IP addresses) then (yes) #edf7de:Update Machine status with IP addresses from VM; else (no) #LightGreen:Requeue; endif endif endif else (no) #edf7de:Clone template to create new VM; #edf7de:Assign clone TaskRef to Machine; #LightGreen:Requeue; endif endif endif #edf7de:Machine state patched back to API server; repeat while (Reconcile is requeued) is (yes) -> no; if (Error occurred) then (yes) #Pink:Reconcile failed; else (no) #LightBlue:Reconcile success; endif stop; @enduml