Skip to content

Commit 5a56d20

Browse files
esindrilccaffy
authored andcommitted
MGM: Properly display and enforce the enable flag for the recycle bin
1 parent 12aebcb commit 5a56d20

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

mgm/proc/user/RecycleCmd.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ RecycleCmd::ProcessRequest() noexcept
151151
retc = Recycle::Config(std_out, std_err, mVid, config.op(), config.value());
152152
} else if (config.op() == eos::console::RecycleProto_ConfigProto::ENFORCE) {
153153
retc = Recycle::Config(std_out, std_err, mVid, config.op(), config.value());
154+
} else if (config.op() == eos::console::RecycleProto_ConfigProto::ENABLE) {
155+
retc = Recycle::Config(std_out, std_err, mVid, config.op(), config.value());
154156
} else if (config.op() == eos::console::RecycleProto_ConfigProto::DUMP) {
155157
retc = 0;
156158
std_out = gOFS->mRecycler->Dump();

mgm/recycle/Recycle.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,21 @@ Recycle::Config(std::string& std_out, std::string& std_err,
13111311
if (!gOFS->mRecycler->mPolicy.Config(RecyclePolicy::sEnforceKey, value,
13121312
std_err)) {
13131313
return EINVAL;
1314+
} else {
1315+
if (value == "on") {
1316+
std_out += "success: recycle bin enforced";
1317+
} else {
1318+
std_out += "success: recycle bin not enforced";
1319+
}
1320+
}
1321+
} else if (op == eos::console::RecycleProto_ConfigProto::ENABLE) {
1322+
if (value.empty() || ((value != "on") && (value != "off"))) {
1323+
std_err = "error: missing/wrong ennable value\n";
1324+
return EINVAL;
1325+
}
1326+
1327+
if (!gOFS->mRecycler->mPolicy.Config(RecyclePolicy::sEnableKey, value, std_err)) {
1328+
return EINVAL;
13141329
} else {
13151330
if (value == "on") {
13161331
std_out += "success: recycle bin enabled";

mgm/recycle/RecyclePolicy.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ void RecyclePolicy::ApplyConfig(eos::mgm::FsView* fsview)
7272
bool RecyclePolicy::StoreConfig()
7373
{
7474
std::ostringstream oss;
75-
oss << sEnforceKey << "=" << (mEnforced.load() ? "on" : "off")
76-
<< sEnforceKey << "=" << (mEnforced.load() ? "on" : "off")
77-
<< sKeepTimeKey << "=" << mKeepTimeSec.load() << " "
78-
<< sRatioKey << "=" << mSpaceKeepRatio.load() << " "
79-
<< sCollectKey << "=" << mCollectInterval.load().count() << " "
80-
<< sRemoveKey << "=" << mRemoveInterval.load().count() << " "
75+
oss << sEnforceKey << "=" << (mEnforced.load() ? "on" : "off") << " " //
76+
<< sEnableKey << "=" << (mEnabled.load() ? "on" : "off") << " " //
77+
<< sKeepTimeKey << "=" << mKeepTimeSec.load() << " " //
78+
<< sRatioKey << "=" << mSpaceKeepRatio.load() << " " //
79+
<< sCollectKey << "=" << mCollectInterval.load().count() << " " //
80+
<< sRemoveKey << "=" << mRemoveInterval.load().count() << " " //
8181
<< sDryRunKey << "=" << (mDryRun.load() ? "yes" : "no");
8282
return FsView::gFsView.SetGlobalConfig("recycle", oss.str());
8383
}
@@ -157,6 +157,7 @@ RecyclePolicy::Dump(const std::string& delim) const
157157
{
158158
std::ostringstream oss;
159159
oss << "enforced=" << (mEnforced.load() ? "on" : "off") << delim
160+
<< "enabled=" << (mEnabled.load() ? "on" : "off") << delim
160161
<< "dry_run=" << (mDryRun.load() ? "yes" : "no") << delim
161162
<< "keep_time_sec=" << mKeepTimeSec.load() << delim
162163
<< "space_keep_ratio=" << mSpaceKeepRatio.load() << delim

0 commit comments

Comments
 (0)