From 0cb96d50302f9f3ad1c17e0bb650ac37db4d5206 Mon Sep 17 00:00:00 2001
From: jikai <jikai11@huawei.com>
Date: Wed, 10 Apr 2024 08:41:46 +0000
Subject: [PATCH 53/69] remove container root path in rt_lcr_rm if lcr runtime
 missing

Signed-off-by: jikai <jikai11@huawei.com>
---
 src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c b/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c
index 6b862958..978da079 100644
--- a/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c
+++ b/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c
@@ -238,7 +238,13 @@ int rt_lcr_rm(const char *name, const char *runtime, const rt_rm_params_t *param
 
     engine_ops = engines_get_handler(runtime);
     if (engine_ops == NULL || engine_ops->engine_delete_op == NULL) {
-        ERROR("Failed to get engine delete operations");
+        // if engine_ops is NULL, container root path may have been corrupted, try to remove by daemon
+        // If user runs container with lcr but remove lcr runtime after, there might be resources remaining
+        ERROR("Failed to get engine delete operations, container %s root path may have been corrupted, try to remove by daemon", name);
+        if (remove_container_rootpath(name, params->rootpath) == 0) {
+            ret = 0;
+            goto out;
+        }
         ret = -1;
         goto out;
     }
-- 
2.34.1

