#include "icinga/icingaapplication.hpp"
#include "icinga/clusterevents.hpp"
#include "icinga/checkable.hpp"
+#include "remote/apilistener.hpp"
#include "base/application.hpp"
#include "base/objectlock.hpp"
#include "base/utility.hpp"
cr->SetState(ServiceWarning);
}
+ /* Indicate a warning when the last synced config caused a stage validation error. */
+ ApiListener::Ptr listener = ApiListener::GetInstance();
+
+ if (listener) {
+ Dictionary::Ptr validationResult = listener->GetLastFailedZonesStageValidation();
+
+ if (validationResult) {
+ output += "; Last zone sync stage validation failed at "
+ + Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", validationResult->Get("ts"));
+
+ cr->SetState(ServiceWarning);
+ }
+ }
+
/* Extract the version number of the running Icinga2 instance.
* We assume that appVersion will allways be something like 'v2.10.1-8-gaebe6da' and we want to extract '2.10.1'.
*/
Utility::CopyFile(stagePath, currentPath);
}
- Application::RequestRestart();
- } else {
- Log(LogCritical, "ApiListener")
- << "Config validation failed for staged cluster config sync in '" << GetApiZonesStageDir()
- << "'. Aborting. Logs: '" << logFile << "'";
-
ApiListener::Ptr listener = ApiListener::GetInstance();
if (listener)
- listener->UpdateLastFailedZonesStageValidation(pr.Output);
+ listener->ClearLastFailedZonesStageValidation();
+
+ Application::RequestRestart();
+
+ return;
}
+
+ /* Error case. */
+ Log(LogCritical, "ApiListener")
+ << "Config validation failed for staged cluster config sync in '" << GetApiZonesStageDir()
+ << "'. Aborting. Logs: '" << logFile << "'";
+
+ ApiListener::Ptr listener = ApiListener::GetInstance();
+
+ if (listener)
+ listener->UpdateLastFailedZonesStageValidation(pr.Output);
}
void ApiListener::AsyncTryActivateZonesStage(const String& stageConfigDir, const String& currentConfigDir,
SetLastFailedZonesStageValidation(lastFailedZonesStageValidation);
}
+
+void ApiListener::ClearLastFailedZonesStageValidation()
+{
+ SetLastFailedZonesStageValidation(Dictionary::Ptr());
+}
const std::vector<String>& relativePaths);
void UpdateLastFailedZonesStageValidation(const String& log);
+ void ClearLastFailedZonesStageValidation();
/* configsync */
void UpdateConfigObject(const ConfigObject::Ptr& object, const MessageOrigin::Ptr& origin,