-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[server][Action] Reexecute action mechanism. #2472
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -549,6 +549,52 @@ void ActionManager::checkEvents(const EventInfoList &eventList) | |
} | ||
} | ||
|
||
void ActionManager::reExecuteUnfinishedAction(void) | ||
{ | ||
ThreadLocalDBCache cache; | ||
DBTablesAction &dbAction = cache.getAction(); | ||
DBTablesMonitoring &dbMonitoring = cache.getMonitoring(); | ||
|
||
ActionLogList actionLogList; | ||
const vector<int> targetStatuses{ACTLOG_STAT_QUEUING, | ||
ACTLOG_STAT_STARTED, | ||
ACTLOG_STAT_RESIDENT_QUEUING, | ||
ACTLOG_STAT_LAUNCHING_RESIDENT}; | ||
|
||
if (!dbAction.getTargetStatusesLogs(actionLogList, targetStatuses)) { | ||
MLPL_INFO("Hatohol does not have unfinished action.\n"); | ||
return; | ||
} | ||
|
||
for (const auto &actionLog: actionLogList) { | ||
EventInfoList eventList; | ||
EventsQueryOption eventOption(USER_ID_SYSTEM); | ||
|
||
eventOption.setTargetServerId(actionLog.serverId); | ||
eventOption.setEventIds({actionLog.eventId}); | ||
dbMonitoring.getEventInfoList(eventList, eventOption); | ||
if (eventList.empty()) | ||
continue; | ||
auto const &eventInfo = *eventList.cbegin(); | ||
|
||
ActionDefList actionList; | ||
ActionsQueryOption actionOption(USER_ID_SYSTEM); | ||
ActionIdList actionIdList{actionLog.actionId}; | ||
actionOption.setActionIdList(actionIdList); | ||
dbAction.getActionList(actionList, actionOption); | ||
|
||
if (actionList.empty()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here too |
||
continue; | ||
dbAction.updateLogStatusToAborted(actionLog.id); | ||
runAction(*actionList.cbegin(), eventInfo, dbAction); | ||
const string message = | ||
StringUtils::sprintf("Action log ID(%" FMT_GEN_ID "): " | ||
"Update log status to aborted(7).\n", | ||
actionLog.id); | ||
MLPL_WARN("%s", message.c_str()); | ||
} | ||
} | ||
|
||
// --------------------------------------------------------------------------- | ||
// Protected methods | ||
// --------------------------------------------------------------------------- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ using namespace mlpl; | |
#include "ConfigManager.h" | ||
#include "ThreadLocalDBCache.h" | ||
#include "ChildProcessManager.h" | ||
#include "ActionManager.h" | ||
|
||
static string pidFilePath; | ||
static int pipefd[2]; | ||
|
@@ -244,6 +245,11 @@ int mainRoutine(int argc, char *argv[]) | |
|
||
// setup configuration database | ||
ThreadLocalDBCache cache; | ||
|
||
// Re execute unfinished action | ||
ActionManager actionManager; | ||
actionManager.reExecuteUnfinishedAction(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. memo: I've noticed that Hatohol server blocks in this line when bunch of unfinished actions are remained. |
||
|
||
// start REST server | ||
// 'rest' is on a stack. The destructor of it will be automatically | ||
// called at the end of this function. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have to show warning in this condition ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to show logs