summaryrefslogtreecommitdiff
path: root/0021-bugfix-of-update-restart-policy-for-auto-remove-cont.patch
blob: 6d0ba03b3ef21032daae3c937fe21bf7886c1145 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From ea51fa836464660fcca245e7e36a2b4cdf1e5997 Mon Sep 17 00:00:00 2001
From: zhangxiaoyu <zhangxiaoyu58@huawei.com>
Date: Tue, 21 Nov 2023 10:23:26 +0800
Subject: [PATCH 21/64] bugfix of update restart policy for auto remove
 container

Signed-off-by: zhangxiaoyu <zhangxiaoyu58@huawei.com>
---
 .../executor/container_cb/execution_extend.c   | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/daemon/executor/container_cb/execution_extend.c b/src/daemon/executor/container_cb/execution_extend.c
index 6759a4fc..de017b4e 100644
--- a/src/daemon/executor/container_cb/execution_extend.c
+++ b/src/daemon/executor/container_cb/execution_extend.c
@@ -1113,15 +1113,14 @@ static int update_host_config_check(container_t *cont, host_config *hostconfig)
 
     ret = verify_host_config_settings(hostconfig, true);
     if (ret != 0) {
-        goto out;
+        return -1;
     }
 
     if (container_is_removal_in_progress(cont->state) || container_is_dead(cont->state)) {
         ERROR("Container is marked for removal and cannot be \"update\".");
         isulad_set_error_message(
             "Cannot update container %s: Container is marked for removal and cannot be \"update\".", id);
-        ret = -1;
-        goto out;
+        return -1;
     }
 
     if (container_is_running(cont->state) && hostconfig->kernel_memory) {
@@ -1129,12 +1128,17 @@ static int update_host_config_check(container_t *cont, host_config *hostconfig)
         isulad_set_error_message("Cannot update container %s: Can not update kernel memory to a running container,"
                                  " please stop it first.",
                                  id);
-        ret = -1;
-        goto out;
+        return -1;
     }
 
-out:
-    return ret;
+    if (cont->hostconfig->auto_remove && hostconfig->restart_policy != NULL &&
+        hostconfig->restart_policy->name != NULL && strcmp("no", hostconfig->restart_policy->name) != 0) {
+        ERROR("Cannot update restart policy for the auto remove container %s", id);
+        isulad_set_error_message("Cannot update restart policy for the auto remove container %s", id);
+        return -1;
+    }
+
+    return 0;
 }
 
 static int do_update_resources(const container_update_request *request, container_t *cont)
-- 
2.42.0