Conversation
|
|
||
| for (const IReadyCondition* ready_condition : ready_conditions_) | ||
| { | ||
| const osal::OsalReturnType result = ready_condition->wait(handle_.value()); |
There was a problem hiding this comment.
Currently we have one overall ready timeout for the component.
if we had multiple ready conditions, I think this would mean all ready condition must be fulfilled within the ready_timeout. So it would not be that each ready condition can take the full ready timeout.
This makes me think that it could make sense to move the timeout checking in the component. Same for the shutdown timeout
| { | ||
| return score::cpp::make_unexpected(ComponentError::kErrorBeforeReady); | ||
| } | ||
| handle_ = result.value(); |
There was a problem hiding this comment.
I wonder how to handle the case that the component crashes before ready condition is fulfilled.
Is this in the responsibility of each ready condition to continuously check if the component is still running?
| } | ||
|
|
||
| Component::Component( | ||
| const IStartAction* start_action, |
There was a problem hiding this comment.
With the division into start/stop actions I am wondering what is keeping track of the process state.
What will own the process handle?
I think at every point in time we need to know what is the state of any process we started, and what is the state of the component
There was a problem hiding this comment.
The handle is owned by the component, and should track the state of the underlying resource (a process, a container, etc) but not the state of the component itself. It may be useful to make the handle mutable, for example to clear the PID if the process has crashed.
Currently the state at the component level is just whether or not a handle currently exists. But this should be extended to an enum such as starting, stopping, failed... which is updated as we run each action and in response to external events.
| return score::cpp::make_unexpected(ComponentError::kErrorAfterReady); | ||
| } | ||
|
|
||
| IComponent::RequestResult Component::tryHandleTermination(int32_t status) |
There was a problem hiding this comment.
I wonder how to judge now if the process crashed or was intentionally terminated (as the result of the stop_action/force_stop_action or the process is configured as self-terminating and we are waiting for this in the ready condition).
There was a problem hiding this comment.
Similar to the other comment, we could store this state at the component level.
|
|
||
| if (process.pid > 0) | ||
| { | ||
| if (kill(process.pid, SIGTERM) == 0) |
There was a problem hiding this comment.
I think we'll need to decide where the timeout monitoring takes place for the shutdown and the escalation to SIGKILL in case of timeout
| return score::cpp::make_unexpected(ComponentError::kActivationTimedOut); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
I think we'll need to decide how the supervision is handled.
I think a natural point would be to start supervision here after all ready conditions are fulfilled.
Currently, this will always translate to start supervision when kRunning reported.
Though for this we also need the timestamp from the kRunning report, as the supervision has to be started exactly at this timestamp.
There was a problem hiding this comment.
Maybe it would be possible to have IpcCommsSync store the timestamp (as it should happen only once per instance). That is already stored inside ProcessHandle, so it would be accessible to the supervision.
ProcessInfoNode and ProcessLauncherComponent class
This uses the existing component interface, so it should be fully compatible with existing callers.
This will be needed to remove the direct use of process identifiers in `Graph::forceKillProcesses`, making it flexible to other kinds of components.
These will be used for run targets, which do not contain any underlying process.
These use the existing `ProcessLauncher` for the time being; eventually the code from `ProcessLauncher` should be migrated into the actions themselves.
Follow the naming conventions.
Start, stop, force stop, and ready conditions are now implemented as strategies which plug in to a central
Componentclass.The only interaction between these classes is a tiny
Handlestruct, which identifies the child process to act upon.Ideally, the handle will stay internal to the
Component, and higher level classes such asProcessGroupManagerand theGraphwill have no knowledge of the underlying process.This new architecture should improve:
ProcessInfoNodehaving a mixture of process- and component-level code.ProcessLauncheralso having code for process termination.As a start, this pull request just introduces the new classes, and has them call the existing
ProcessLauncherfrom its original location.Once the new component class is ready, we can change the
Graphto start using it in place ofProcessInfoNode. Currently it is unused outside of tests.Finally, we will clean up by moving the old code into its new locations (rather than just calling it).