Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

PlantUML Macro
@startuml
hide empty description
title Deployment Intent Group state transitions\nwith AppContext state transitions illustrated
state Created #LightGreen
state Approved #LightGreen
state Instantiated #LightGreen
state Terminated #LightGreen

[*] -down-> Created : Create Deployment\nIntent Group
Created --> Created : //Modify intents//
Created -down-> Approved : POST approve
note left of Created
  //Modify intents// encompasses
  adding/deleting/updating the
  intents assigned to a Deployment
  Intent Group as well as updating
  the Deployment Intent Group itself
end note

  

Approved -down-> Instantiated : POST instantiate
Approved -> Created : //Modify intents//

Instantiated -down-> Terminated: POST terminate
Terminated -up-> Instantiated: POST instantiate


state Instantiated #LightGreen {
    state "Instantiated" as acInstantiated #LightBlue
    state Instantiating #LightBlue
    state InstantiateFailed #LightBlue
 
    Instantiating -> InstantiateFailed
    Instantiating -> acInstantiated
 
}

state Terminated #LightGreen {
    state "PreTerminate" #LightBlue
    state "Terminated" as acTerminated #LightBlue
    state "Terminating" #LightBlue
    state "TerminateFailed" as termFailed #LightBlue
    PreTerminate -> Terminating
    Terminating -> termFailed
    Terminating -> acTerminated
 }

Terminated --> Created: //Modify intents//
Created --> [*]: DELETE Deployment Intent Group
@enduml

...

PlantUML Macro
@startuml
hide empty description
title AppContext State Transition
state Instantiated #LightBlue
state Instantiating #LightBlue
state InstantiateFailed #LightBlue
state PreTerminate #LightBlue
state Terminating #LightBlue
state Terminated #LightBlue
state TerminateFailed #LightBlue
 
[*] -> Instantiating : **gRPC instantiate**
Instantiating -> InstantiateFailed : //any resource//\n//Apply Failed//
Instantiating -> Instantiated : //all resources//\n//Applied//

Instantiating --> PreTerminateTerminating : **gRPC terminate**\n//old instantiate//\n//go routines//\n//cleaned up//
Instantiated --> Terminating : **gRPC terminate**
InstantiateFailed --> Terminating : **gRPC terminate**
PreTerminate -> Terminating : //old instantiate//\n//go routines//\n//cleaned up//

note left of PreTerminateTerminating
  Transition to PreTerminate/Terminating
  is allowed to occur when the controlleringcontrolling
  EMCO resource (e.g. DeploymentIntentGroup
  or Cluster) is in the Instantiated state
end note

Terminating -> Terminated : //all resources//\n//Deleted//
Terminating --> TerminateFailed : //some resources//\n//Delete Failed//
@enduml

...

PlantUML Macro
@startuml
hide empty description
title Rsync Resource State Transition (with corresponding AppContext states)
 
[*] -left-> Instantiating #LightBlue : **gRPC**\n**instantiate**
[*] -right-> Pending : **AppContext**\n**changes to**\n**Instantiating**
Pending -> Applied : Successful\napply
Pending --> Failed : Failed apply\nor delete
Pending --> Retrying

Failed --> Deleted : **AppContext**\n**changes to**\n**Terminating**
Pending --> Deleted : **AppContext**\n**changes to**\n**Terminating**
Retrying --> Deleted : **AppContext**\n**changes to**\n**Terminating**
Applied --> Pending : **AppContext**\n**changes to**\n**Terminating**
Pending --> Deleted : successful\ndelete
Retrying -> Applied
Retrying --> Retrying 
Retrying --> Deleted : successful\ndelete
Retrying --> Failed : Exceed\nretry time

Instantiating -left-> PreTerminateTerminating #LightBlue : **//gRPC//**\n**//terminate//**
note left of PreTerminate
  On gRPC terminate, if the
  AppContext is Instantiating
  then it moves to PreTerminate
  and any resources states that
  have not reached a final state
  (Applied or Failed) have to be
  set to Deleted
end note
PreTerminate -down-> Terminating #LightBlue : //all resource states//\n//old instantiate threads//\n//etc. cleaned up//

X #LightBlue -up-> Terminating : **//gRPC//**\n**//terminate//**\n//from InstantiateFailed//\n//or Instantiated//
Failed --> InstantiateFailed #LightBlue : //any resource//
Failed --> TerminateFailed #LightBlue : //any resource//
Applied --> Instantiated #LightBlue : //all resources//
Deleted --> Terminated #LightBlue : //all resources//
@enduml

...

PlantUML Macro
@startuml
title DeploymentDeploymenet Intent Group Instantiation Sequence
actor Admin

box "Orchestrator"
participant scheduler
participant generic_placement_controller
end box

box "EMCO DB"
database mongo
end box

box "AppContext"
participant etcd
end box

box "resource synchronizer"
participant rsync
participant appcontext_watcher
collections worker_thread
collections cluster_watcher
end box

box "Edge Cluster"
participant API_Server
participant cluster_etcd
participant monitor
end box


Admin -> scheduler : POST instantiate\nDeployment Intent Group
activate scheduler
activate scheduler #Red

scheduler -> mongo : retrieve Deployment Intent Group
scheduler -> Admin : ERROR if wrong state
deactivate scheduler #Red

scheduler -> generic_placement_controller : create AppContext
activate generic_placement_controller

generic_placement_controller -> mongo : get generic placement intent
generic_placement_controller -> etcd : create AppContext and metadata
generic_placement_controller ->scheduler : done
deactivate generic_placement_controller


scheduler -> scheduler : invoke all other\nplacement and action\ncontrollers (not shown)

scheduler -> rsync : gRPC call to instantiate AppContext
activate rsync
activate rsync #Red

