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