mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
This fix ensures that in case of a project quota, the corresponding project gets initialized, if required. Signed-off-by: Christoph Fiehe <c.fiehe@eurodata.de> Co-authored-by: Christoph Fiehe <c.fiehe@eurodata.de>
This commit is contained in:
parent
be1a905f6f
commit
9c11230824
3 changed files with 59 additions and 37 deletions
3
changelogs/fragments/5143-fix-xfs-quota-project-init.yml
Normal file
3
changelogs/fragments/5143-fix-xfs-quota-project-init.yml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- xfs_quota - in case of a project quota, the call to ``xfs_quota`` did not initialize/reset the project (https://github.com/ansible-collections/community.general/issues/5143).
|
|
@ -300,31 +300,35 @@ def main():
|
||||||
prj_set = False
|
prj_set = False
|
||||||
break
|
break
|
||||||
|
|
||||||
if not prj_set and not module.check_mode:
|
if state == "present" and not prj_set:
|
||||||
cmd = "project -s"
|
if not module.check_mode:
|
||||||
rc, stdout, stderr = exec_quota(module, xfs_quota_bin, cmd, mountpoint)
|
cmd = "project -s %s" % name
|
||||||
if rc != 0:
|
rc, stdout, stderr = exec_quota(module, xfs_quota_bin, cmd, mountpoint)
|
||||||
result["cmd"] = cmd
|
if rc != 0:
|
||||||
result["rc"] = rc
|
result["cmd"] = cmd
|
||||||
result["stdout"] = stdout
|
result["rc"] = rc
|
||||||
result["stderr"] = stderr
|
result["stdout"] = stdout
|
||||||
module.fail_json(
|
result["stderr"] = stderr
|
||||||
msg="Could not get quota realtime block report.", **result
|
module.fail_json(
|
||||||
)
|
msg="Could not get quota realtime block report.", **result
|
||||||
|
)
|
||||||
|
|
||||||
result["changed"] = True
|
result["changed"] = True
|
||||||
|
|
||||||
elif not prj_set and module.check_mode:
|
elif state == "absent" and prj_set and name != quota_default:
|
||||||
result["changed"] = True
|
if not module.check_mode:
|
||||||
|
cmd = "project -C %s" % name
|
||||||
|
rc, stdout, stderr = exec_quota(module, xfs_quota_bin, cmd, mountpoint)
|
||||||
|
if rc != 0:
|
||||||
|
result["cmd"] = cmd
|
||||||
|
result["rc"] = rc
|
||||||
|
result["stdout"] = stdout
|
||||||
|
result["stderr"] = stderr
|
||||||
|
module.fail_json(
|
||||||
|
msg="Failed to clear managed tree from project quota control.", **result
|
||||||
|
)
|
||||||
|
|
||||||
# Set limits
|
result["changed"] = True
|
||||||
if state == "absent":
|
|
||||||
bhard = 0
|
|
||||||
bsoft = 0
|
|
||||||
ihard = 0
|
|
||||||
isoft = 0
|
|
||||||
rtbhard = 0
|
|
||||||
rtbsoft = 0
|
|
||||||
|
|
||||||
current_bsoft, current_bhard = quota_report(
|
current_bsoft, current_bhard = quota_report(
|
||||||
module, xfs_quota_bin, mountpoint, name, quota_type, "b"
|
module, xfs_quota_bin, mountpoint, name, quota_type, "b"
|
||||||
|
@ -336,6 +340,23 @@ def main():
|
||||||
module, xfs_quota_bin, mountpoint, name, quota_type, "rtb"
|
module, xfs_quota_bin, mountpoint, name, quota_type, "rtb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Set limits
|
||||||
|
if state == "absent":
|
||||||
|
bhard = 0
|
||||||
|
bsoft = 0
|
||||||
|
ihard = 0
|
||||||
|
isoft = 0
|
||||||
|
rtbhard = 0
|
||||||
|
rtbsoft = 0
|
||||||
|
|
||||||
|
# Ensure that a non-existing quota does not trigger a change
|
||||||
|
current_bsoft = current_bsoft if current_bsoft is not None else 0
|
||||||
|
current_bhard = current_bhard if current_bhard is not None else 0
|
||||||
|
current_isoft = current_isoft if current_isoft is not None else 0
|
||||||
|
current_ihard = current_ihard if current_ihard is not None else 0
|
||||||
|
current_rtbsoft = current_rtbsoft if current_rtbsoft is not None else 0
|
||||||
|
current_rtbhard = current_rtbhard if current_rtbhard is not None else 0
|
||||||
|
|
||||||
result["xfs_quota"] = dict(
|
result["xfs_quota"] = dict(
|
||||||
bsoft=current_bsoft,
|
bsoft=current_bsoft,
|
||||||
bhard=current_bhard,
|
bhard=current_bhard,
|
||||||
|
@ -370,25 +391,23 @@ def main():
|
||||||
limit.append("rtbhard=%s" % rtbhard)
|
limit.append("rtbhard=%s" % rtbhard)
|
||||||
result["rtbhard"] = int(rtbhard)
|
result["rtbhard"] = int(rtbhard)
|
||||||
|
|
||||||
if len(limit) > 0 and not module.check_mode:
|
if len(limit) > 0:
|
||||||
if name == quota_default:
|
if not module.check_mode:
|
||||||
cmd = "limit %s -d %s" % (type_arg, " ".join(limit))
|
if name == quota_default:
|
||||||
else:
|
cmd = "limit %s -d %s" % (type_arg, " ".join(limit))
|
||||||
cmd = "limit %s %s %s" % (type_arg, " ".join(limit), name)
|
else:
|
||||||
|
cmd = "limit %s %s %s" % (type_arg, " ".join(limit), name)
|
||||||
|
|
||||||
rc, stdout, stderr = exec_quota(module, xfs_quota_bin, cmd, mountpoint)
|
rc, stdout, stderr = exec_quota(module, xfs_quota_bin, cmd, mountpoint)
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
result["cmd"] = cmd
|
result["cmd"] = cmd
|
||||||
result["rc"] = rc
|
result["rc"] = rc
|
||||||
result["stdout"] = stdout
|
result["stdout"] = stdout
|
||||||
result["stderr"] = stderr
|
result["stderr"] = stderr
|
||||||
module.fail_json(msg="Could not set limits.", **result)
|
module.fail_json(msg="Could not set limits.", **result)
|
||||||
|
|
||||||
result["changed"] = True
|
result["changed"] = True
|
||||||
|
|
||||||
elif len(limit) > 0 and module.check_mode:
|
|
||||||
result["changed"] = True
|
|
||||||
|
|
||||||
module.exit_json(**result)
|
module.exit_json(**result)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@
|
||||||
- name: Assert project limits results for xft_quotaval after re-apply
|
- name: Assert project limits results for xft_quotaval after re-apply
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- test_pquota_project_after.changed
|
- test_pquota_project_after is not changed
|
||||||
- name: Reset default project limits
|
- name: Reset default project limits
|
||||||
xfs_quota:
|
xfs_quota:
|
||||||
mountpoint: '{{ remote_tmp_dir }}/pquota'
|
mountpoint: '{{ remote_tmp_dir }}/pquota'
|
||||||
|
|
Loading…
Reference in a new issue