Skip to content

Commit

Permalink
[occ] do not call iterateCheck when in ERROR
Browse files Browse the repository at this point in the history
There is no point in asking the controlled task for a health check if it's still in ERROR.
The task can go to healthy state by requesting a recover transition, which gives a success or failure as a return value.

OCTRL-958
  • Loading branch information
knopers8 authored and teo committed Dec 11, 2024
1 parent de4d866 commit 50cf2cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 13 additions & 11 deletions occ/occlib/OccServer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -437,17 +437,19 @@ void OccServer::runChecker()
}
}

// execute periodic check, in any state
int err = m_rco->iterateCheck();
// if there's an error but the SM hasn't been moved to t_State::error yet
if (err && (m_rco->getState() != t_State::error)) {
updateState(t_State::error);

// the above publishes a state change event to the StateStream, but we also push an exception event on the
// EventStream because the transition was initiated by the task
auto taskErrorEvent = new pb::DeviceEvent;
taskErrorEvent->set_type(pb::TASK_INTERNAL_ERROR);
pushEvent(taskErrorEvent);
// execute periodic check, in any state except ERROR
if (m_rco->getState() != t_State::error) {
int err = m_rco->iterateCheck();
// if there's an error but the SM hasn't been moved to t_State::error yet
if (err) {
updateState(t_State::error);

// the above publishes a state change event to the StateStream, but we also push an exception event on the
// EventStream because the transition was initiated by the task
auto taskErrorEvent = new pb::DeviceEvent;
taskErrorEvent->set_type(pb::TASK_INTERNAL_ERROR);
pushEvent(taskErrorEvent);
}
}

m_mu.unlock();
Expand Down
4 changes: 2 additions & 2 deletions occ/occlib/RuntimeControlledObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ class OCC_EXPORT RuntimeControlledObject {
virtual int iterateRunning();

/**
* Perform periodic checks during every state.
* Perform periodic checks during every state except ERROR.
*
* @return 0 if the check completed successfully and the machine can stay in the current state,
* or any other value to immediately trigger a transition to the error state.
*
* This function is called continuously by OccServer::runChecker in any state, including
* This function is called continuously by OccServer::runChecker in any state except ERROR, including
* t_State::running. Its purpose is for the implementer to report an unusual condition in
* order to trigger a transition to t_State::error.
*/
Expand Down

0 comments on commit 50cf2cd

Please sign in to comment.