File plugin_script-Execute-all-scripts-regardless-of-errors.patch of Package tuned.35791

From: Ondřej Lysoněk <olysonek@redhat.com>
Subject: plugin_script: Execute all scripts regardless of errors
References: 
Patch-Mainline: v2.13.0-rc.1
Git-commit: 66924b842228e7178301aa399d30459155b35762
Git-repo: https://github.com/redhat-performance/tuned.git

Due to commit d4038a7e64af3, if a script fails to execute or its exit
code is non-zero, no subsequent scripts are executed. This seems
logically wrong and it causes problems especially during rollback as some
tunings may not be reverted due to this behaviour. Also, it appears it
was not the intention of that commit to change this behaviour - the
intention rather seems to have been to make _call_scripts return
success/error information for use by the verification mechanism.

So let's aggregate the success/error information instead.

Related: https://github.com/redhat-performance/tuned/pull/194

Signed-off-by: Ondřej Lysoněk <olysonek@redhat.com>


Signed-off-by:  <trenn@suse.com>
diff --git a/tuned/plugins/plugin_script.py b/tuned/plugins/plugin_script.py
index 940c1f9..19b7fc6 100644
--- a/tuned/plugins/plugin_script.py
+++ b/tuned/plugins/plugin_script.py
@@ -31,6 +31,7 @@ class ScriptPlugin(base.Plugin):
 		pass
 
 	def _call_scripts(self, scripts, arguments):
+		ret = True
 		for script in scripts:
 			environ = os.environ
 			environ.update(self._variables.get_env())
@@ -47,11 +48,11 @@ class ScriptPlugin(base.Plugin):
 					log.error("script '%s' error output: '%s'" % (script, err[:-1]))
 				if proc.returncode:
 					log.error("script '%s' returned error code: %d" % (script, proc.returncode))
-					return False
+					ret = False
 			except (OSError,IOError) as e:
 				log.error("script '%s' error: %s" % (script, e))
-				return False
-		return True
+				ret = False
+		return ret
 
 	def _instance_apply_static(self, instance):
 		super(ScriptPlugin, self)._instance_apply_static(instance)
openSUSE Build Service is sponsored by