rsync -> etcd : SetInitialize Appcontext state=Instantiating\nSet Resources state=Pendingstate=Pending
rsync -> etcd : Initialize StopFlag=False
rsync -> scheduler : Return Error if on occurs
deactivate rsync #Red
scheduler --> Admin : Return ERROR

create appcontext_watcher
rsync -> appcontext_watcher: invoke thread to instantiate AppContext
activate appcontext_watcher
appcontext_watcher -> etcd : start watching StopFlag
rsync -> scheduler : return OK
deactivate rsync
scheduler -> Admin : Return OK
deactivate scheduler

create worker_thread
loop for each app
appcontext_watcher -> worker_thread : start thread to handle app
loop for each cluster
worker_thread -> worker_thread : start thread to handle cluster
create cluster_watcher
worker_thread -> cluster_watcher : invoke Watcher for\nResourceBundleState CRs\n(may already exist)
loop until all resources are Applied or a Failure occurs
worker_thread -> API_Server : Send Resource Apply to Cluster
worker_thread -> etcd : If success Resource State = Applied\nElse If Connectivity Error Resource State = Retrying\nElse Resource State = Failed
end
worker_thread -> API_Server : Apply ResourceBundleState CR

end
end
worker_thread -> appcontext_watcher : all worker threads complete
appcontext_watcher -> etcd : if any Resource = Failed, AppContext State = Failed\nElse All Resources=Applied, AppContext State = Instantiated

deactivate appcontext_watcher
@enduml

...

PlantUML Macro
@startuml
title Deployment Intent Group Termination Sequence

actor Admin

box "Orchestrator"
participant scheduler
participant generic_placement_controller
end box

box "EMCO DB"
database mongo
end box

box "AppContext"
participant etcd
end box

box "resource synchronizer"
participant rsync
participant old_appcontext_watcher
participant appcontext_watcher
collections old_worker_thread
collections worker_thread
collections cluster_watcher
end box

box "Edge Cluster"
participant API_Server
participant cluster_etcd
participant monitor
end box

activate old_appcontext_watcher
note right of old_appcontext_watcher : may be a thread still\nstill trying to instantiate\nthe appcontext
activate old_worker_thread
note left of old_worker_thread : may be thread(s) still trying\nto instantiate resources

old_appcontext_watcher <- etcd : watching AppContext stateStopFlag

Admin -> scheduler : POST terminate\nDeployment Intent Group
activate scheduler
activate scheduler #Red

scheduler -> mongo : retrieve Deployment Intent Group
scheduler -> Admin : ERROR if wrong state
deactivate scheduler #Red


scheduler -> rsync : gRPC call to terminate AppContext
activate rsync
activate rsync #Red


rsync -> etcd : If AppContext==Instantiating\nAppContext=PreTerminate\nElse AppContext=Terminating
create appcontext_watcher
rsync -> appcontext_watcher ++ : invoke thread to terminate AppContext

create appcontext_watcher
rsync -> appcontext_watcher : invoke thread to terminate AppContext
appcontext_watcher -> etcd : Set StopFlag = True
etcd -> appcontext_watcher ++ #Red : start watching until AppContext==Instantiated OR StopFlag==False
etcd -> old_appcontext_watcher ++ #Red : detects StopFlag=True
old_appcontext_watcher -> old_worker_thread : terminate any running Instantiate threads
rsync -> scheduler : Return Error if one occurs at this stage
deactivate rsync #Red
scheduler --> Admin : Return ERROR
rsync -> scheduler : return OK
deactivate rsync
scheduler -> Admin : Return OK
deactivate scheduler


etcd -> appcontext_watcher : start watching for AppContext=Terminating
etcd -> old_appcontext_watcher ++ : detects AppContext=PreTerminate
old_appcontext_watcher
deactivate scheduler

old_worker_thread -> old_workerappcontext_threadwatcher : terminate anyall runningold Instantiatethreads threadsreturn
deactivate old_worker_thread
etcd <- old_appcontext_watcher -- #Red : Set AppContext=TerminatingStopFlag=False
rsync <- old_appcontext_watcher : old instantiate thread returns
deactivate old_appcontext_watcher

etcd <- appcontext_watcher -- : Detects AppContext==Instantiated OR StopFlag==False

etcd <- etcdappcontext_watcher : DetectsSet AppContext=TerminatedTerminating
activate appcontext_watcher #LightGreen

loop initialize all resources states for terminate handling
appcontext_watcher -> etcd : If Resource = Applied, Resource= Pending\nelseif Resource = (Pending, Failed, Retrying), Resource=Deleted
end

activate appcontext_watcher

loop for each app
create worker_thread
appcontext_watcher -> worker_thread : start thread to handle app
loop for each cluster
worker_thread -> worker_thread : start thread to handle cluster
loop until all resources are Deleted or Failed
worker_thread -> API_Server : Send Resource Delete to Cluster
worker_thread -> etcd : If success Resource State = Deleted\nElse If Connectivity Error Resource State = Retrying\nElse Resource State = Failed
end

loop waiting until deleted resources disappear from ResourceBundleState CR
monitor -> cluster_etcd : Update ResourceBundleState CR\nas resources get deleted
cluster_watcher <- cluster_etcd : Notifications of changes in\nResourcebundleState CR
cluster_watcher -> etcd : Update Status at app-cluster\nin AppContext
worker_thread -> etcd : wait until ResourceBundleState CR is empty
end
worker_thread -> API_Server : Delete ResourceBundleState CR

end
end
worker_thread -> appcontext_watcher : all worker threads complete
appcontext_watcher -> etcd : if any Resource = Failed, AppContext State = Failed\nElse All Resources=Deleted, AppContext State = Terminated

deactivate appcontext_watcher
@enduml

...