Commit e487d500 authored by Christian Mohrbacher's avatar Christian Mohrbacher

mgmtd: allow to start with empty targetStates and nodeStates files

see #574

(cherry picked from commit 5e1fd706411ed01493c14e5f65e878fbaa1d0548)

Conflicts:
	fhgfs_mgmtd/source/app/App.cpp
parent 76604d8a
......@@ -688,7 +688,7 @@ void App::readTargetStates(const bool firstRun, StringMap& formatProperties,
MgmtdTargetStateStore* stateStore) throw(ComponentInitException)
{
if (stateStore->loadStatesFromFile())
{
{ // file could be read, so no need to proceed further
LOG(NOTICE, "Loaded storage target states.", as("NodeType", stateStore->nodeTypeStr(true)));
return;
}
......@@ -717,8 +717,15 @@ void App::readTargetStates(const bool firstRun, StringMap& formatProperties,
}
if (formatProperties[propertiesKey] == "1")
throw ComponentInitException("Could not load target or node states. NodeType: "
+ stateStore->nodeTypeStr(true) + ".");
throw ComponentInitException(
"Could not load target or node states. "
"The target and node states before the last shutdown are unknown. "
"If you want to start beegfs-mgmtd please manually create the files "
+ mgmtdPath->str() + "/" CONFIG_STORAGETARGETSTATES_FILENAME " "
"and " + mgmtdPath->str() + "/" CONFIG_METANODESTATES_FILENAME " "
"with empty contents. "
"The states will be recovered from the currently known states of the servers. "
"NodeType: " + stateStore->nodeTypeStr(true) + ".");
// The first run after an update - read the old file, and set the flag.
if (targetStateStore->loadResyncSetFromFile())
......
......@@ -619,6 +619,14 @@ bool MgmtdTargetStateStore::loadStatesFromFile()
return false;
}
if (readRes.second.size() == 0) // file was empty
{
LOG(WARNING, "Found empty target states file. "
"Proceeding without last known target states.",
as("NodeType", Node::nodeTypeToStr(nodeType)));
return true;
}
Deserializer des(&readRes.second[0], readRes.second.size());
RWLockGuard lock(rwlock, SafeRWLock_WRITE);
......@@ -630,6 +638,9 @@ bool MgmtdTargetStateStore::loadStatesFromFile()
return false;
}
LOG(NOTICE, "Loaded storage target states.",
as("NodeType", Node::nodeTypeToStr(nodeType)));
// Set all targets / nodes to POFFLINE to prevent switchover before we have report from anyone.
setAllStatesUnlocked(TargetReachabilityState_POFFLINE);
......
......@@ -12,6 +12,6 @@ on node do
raise "starting mgmtd should have failed"
else
raise "Should have included clear error message" unless \
result[:stdout].include? "Could not load target or node states. NodeType: Storage target."
result[:stdout].include? "Could not load target or node states."
end
end
on node do
shutdown_daemon_hard(node, "mgmtd")
shell "sudo truncate -s 0 #{node.properties["mgmtd"]["config"]["storeMgmtdDirectory"]}/targetStates"
shell "sudo truncate -s 0 #{node.properties["mgmtd"]["config"]["storeMgmtdDirectory"]}/nodeStates"
startup_daemon(node, "mgmtd", node.properties["mgmtd"]["config"])
end
desc:
Management daemon shall start up if targetStates and nodeStates
files are empty.
hosts:
node:
- mgmtd
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment