Background
DCE's current plugin mechanism is pod lifecycle centric, and allows custom extensions to be plugged in around the steps needed to launch a pod (i.e. custom plugins can be added pre/post of image pull, compose up steps)
Requirement
There are situations that demand custom logic executions outside of pod lifecycle, and aligned with the executor's API functions. For example, we have a requirement to execute some custom logic to post error related metrics whenever the the control exits LaunchTask implementation of dce-go.
This may be applicable for other executor API methods too but scope of this issue could deal with LaunchTask and allow extensibility for all API methods.
Proposed Design
Executor Hook
- ExecutorHook allows custom implementations to be plugged post execution of Docker Compose Mesos Executor's API methods
- Here is a representation of proposed ExecutorHook interface
type ExecutorHook interface {
// PostExec is invoked post execution of Docker Compose Mesos Executor's lifecycle function
PostExec(taskInfo *mesos.TaskInfo) error
// BestEffort is invoked in case a PostExec returned an error and are expected to return a bool to indicate
// if the execution needs to continue with the next available hook or not
BestEffort(execPhase string) bool
}
- Config for executor hook is defined based on the method of the executor API as shown below. For current requirement explained above, supporting post execution of LaunchTask is only needed. But there are possibilities to introduce "Pre" hooks and for a different API method of the executor so the config structure is designed to support that.
...
execHooks:
LaunchTask:
Post: ["hook1", "hook2"]
...
So, on exit from LaunchTask, most definite thing that is done in the current DCE is to send status to mesos. So to perform the post executions, we can introduce a task status channel and have the hooks executed based on various status changes.
Background
DCE's current plugin mechanism is pod lifecycle centric, and allows custom extensions to be plugged in around the steps needed to launch a pod (i.e. custom plugins can be added pre/post of image pull, compose up steps)
Requirement
There are situations that demand custom logic executions outside of pod lifecycle, and aligned with the executor's API functions. For example, we have a requirement to execute some custom logic to post error related metrics whenever the the control exits LaunchTask implementation of dce-go.
This may be applicable for other executor API methods too but scope of this issue could deal with LaunchTask and allow extensibility for all API methods.
Proposed Design
Executor Hook
So, on exit from LaunchTask, most definite thing that is done in the current DCE is to send status to mesos. So to perform the post executions, we can introduce a task status channel and have the hooks executed based on various status changes.