bbecb6
From 2857bc69957bde7e59fff1c66c5a83c7f560616b Mon Sep 17 00:00:00 2001
bbecb6
From: Florence Blanc-Renaud <flo@redhat.com>
bbecb6
Date: Tue, 31 Jan 2023 15:53:08 +0100
bbecb6
Subject: [PATCH] automember-rebuild: add a notice about high CPU usage
bbecb6
bbecb6
The automember-rebuild task may require high CPU usage
bbecb6
if many users/hosts/groups are processed.
bbecb6
Add a note in the ipa automember-rebuild CLI output
bbecb6
and in the WebUI confirmation message.
bbecb6
bbecb6
Fixes: https://pagure.io/freeipa/issue/9320
bbecb6
Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
bbecb6
Reviewed-By: Francisco Trivino <ftrivino@redhat.com>
bbecb6
---
bbecb6
 install/ui/test/data/i18n_messages.json | 2 +-
bbecb6
 ipaclient/plugins/automember.py         | 8 ++++++++
bbecb6
 ipaserver/plugins/internal.py           | 6 +++++-
bbecb6
 3 files changed, 14 insertions(+), 2 deletions(-)
bbecb6
bbecb6
diff --git a/install/ui/test/data/i18n_messages.json b/install/ui/test/data/i18n_messages.json
bbecb6
index 49d288326d8cea192a16e93a274599805b0ea666..5b735487bf33805e8f0534d378d1497f05a11be8 100644
bbecb6
--- a/install/ui/test/data/i18n_messages.json
bbecb6
+++ b/install/ui/test/data/i18n_messages.json
bbecb6
@@ -7,7 +7,7 @@
bbecb6
             "actions": {
bbecb6
                 "apply": "Apply", 
bbecb6
                 "automember_rebuild": "Rebuild auto membership", 
bbecb6
-                "automember_rebuild_confirm": "Are you sure you want to rebuild auto membership?", 
bbecb6
+                "automember_rebuild_confirm": "Are you sure you want to rebuild auto membership? In case of a high number of users, hosts or groups, the operation may require high CPU usage.",
bbecb6
                 "automember_rebuild_success": "Automember rebuild membership task completed", 
bbecb6
                 "confirm": "Are you sure you want to proceed with the action?", 
bbecb6
                 "delete_confirm": "Are you sure you want to delete ${object}?", 
bbecb6
diff --git a/ipaclient/plugins/automember.py b/ipaclient/plugins/automember.py
bbecb6
index df4a2e5a01744e0ff22c74180e13c2e7dc33fbaa..7108dc948753b9f6a4439842bd75e7c5e064bda6 100644
bbecb6
--- a/ipaclient/plugins/automember.py
bbecb6
+++ b/ipaclient/plugins/automember.py
bbecb6
@@ -34,3 +34,11 @@ class automember_add_condition(MethodOverride):
bbecb6
             flags=['suppress_empty'],
bbecb6
         ),
bbecb6
     )
bbecb6
+
bbecb6
+
bbecb6
+@register(override=True, no_fail=True)
bbecb6
+class automember_rebuild(MethodOverride):
bbecb6
+    def interactive_prompt_callback(self, kw):
bbecb6
+        msg = _('IMPORTANT: In case of a high number of users, hosts or '
bbecb6
+                'groups, the operation may require high CPU usage.')
bbecb6
+        self.Backend.textui.print_plain(msg)
bbecb6
diff --git a/ipaserver/plugins/internal.py b/ipaserver/plugins/internal.py
bbecb6
index 5ffa7a281548a0658386f8740dbddd96fd0bc7d6..e1e920f8bb49dd8ba8f30b727111bb1316f6a918 100644
bbecb6
--- a/ipaserver/plugins/internal.py
bbecb6
+++ b/ipaserver/plugins/internal.py
bbecb6
@@ -160,7 +160,11 @@ class i18n_messages(Command):
bbecb6
         "actions": {
bbecb6
             "apply": _("Apply"),
bbecb6
             "automember_rebuild": _("Rebuild auto membership"),
bbecb6
-            "automember_rebuild_confirm": _("Are you sure you want to rebuild auto membership?"),
bbecb6
+            "automember_rebuild_confirm": _(
bbecb6
+                "Are you sure you want to rebuild auto membership? In case of "
bbecb6
+                "a high number of users, hosts or groups, the operation "
bbecb6
+                "may require high CPU usage."
bbecb6
+            ),
bbecb6
             "automember_rebuild_success": _("Automember rebuild membership task completed"),
bbecb6
             "confirm": _("Are you sure you want to proceed with the action?"),
bbecb6
             "delete_confirm": _("Are you sure you want to delete ${object}?"),
bbecb6
-- 
bbecb6
2.39.1
bbecb6