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