Commit ead1f659 authored by Elvin Sindrilaru's avatar Elvin Sindrilaru

MGM: Use config option mgmofs.centraldrain to mark the use of central draining

This avoids some issues with file system updates during boot-up and also greatly simplifies the code.
parent d70599c4
Pipeline #467576 passed with stages
in 37 minutes 40 seconds
......@@ -94,11 +94,27 @@ bool
FileSystem::SetConfigStatus(eos::common::FileSystem::fsstatus_t new_status)
{
using eos::mgm::FsView;
FsView::DrainType dt =
FsView::gFsView.GetDrainType(this, gOFS->MasterPtr->IsActivated());
eos::common::FileSystem::fsstatus_t old_status = GetConfigStatus();
if (dt == FsView::DrainType::Distributed) {
if (gOFS->mIsCentralDrain) {
eos_static_info("fsid=%d, centralized drain type", GetId());
int drain_tx = IsDrainTransition(old_status, new_status);
if (drain_tx) {
std::string out_msg;
if (drain_tx > 0) {
if (!gOFS->mDrainEngine.StartFsDrain(this, 0, out_msg)) {
eos_static_err("%s", out_msg.c_str());
return false;
}
} else if (drain_tx < 0) {
if (!gOFS->mDrainEngine.StopFsDrain(this, out_msg)) {
eos_static_err("%s", out_msg.c_str());
}
}
}
} else {
eos_static_info("fsid=%d, distributed drain type", GetId());
if ((old_status == kDrainDead) || (old_status == kDrain)) {
......@@ -135,26 +151,6 @@ FileSystem::SetConfigStatus(eos::common::FileSystem::fsstatus_t new_status)
SetDrainStatus(eos::common::FileSystem::kNoDrain);
}
}
} else if (dt == FsView::DrainType::Central) {
eos_static_info("fsid=%d, centralized drain type", GetId());
int drain_tx = IsDrainTransition(old_status, new_status);
if (drain_tx) {
std::string out_msg;
if (drain_tx > 0) {
if (!gOFS->mDrainEngine.StartFsDrain(this, 0, out_msg)) {
eos_static_err("%s", out_msg.c_str());
return false;
}
} else if (drain_tx < 0) {
if (!gOFS->mDrainEngine.StopFsDrain(this, out_msg)) {
eos_static_err("%s", out_msg.c_str());
}
}
}
} else {
eos_static_info("fsid=%d, unknown drain type", GetId());
}
std::string val = eos::common::FileSystem::GetConfigStatusAsString(new_status);
......
......@@ -2318,41 +2318,6 @@ FsView::HeartBeatCheck()
return 0;
}
//------------------------------------------------------------------------------
// Check if centralized draining is to be used for the given file system
//------------------------------------------------------------------------------
FsView::DrainType
FsView::GetDrainType(FileSystem* fs, bool activated)
{
if (activated) {
eos::common::FileSystem::fs_snapshot_t snapshot;
if (fs->SnapShotFileSystem(snapshot)) {
auto it = mSpaceView.find(snapshot.mSpace);
if (it == mSpaceView.end()) {
eos_crit("fsid=%lu attached to unknown space=%s", snapshot.mId,
snapshot.mSpace.c_str());
return DrainType::Unknown;
}
FsSpace* space = it->second;
// Check if space has centralized draining enabled
if (space->GetConfigMember("drainer.central") == "on") {
return DrainType::Central;
}
return DrainType::Distributed;
} else {
eos_err("failed to take file system snapshot");
return DrainType::Unknown;
}
} else {
return DrainType::Unknown;
}
}
//------------------------------------------------------------------------------
// Return a view member variable
//------------------------------------------------------------------------------
......@@ -4138,23 +4103,4 @@ FsSpace::ResetDraining()
}
}
//------------------------------------------------------------------------------
// @note This method and its associated functionality should be dropped one
// we remove the distributed draining
//
// Reapply the status of the file system to trigger eventually the draining
//------------------------------------------------------------------------------
void
FsView::ReapplyConfigStatus()
{
eos_info("reapplying config status");
eos::common::RWMutexReadLock view_rd_lock(ViewMutex);
for (auto it = mIdView.cbegin(); it != mIdView.cend(); ++it) {
auto fs = it->second;
auto cfg_status = fs->GetConfigStatus();
fs->SetConfigStatus(cfg_status);
}
}
EOSMGMNAMESPACE_END
......@@ -1107,24 +1107,6 @@ public:
//----------------------------------------------------------------------------
void SetNextFsId(eos::common::FileSystem::fsid_t fsid);
//----------------------------------------------------------------------------
//! Get type of draining for given file system
//!
//! @param fs file system object
//! @param activated true if all config loaded, otherwise false
//!
//! @return DrainType value
//----------------------------------------------------------------------------
DrainType GetDrainType(FileSystem* fs, bool activated);
//----------------------------------------------------------------------------
//! @note This method and its associated functionality should be dropped one
//! we remove the distributed draining
//!
//! Reapply the status of the file system to trigger eventually the draining
//----------------------------------------------------------------------------
void ReapplyConfigStatus();
private:
pthread_t hbthread; ///< Thread ID of the heartbeat thread
bool mIsHeartbeatOn; ///< True if heartbeat thread is running
......
......@@ -1132,15 +1132,6 @@ Master::Activate(XrdOucString& stdOut, XrdOucString& stdErr, int transitiontype)
}
fActivated.store(true);
// Reapply the fs configstatus to start eventually the draining given the
// space config
if (transitiontype == Transition::Type::kMasterToMaster) {
FsView::gFsView.ReapplyConfigStatus();
// @todo (esindril): note that the FsConfigListerner can then disable
// the draining in the beginning and we should properly accound for this
}
return true;
}
......
......@@ -172,7 +172,7 @@ XrdMgmOfs::XrdMgmOfs(XrdSysError* ep):
mCommentLog(nullptr),
FsckPtr(new eos::mgm::Fsck()), FsCheck(*FsckPtr),
MasterPtr(new eos::mgm::Master()), MgmMaster(*MasterPtr),
mRouting(new eos::mgm::PathRouting()),
mRouting(new eos::mgm::PathRouting()), mIsCentralDrain(false),
LRUPtr(new eos::mgm::LRU()), LRUd(*LRUPtr),
WFEPtr(new eos::mgm::WFE()), WFEd(*WFEPtr),
UTF8(false), mFstGwHost(""), mFstGwPort(0), mQdbCluster(""), mHttpdPort(8000),
......
......@@ -1549,6 +1549,7 @@ public:
//! Shared Hash/Queue Object Change Notifier
XrdMqSharedObjectChangeNotifier ObjectNotifier;
Drainer mDrainEngine; ///< Centralized draning
bool mIsCentralDrain; ///< Flag to mark central draining
std::unique_ptr<HttpServer> Httpd; ///< Http daemon if available
//! LRU object running the LRU policy engine
......
......@@ -343,7 +343,7 @@ XrdMgmOfs::FsConfigListener()
if (FsView::gFsView.mIdView.count(fsid)) {
FileSystem* fs = FsView::gFsView.mIdView[fsid];
fs->SetConfigStatus(eos::common::FileSystem::kRW);
fs->StopDrainJob();
}
}
}
......
......@@ -46,20 +46,11 @@
eos::common::FileSystem::fsid_t >> sZeroMove;
static time_t sScheduledFidCleanupTime = 0;
// If distributed drain not enabled this doesn't return anything
if (gOFS->mIsCentralDrain)
{
// If distributed drain not enabled this doesn't return anything
eos::common::FileSystem::fsid_t fsid = atoi(sfsid.c_str());
eos::common::RWMutexReadLock fs_rd_lock(FsView::gFsView.ViewMutex);
auto fs = FsView::gFsView.mIdView[fsid];
if (fs)
{
if (FsView::gFsView.GetDrainType(fs, gOFS->MasterPtr->IsActivated()) !=
FsView::DrainType::Distributed) {
error.setErrInfo(0, "");
return SFS_DATA;
}
}
error.setErrInfo(0, "");
return SFS_DATA;
}
// Deal with 0-size files 'scheduled' before, which just need a move in the
......
......@@ -751,6 +751,19 @@ XrdMgmOfs::Configure(XrdSysError& Eroute)
Eroute.Say("=====> mgmofs.authlib : ", mAuthLib.c_str());
}
if (!strcmp("centraldrain", var)) {
if ((!(val = Config.GetWord())) ||
(strcmp("true", val) && strcmp("false", val) &&
strcmp("1", val) && strcmp("0", val))) {
Eroute.Emsg("Config", "argument 2 for centraldrain illegal or missing. "
"Must be <true>, <false>, <1> or <0>!");
} else {
if ((!strcmp("true", val) || (!strcmp("1", val)))) {
mIsCentralDrain = true;
}
}
}
if (!strcmp("authorize", var)) {
if ((!(val = Config.GetWord())) ||
(strcmp("true", val) && strcmp("false", val) &&
......
......@@ -34,7 +34,6 @@ EOSMGMNAMESPACE_BEGIN
using namespace std::chrono;
constexpr std::chrono::seconds DrainFs::sUpdateTimeout;
constexpr std::chrono::seconds DrainFs::sRefreshTimeout;
constexpr std::chrono::seconds DrainFs::sStallTimeout;
......@@ -221,7 +220,7 @@ DrainFs::Stop()
if (fs) {
mStatus = eos::common::FileSystem::kNoDrain;
fs->OpenTransaction();
fs->SetConfigStatus(eos::common::FileSystem::kRW);
// fs->SetConfigStatus(eos::common::FileSystem::kRW);
fs->SetDrainStatus(eos::common::FileSystem::kNoDrain, false);
fs->CloseTransaction();
FsView::gFsView.StoreFsConfig(fs);
......@@ -381,17 +380,8 @@ DrainFs::UpdateProgress()
is_expired = true;
}
// Check if we should do an update, we update every sUpdateTimeout seconds
bool do_update = false;
auto last_upd = now - mLastUpdateTime;
if (duration_cast<seconds>(last_upd).count() > sUpdateTimeout.count()) {
mLastUpdateTime = now;
do_update = true;
}
// Update drain display variables
if ((is_stalled || is_expired || (mLastProgressTime == now)) && do_update) {
if (is_stalled || is_expired || (mLastProgressTime == now)) {
FileSystem* fs = nullptr;
eos::common::RWMutexReadLock fs_rd_lock(FsView::gFsView.ViewMutex);
......
......@@ -179,7 +179,6 @@ private:
//---------------------------------------------------------------------------
void Stop();
constexpr static std::chrono::seconds sUpdateTimeout {5};
constexpr static std::chrono::seconds sRefreshTimeout {60};
constexpr static std::chrono::seconds sStallTimeout {600};
eos::common::FileSystem::fsid_t mFsId; ///< Drain source fsid
......
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