04124f
From c044822affcf1fb21e4f4d26b18f73f152ea2a6d Mon Sep 17 00:00:00 2001
04124f
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
04124f
Date: Tue, 26 Nov 2019 15:49:39 +0100
04124f
Subject: [PATCH 1/3] Fix Traceback on reload when the preset profile does not
04124f
 exist
04124f
MIME-Version: 1.0
04124f
Content-Type: text/plain; charset=UTF-8
04124f
Content-Transfer-Encoding: 8bit
04124f
04124f
The reload_profile_config() method can pass through a TunedException
04124f
when the requested profile does not exist, or is invalid. We need to
04124f
catch it and log the error.
04124f
04124f
Resolves: rhbz#1774645
04124f
Resolves: rhbz#1702724
04124f
04124f
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
04124f
---
04124f
 tuned/daemon/controller.py | 6 +++++-
04124f
 1 file changed, 5 insertions(+), 1 deletion(-)
04124f
04124f
diff --git a/tuned/daemon/controller.py b/tuned/daemon/controller.py
04124f
index 5e1e9ba2..48c30ea6 100644
04124f
--- a/tuned/daemon/controller.py
04124f
+++ b/tuned/daemon/controller.py
04124f
@@ -138,7 +138,11 @@ def reload(self, caller = None):
04124f
 			stop_ok = self.stop()
04124f
 			if not stop_ok:
04124f
 				return False
04124f
-			self._daemon.reload_profile_config()
04124f
+			try:
04124f
+				self._daemon.reload_profile_config()
04124f
+			except TunedException as e:
04124f
+				log.error("Failed to reload Tuned: %s" % e)
04124f
+				return False
04124f
 			return self.start()
04124f
 
04124f
 	def _switch_profile(self, profile_name, manual):
04124f
04124f
From 5d8ef2c0095e999107574ebfb86e735bc048756e Mon Sep 17 00:00:00 2001
04124f
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
04124f
Date: Tue, 26 Nov 2019 16:53:04 +0100
04124f
Subject: [PATCH 2/3] Set manual profile mode on tuned-adm off
04124f
MIME-Version: 1.0
04124f
Content-Type: text/plain; charset=UTF-8
04124f
Content-Transfer-Encoding: 8bit
04124f
04124f
To fix rhbz#1774645 and rhbz#1702724, we need to make the
04124f
`Controller.reload` operation behave the same as a Tuned restart even
04124f
in the case when Tuned is running but no profile is applied. If we did
04124f
that, while setting automatic profile mode on `tuned-adm off` (as it
04124f
is currently done), we would end up with a behaviour where `tuned-adm
04124f
off` followed by controller reload would result in the recommended
04124f
profile being applied.
04124f
04124f
We agreed with Jaroslav that this behaviour wouldn't make sense, so we
04124f
instead decided to change the behaviour of `tuned-adm off` followed by
04124f
Tuned *restart*. Previously, it would result in the recommended
04124f
profile being applied (which doesn't make much sense to us either). So
04124f
we decided to change `tuned-adm off`, so that even after restart,
04124f
Tuned runs with no profile applied, i.e. making `tuned-adm off` set
04124f
manual profile mode.
04124f
04124f
Related: rhbz#1774645
04124f
Related: rhbz#1702724
04124f
04124f
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
04124f
---
04124f
 tuned/daemon/controller.py | 2 +-
04124f
 1 file changed, 1 insertion(+), 1 deletion(-)
04124f
04124f
diff --git a/tuned/daemon/controller.py b/tuned/daemon/controller.py
04124f
index 48c30ea6..5bd4d31a 100644
04124f
--- a/tuned/daemon/controller.py
04124f
+++ b/tuned/daemon/controller.py
04124f
@@ -219,7 +219,7 @@ def disable(self, caller = None):
04124f
 		if self._daemon.is_running():
04124f
 			self._daemon.stop()
04124f
 		if self._daemon.is_enabled():
04124f
-			self._daemon.set_profile(None, None, save_instantly=True)
04124f
+			self._daemon.set_profile(None, True, save_instantly=True)
04124f
 		return True
04124f
 
04124f
 	@exports.export("", "b")
04124f
04124f
From d545b13dc1e7568af42a59e9721033813eccb61a Mon Sep 17 00:00:00 2001
04124f
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
04124f
Date: Wed, 27 Nov 2019 10:53:03 +0100
04124f
Subject: [PATCH 3/3] controller: Proceed with reload even if daemon is not
04124f
 running
04124f
MIME-Version: 1.0
04124f
Content-Type: text/plain; charset=UTF-8
04124f
Content-Transfer-Encoding: 8bit
04124f
04124f
To fix rhbz#1774645 and rhbz#1702724, we need to make the
04124f
`Controller.reload` operation behave the same as a Tuned restart even
04124f
in the case when Tuned is running but no profile is applied. To
04124f
achieve that, we must not `return False` from `reload()` when Daemon
04124f
is not running.
04124f
04124f
I'm not aware of any specific purpose the `return False` could serve,
04124f
other than perhaps making sure that running reload after `tuned-adm
04124f
off` does not result in the recommended profile being applied. This
04124f
case is handled in commit 5d8ef2c0095e9, so I think it should be safe
04124f
now to drop the `return`.
04124f
04124f
Resolves: rhbz#1774645
04124f
Resolves: rhbz#1702724
04124f
04124f
Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>
04124f
---
04124f
 tuned/daemon/controller.py | 16 +++++++---------
04124f
 1 file changed, 7 insertions(+), 9 deletions(-)
04124f
04124f
diff --git a/tuned/daemon/controller.py b/tuned/daemon/controller.py
04124f
index 5bd4d31a..18e0bb61 100644
04124f
--- a/tuned/daemon/controller.py
04124f
+++ b/tuned/daemon/controller.py
04124f
@@ -132,18 +132,16 @@ def stop(self, caller = None):
04124f
 	def reload(self, caller = None):
04124f
 		if caller == "":
04124f
 			return False
04124f
-		if not self._daemon.is_running():
04124f
-			return False
04124f
-		else:
04124f
+		if self._daemon.is_running():
04124f
 			stop_ok = self.stop()
04124f
 			if not stop_ok:
04124f
 				return False
04124f
-			try:
04124f
-				self._daemon.reload_profile_config()
04124f
-			except TunedException as e:
04124f
-				log.error("Failed to reload Tuned: %s" % e)
04124f
-				return False
04124f
-			return self.start()
04124f
+		try:
04124f
+			self._daemon.reload_profile_config()
04124f
+		except TunedException as e:
04124f
+			log.error("Failed to reload Tuned: %s" % e)
04124f
+			return False
04124f
+		return self.start()
04124f
 
04124f
 	def _switch_profile(self, profile_name, manual):
04124f
 		was_running = self._daemon.is_running()