Commit 45274dfe authored by Bernd Lietzow's avatar Bernd Lietzow

Merge branch '875-backport-mgmtd-load-incomplete-targetstates' into 'v6'

Resolve Backport "Loading incomplete targetStates in mgmtd" to v6 #862

See merge request beegfs/projects0!673
parents 5cee708b 032b98fc
......@@ -304,9 +304,23 @@ bool TargetMapper::loadFromFile()
// add to attached states
if ( states )
{
const CombinedTargetState defaultState(TargetReachabilityState_POFFLINE,
TargetConsistencyState_GOOD);
CombinedTargetState ignoredReturnState;
for ( TargetMapCIter iter = targets.begin(); iter != targets.end(); iter++ )
states->addIfNotExists(iter->first,
CombinedTargetState(TargetReachabilityState_POFFLINE, TargetConsistencyState_GOOD) );
{
if (!states->getState(iter->first, ignoredReturnState)) {
LogContext(logContext).log(Log_WARNING,
"Storage target " + StringTk::intToStr(iter->first)
+ " missing in targetStates. Consistency state is lost.");
LogContext(logContext).log(Log_WARNING, "Adding default state for storage target "
+ StringTk::intToStr(iter->first) + ": "
+ states->stateToStr(defaultState));
IGNORE_UNUSED_VARIABLE(logContext);
states->addIfNotExists(iter->first, defaultState);
}
}
}
mappingsDirty = true;
......
......@@ -602,8 +602,20 @@ void App::initStorage(const bool firstRun) throw(InvalidConfigException, Compone
StringTk::intToStr(targetNumIDMapper->getSize() ) );
// load target mappings
// Set path for legacy resync set file
Path targetsToResyncPath(CONFIG_STORAGETARGETSTORESYNC_FILENAME);
targetStateStore->setResyncSetStorePath(targetsToResyncPath.str() );
Path nodesToResyncPath(CONFIG_METANODESTORESYNC_FILENAME);
metaStateStore->setResyncSetStorePath(nodesToResyncPath.str() );
// Set path for state set file
targetStateStore->setTargetStateStorePath(CONFIG_STORAGETARGETSTATES_FILENAME);
metaStateStore->setTargetStateStorePath(CONFIG_METANODESTATES_FILENAME);
readTargetStates(firstRun, formatProperties, targetStateStore);
readTargetStates(firstRun, formatProperties, metaStateStore);
// load target mappings
Path targetsPath(CONFIG_TARGETMAPPINGS_FILENAME);
targetMapper->setStorePath(targetsPath.str() );
if(targetMapper->loadFromFile() )
......@@ -637,19 +649,6 @@ void App::initStorage(const bool firstRun) throw(InvalidConfigException, Compone
this->log->log(Log_NOTICE, "Loaded metadata node mirror buddy group mappings: " +
StringTk::intToStr(metaBuddyGroupMapper->getSize() ) );
// Set path for legacy resync set file
Path targetsToResyncPath(CONFIG_STORAGETARGETSTORESYNC_FILENAME);
targetStateStore->setResyncSetStorePath(targetsToResyncPath.str() );
Path nodesToResyncPath(CONFIG_METANODESTORESYNC_FILENAME);
metaStateStore->setResyncSetStorePath(nodesToResyncPath.str() );
// Set path for state set file
targetStateStore->setTargetStateStorePath(CONFIG_STORAGETARGETSTATES_FILENAME);
metaStateStore->setTargetStateStorePath(CONFIG_METANODESTATES_FILENAME);
readTargetStates(firstRun, formatProperties, targetStateStore);
readTargetStates(firstRun, formatProperties, metaStateStore);
// save config, just to be sure that the format is correct and up to date
formatProperties.erase("longNodeIDs");
StorageTkEx::updateStorageFormatFile(mgmtdPathStr, STORAGETK_FORMAT_MIN_VERSION,
......
# The mgmtd should recover from an erroneous empty map in the targetStates file.
on node do
shutdown_daemon_soft(node, "mgmtd")
# Four zero bytes are what the serializer produces for an empty std::map.
# (32-bit length + entries)
shell "echo -en '\\x00\\x00\\x00\\x00'"\
"> #{node.properties["mgmtd"]["config"]["storeMgmtdDirectory"]}/targetStates"
startup_daemon(node, "mgmtd", node.properties["mgmtd"]["config"])
# The mgmtd should recognize the missing state on loading and warn the user.
wait_daemon_log(node, "mgmtd",
"Storage target [0-9]+ missing in targetStates. Consistency state is lost", 30)
restart_daemon_soft(node, "storage", "store0")
# Should appear almost instantaneously, but give it 30 seconds before failing.
wait_daemon_log(node, "store0", "Registration and management info download complete.", 30)
result = shell? "echo -en '\\x00\\x00\\x00\\x00'"\
"| cmp - "\
"#{node.properties["mgmtd"]["config"]["storeMgmtdDirectory"]}/targetStates"
raise "The targetStates is still an empty map (serialized to 0x00000000)." if result
end
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