From 5e125dd63c18e434c684939147717a3a6440b471 Mon Sep 17 00:00:00 2001
From: yangjiaqi <yangjiaqi16@huawei.com>
Date: Thu, 28 Dec 2023 16:02:32 +0800
Subject: [PATCH 185/198] iSulad: restart isuald when upgrade active isulad

Signed-off-by: yangjiaqi <yangjiaqi16@huawei.com>
---
 iSulad.spec | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/iSulad.spec b/iSulad.spec
index d3799784..68590a2c 100644
--- a/iSulad.spec
+++ b/iSulad.spec
@@ -167,6 +167,16 @@ if [ -e %{_unitdir}/lcrd.service.rpmsave ]; then
     mv %{_unitdir}/lcrd.service.rpmsave %{_unitdir}/isulad.service
     sed -i 's/lcrd/isulad/g' %{_unitdir}/isulad.service
 fi
+# During the isulad upgrade process, the isulad service may still be running, but the service may be unavailable
+# due to configuration updates and other reasons.
+# it may fail if the X package is upgraded synchronously with isulad and depends on the isulad command,
+# For example syscontianer-tools and lxcfs-tools.
+# Therefore, after upgrading isulad, if the original status of isulad is running,
+# we need to restart isulad to ensure that the service is available during the upgrade process.
+systemctl status isulad | grep 'Active:' | grep 'running'
+if [ $? -eq 0 ]; then
+  systemctl restart isulad
+fi
 %else
 /sbin/service isulad status | grep 'Active:' | grep 'running'
 if [ $? -eq 0 ]; then
-- 
2.25.1

