From fb367e12cc1c226af2f515d9072d33ada21daf1e Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 28 Sep 2018 11:08:58 +0200 Subject: [PATCH] Store the last failed zone stage sync validation as runtime ApiListener attribute --- lib/remote/apilistener-filesync.cpp | 17 ++++++++++++++++- lib/remote/apilistener.hpp | 2 ++ lib/remote/apilistener.ti | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index 5de7df299..f851153fe 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -385,7 +385,12 @@ void ApiListener::TryActivateZonesStageCallback(const ProcessResult& pr, } else { Log(LogCritical, "ApiListener") << "Config validation failed for staged cluster config sync. Aborting. Logs: '" - << GetApiZonesStageDir() + "/startup.log'"; + << logFile << "'"; + + ApiListener::Ptr listener = ApiListener::GetInstance(); + + if (listener) + listener->UpdateLastFailedZonesStageValidation(pr.Output); } } @@ -416,3 +421,13 @@ void ApiListener::AsyncTryActivateZonesStage(const String& stageConfigDir, const process->SetTimeout(300); process->Run(std::bind(&TryActivateZonesStageCallback, _1, stageConfigDir, currentConfigDir, relativePaths, reload)); } + +void ApiListener::UpdateLastFailedZonesStageValidation(const String& log) +{ + Dictionary::Ptr lastFailedZonesStageValidation = new Dictionary({ + { "log", log }, + { "ts", Utility::GetTime() } + }); + + SetLastFailedZonesStageValidation(lastFailedZonesStageValidation); +} diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp index e8512cd6b..757de7e87 100644 --- a/lib/remote/apilistener.hpp +++ b/lib/remote/apilistener.hpp @@ -187,6 +187,8 @@ private: static void AsyncTryActivateZonesStage(const String& stageConfigDir, const String& currentConfigDir, const std::vector& relativePaths, bool reload); + void UpdateLastFailedZonesStageValidation(const String& log); + /* configsync */ void UpdateConfigObject(const ConfigObject::Ptr& object, const MessageOrigin::Ptr& origin, const JsonRpcConnection::Ptr& client = nullptr); diff --git a/lib/remote/apilistener.ti b/lib/remote/apilistener.ti index 4217ce0ab..ac17ccfcf 100644 --- a/lib/remote/apilistener.ti +++ b/lib/remote/apilistener.ti @@ -54,6 +54,8 @@ class ApiListener : ConfigObject [state, no_user_modify] Timestamp log_message_timestamp; [no_user_modify] String identity; + + [state, no_user_modify] Dictionary::Ptr last_failed_zones_stage_validation; }; }