[PATCH 0/2] Issue 557 - Package Update Improvements - Part I

This patch avoid any package update interruption that could be caused by kimchid service. This is important because if kimchid is stopped or restarted during a package update process, the system can become unstable. A part II is being implemented to let kimchi knows whether a package update is happening when kimchid is (re)started. Jose Ricardo Ziviani (2): Make the package update process indendent of Kimchi Set systemd KillMode to process contrib/wokd.service.fedora | 1 + plugins/kimchi/swupdate.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) -- 1.9.1

- This commit forces the package manager to run out of kimchi job group, it will also ignore a sigterm signal in order to let the package manager running until it finishes by itself. Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> --- plugins/kimchi/swupdate.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/kimchi/swupdate.py b/plugins/kimchi/swupdate.py index 84b927f..459b7a2 100644 --- a/plugins/kimchi/swupdate.py +++ b/plugins/kimchi/swupdate.py @@ -17,6 +17,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +import signal +import os import subprocess import time @@ -110,6 +112,14 @@ class SoftwareUpdate(object): self._scanUpdates() return self._num2update + def preUpdate(self): + """ + Make adjustments before executing the command in + a child process. + """ + os.setsid() + signal.signal(signal.SIGTERM, signal.SIG_IGN) + def doUpdate(self, cb, params): """ Execute the update @@ -119,7 +129,8 @@ class SoftwareUpdate(object): cmd = self._pkg_mnger.update_cmd proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + preexec_fn=self.preUpdate) msgs = [] while proc.poll() is None: msgs.append(proc.stdout.readline()) -- 1.9.1

On 09/29/2015 09:39 AM, Jose Ricardo Ziviani wrote:
- This commit forces the package manager to run out of kimchi job group, it will also ignore a sigterm signal in order to let the package manager running until it finishes by itself.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> --- plugins/kimchi/swupdate.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/plugins/kimchi/swupdate.py b/plugins/kimchi/swupdate.py index 84b927f..459b7a2 100644 --- a/plugins/kimchi/swupdate.py +++ b/plugins/kimchi/swupdate.py @@ -17,6 +17,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import signal +import os OS before SIGNAL
import subprocess import time
@@ -110,6 +112,14 @@ class SoftwareUpdate(object): self._scanUpdates() return self._num2update
+ def preUpdate(self): + """ + Make adjustments before executing the command in + a child process. + """ + os.setsid() + signal.signal(signal.SIGTERM, signal.SIG_IGN) + def doUpdate(self, cb, params): """ Execute the update @@ -119,7 +129,8 @@ class SoftwareUpdate(object):
cmd = self._pkg_mnger.update_cmd proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + preexec_fn=self.preUpdate) msgs = [] while proc.poll() is None: msgs.append(proc.stdout.readline())

On 29/09/2015 20:15, Rodrigo Trujillo wrote:
On 09/29/2015 09:39 AM, Jose Ricardo Ziviani wrote:
- This commit forces the package manager to run out of kimchi job group, it will also ignore a sigterm signal in order to let the package manager running until it finishes by itself.
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> --- plugins/kimchi/swupdate.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/plugins/kimchi/swupdate.py b/plugins/kimchi/swupdate.py index 84b927f..459b7a2 100644 --- a/plugins/kimchi/swupdate.py +++ b/plugins/kimchi/swupdate.py @@ -17,6 +17,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import signal +import os OS before SIGNAL
Thanks, Rodrigo! I will change it before merging.
import subprocess import time
@@ -110,6 +112,14 @@ class SoftwareUpdate(object): self._scanUpdates() return self._num2update
+ def preUpdate(self): + """ + Make adjustments before executing the command in + a child process. + """ + os.setsid() + signal.signal(signal.SIGTERM, signal.SIG_IGN) + def doUpdate(self, cb, params): """ Execute the update @@ -119,7 +129,8 @@ class SoftwareUpdate(object):
cmd = self._pkg_mnger.update_cmd proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stderr=subprocess.PIPE, + preexec_fn=self.preUpdate) msgs = [] while proc.poll() is None: msgs.append(proc.stdout.readline())
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

- This commit sets systemd's KillMode to process in order to make sure it won't kill Kimchi's daemon subprocess if Kimchi is stopped. Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com> --- contrib/wokd.service.fedora | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/wokd.service.fedora b/contrib/wokd.service.fedora index 17414d3..023b1af 100644 --- a/contrib/wokd.service.fedora +++ b/contrib/wokd.service.fedora @@ -8,6 +8,7 @@ Type=simple ExecStart=/usr/bin/wokd ExecStop=/bin/kill -TERM $MAINPID EnvironmentFile=/etc/wok/wok.conf +KillMode=process [Install] WantedBy=multi-user.target -- 1.9.1
participants (3)
-
Aline Manera
-
Jose Ricardo Ziviani
-
Rodrigo Trujillo