Commit a9b44fdc authored by Phoebe Buckheister's avatar Phoebe Buckheister 🦎

ctl: improve error message for meta buddy group add failures

meta buddy groups that contain the root inode must be created such that
owner of the non-mirrored root inode becomes the primary of the newly
created group. adding a group that does not satisfy this condition
should give the user some info about why the process failed, not just
*that* it failed and an error message no user can be expected to

see #941
parent ed2067bb
......@@ -229,7 +229,14 @@ int ModeAddMirrorBuddyGroup::execute()
auto addRes = addGroup(cfgPrimaryTargetID, cfgSecondaryTargetID, cfgGroupID);
if (addRes != FhgfsOpsErr_SUCCESS)
if (addRes == FhgfsOpsErr_NOTOWNER && nodeType == NODETYPE_Meta)
std::cerr << "Could not add buddy group: new group would own the root inode, but the root\n"
"inode is owned by the secondary of the new group. Only the primary of a\n"
"new group may own the root inode; try switching primary and secondary.\n";
else if (addRes != FhgfsOpsErr_SUCCESS)
std::cerr << "Could not add buddy group: " << FhgfsOpsErrTk::toErrString(addRes) << "\n";
on main do
root_owner = (shell "#{$binaries[:ctl]} --getentryinfo --unmounted / \
| grep -P --only-matching '(?<=\\[ID: )\\d+'")[:stdout].strip
buddy = root_owner == "1" ? "2" : "1"
res = {}
shell? "sudo #{$binaries[:ctl]} --addmirrorgroup --nodetype=meta \
--primary=#{buddy} --secondary=#{root_owner}", status: res
raise if res[:return] == 0
raise if res[:stderr].index('try switching').nil?
shell "sudo #{$binaries[:ctl]} --addmirrorgroup --nodetype=meta \
--secondary=#{buddy} --primary=#{root_owner}"
- mgmtd
- meta
- meta
- storage
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