Blame SOURCES/0005-automember-rebuild-add-a-notice-about-high-CPU-usage_rhbz#2018198.patch

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