if (!success)
return false;
- /* Load cluster synchronized configuration files. This can be disabled for staged sync validations. */
+ /* Load cluster synchronized configuration files. This can be overridden for staged sync validations. */
String zonesVarDir = Configuration::DataDir + "/api/zones";
/* Cluster config sync stage validation needs this. */
if (systemNS->Contains("ZonesStageVarDir")) {
zonesVarDir = systemNS->Get("ZonesStageVarDir");
- Log(LogInformation, "DaemonUtility")
+ Log(LogNotice, "DaemonUtility")
<< "Overriding zones var directory with '" << zonesVarDir << "' for cluster config sync staging.";
}
/* Spawn a validation process. On success, move the staged configuration
* into production and restart.
*/
- AsyncTryActivateZonesStage(GetApiZonesStageDir(), GetApiZonesDir(), relativePaths, true);
+ AsyncTryActivateZonesStage(GetApiZonesStageDir(), GetApiZonesDir(), relativePaths);
}
return Empty;
void ApiListener::TryActivateZonesStageCallback(const ProcessResult& pr,
const String& stageConfigDir, const String& currentConfigDir,
- const std::vector<String>& relativePaths, bool reload)
+ const std::vector<String>& relativePaths)
{
String logFile = GetApiZonesStageDir() + "/startup.log";
std::ofstream fpLog(logFile.CStr(), std::ofstream::out | std::ostream::binary | std::ostream::trunc);
/* validation went fine, copy stage and reload */
if (pr.ExitStatus == 0) {
Log(LogInformation, "ApiListener")
- << "Config validation for stage '" << GetApiZonesStageDir() << "' was OK, triggering reload.";
+ << "Config validation for stage '" << GetApiZonesStageDir() << "' was OK, copying into '" << GetApiZonesDir() << "' and triggering reload.";
for (const String& path : relativePaths) {
- /* TODO: Better error handling with existing files. */
- Log(LogCritical, "ApiListener")
- << "Copying file '" << path << "' from config sync staging to production directory.";
+ Log(LogNotice, "ApiListener")
+ << "Copying file '" << path << "' from config sync staging to production zones directory.";
String stagePath = GetApiZonesStageDir() + path;
String currentPath = GetApiZonesDir() + path;
Utility::CopyFile(stagePath, currentPath);
}
- if (reload)
- Application::RequestRestart();
+ Application::RequestRestart();
} else {
Log(LogCritical, "ApiListener")
- << "Config validation failed for staged cluster config sync. Aborting. Logs: '"
- << logFile << "'";
+ << "Config validation failed for staged cluster config sync in '" << GetApiZonesStageDir()
+ << "'. Aborting. Logs: '" << logFile << "'";
ApiListener::Ptr listener = ApiListener::GetInstance();
}
void ApiListener::AsyncTryActivateZonesStage(const String& stageConfigDir, const String& currentConfigDir,
- const std::vector<String>& relativePaths, bool reload)
+ const std::vector<String>& relativePaths)
{
VERIFY(Application::GetArgC() >= 1);
Process::Ptr process = new Process(Process::PrepareCommand(args));
process->SetTimeout(300);
- process->Run(std::bind(&TryActivateZonesStageCallback, _1, stageConfigDir, currentConfigDir, relativePaths, reload));
+ process->Run(std::bind(&TryActivateZonesStageCallback, _1, stageConfigDir, currentConfigDir, relativePaths));
}
void ApiListener::UpdateLastFailedZonesStageValidation(const String& log)
static void TryActivateZonesStageCallback(const ProcessResult& pr,
const String& stageConfigDir, const String& currentConfigDir,
- const std::vector<String>& relativePaths, bool reload);
+ const std::vector<String>& relativePaths);
static void AsyncTryActivateZonesStage(const String& stageConfigDir, const String& currentConfigDir,
- const std::vector<String>& relativePaths, bool reload);
+ const std::vector<String>& relativePaths);
void UpdateLastFailedZonesStageValidation(const String& log);