summaryrefslogtreecommitdiff
path: root/0010-do-not-report-low-level-error-to-user.patch
blob: b86e5bf401a980da1ddff171318f5241df6d5af8 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
From ab03fdd4261ebc11f18e3b783dfc38558e5247b5 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Wed, 6 Sep 2023 10:45:37 +0800
Subject: [PATCH 10/33] do not report low level error to user

Signed-off-by: haozi007 <liuhao27@huawei.com>
---
 src/daemon/entry/cri/cri_helpers.cc             |  4 ++--
 .../v1alpha/cri_container_manager_service.cc    |  3 ++-
 src/daemon/executor/container_cb/execution.c    |  4 ++--
 .../executor/container_cb/execution_network.c   | 17 ++++++++---------
 .../executor/container_cb/execution_stream.c    |  4 ++--
 src/daemon/modules/container/container_unix.c   |  2 +-
 src/daemon/modules/image/external/ext_image.c   |  4 ++--
 src/daemon/modules/image/oci/oci_load.c         |  2 +-
 .../modules/runtime/engines/lcr/lcr_rt_ops.c    |  3 +--
 src/daemon/modules/service/service_container.c  |  2 +-
 src/daemon/modules/spec/verify.c                |  2 +-
 src/daemon/modules/volume/local.c               |  8 ++++----
 src/utils/tar/isulad_tar.c                      | 16 ++++++++--------
 src/utils/tar/util_archive.c                    | 12 ++++++------
 14 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/src/daemon/entry/cri/cri_helpers.cc b/src/daemon/entry/cri/cri_helpers.cc
index a80ec7d0..2e1096f5 100644
--- a/src/daemon/entry/cri/cri_helpers.cc
+++ b/src/daemon/entry/cri/cri_helpers.cc
@@ -540,8 +540,8 @@ void RemoveContainerLogSymlink(const std::string &containerID, Errors &error)
     if (path != nullptr) {
         // Only remove the symlink when container log path is specified.
         if (util_path_remove(path) != 0 && errno != ENOENT) {
-            error.Errorf("Failed to remove container %s log symlink %s: %s", containerID.c_str(), path,
-                         strerror(errno));
+            SYSERROR("Failed to remove container %s log symlink %s.", containerID.c_str(), path);
+            error.Errorf("Failed to remove container %s log symlink %s.", containerID.c_str(), path);
             goto cleanup;
         }
     }
diff --git a/src/daemon/entry/cri/v1alpha/cri_container_manager_service.cc b/src/daemon/entry/cri/v1alpha/cri_container_manager_service.cc
index b4faab95..013b938a 100644
--- a/src/daemon/entry/cri/v1alpha/cri_container_manager_service.cc
+++ b/src/daemon/entry/cri/v1alpha/cri_container_manager_service.cc
@@ -547,8 +547,9 @@ void ContainerManagerService::CreateContainerLogSymlink(const std::string &conta
             WARN("Deleted previously existing symlink file: %s", path);
         }
         if (symlink(realPath, path) != 0) {
+            SYSERROR("failed to create symbolic link %s to the container log file %s for container %s", path, realPath, containerID.c_str());
             error.Errorf("failed to create symbolic link %s to the container log file %s for container %s: %s", path,
-                         realPath, containerID.c_str(), strerror(errno));
+                         realPath, containerID.c_str());
             goto cleanup;
         }
     } else {
diff --git a/src/daemon/executor/container_cb/execution.c b/src/daemon/executor/container_cb/execution.c
index d3571b7f..63d8143c 100644
--- a/src/daemon/executor/container_cb/execution.c
+++ b/src/daemon/executor/container_cb/execution.c
@@ -345,13 +345,13 @@ static int maybe_create_cpu_realtime_file(int64_t value, const char *file, const
     fd = util_open(fpath, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, 0700);
     if (fd < 0) {
         SYSERROR("Failed to open file: %s.", fpath);
-        isulad_set_error_message("Failed to open file: %s: %s", fpath, strerror(errno));
+        isulad_set_error_message("Failed to open file: %s.", fpath);
         return -1;
     }
     nwrite = util_write_nointr(fd, buf, strlen(buf));
     if (nwrite < 0 || (size_t)nwrite != strlen(buf)) {
         SYSERROR("Failed to write %s to %s.", buf, fpath);
-        isulad_set_error_message("Failed to write '%s' to '%s': %s", buf, fpath, strerror(errno));
+        isulad_set_error_message("Failed to write '%s' to '%s'.", buf, fpath);
         return -1;
     }
 
diff --git a/src/daemon/executor/container_cb/execution_network.c b/src/daemon/executor/container_cb/execution_network.c
index ce924332..a145e33a 100644
--- a/src/daemon/executor/container_cb/execution_network.c
+++ b/src/daemon/executor/container_cb/execution_network.c
@@ -68,8 +68,8 @@ static int write_hostname_to_file(const char *rootfs, const char *hostname)
 
     ret = util_write_file(file_path, hostname, strlen(hostname), NETWORK_MOUNT_FILE_MODE);
     if (ret) {
-        SYSERROR("Failed to write %s", file_path);
-        isulad_set_error_message("Failed to write %s: %s", file_path, strerror(errno));
+        SYSERROR("Failed to write %s.", file_path);
+        isulad_set_error_message("Failed to write %s.", file_path);
         goto out;
     }
 
@@ -97,8 +97,8 @@ static int fopen_network(FILE **fp, char **file_path, const char *rootfs, const
 
     *fp = util_fopen(*file_path, "a+");
     if (*fp == NULL) {
-        SYSERROR("Failed to open %s", *file_path);
-        isulad_set_error_message("Failed to open %s: %s", *file_path, strerror(errno));
+        SYSERROR("Failed to open %s.", *file_path);
+        isulad_set_error_message("Failed to open %s.", *file_path);
         return -1;
     }
     return 0;
@@ -169,8 +169,8 @@ static int write_content_to_file(const char *file_path, const char *content)
     if (content != NULL) {
         ret = util_write_file(file_path, content, strlen(content), NETWORK_MOUNT_FILE_MODE);
         if (ret != 0) {
-            SYSERROR("Failed to write file %s", file_path);
-            isulad_set_error_message("Failed to write file %s: %s", file_path, strerror(errno));
+            SYSERROR("Failed to write file %s.", file_path);
+            isulad_set_error_message("Failed to write file %s.", file_path);
             return ret;
         }
     }
@@ -702,9 +702,8 @@ static int chown_network(const char *user_remap, const char *rootfs, const char
         goto out;
     }
     if (chown(file_path, host_uid, host_gid) != 0) {
-        SYSERROR("Failed to chown network file '%s' to %u:%u", filename, host_uid, host_gid);
-        isulad_set_error_message("Failed to chown network file '%s' to %u:%u: %s", filename, host_uid, host_gid,
-                                 strerror(errno));
+        SYSERROR("Failed to chown network file '%s' to %u:%u.", filename, host_uid, host_gid);
+        isulad_set_error_message("Failed to chown network file '%s' to %u:%u.", filename, host_uid, host_gid);
         ret = -1;
         goto out;
     }
diff --git a/src/daemon/executor/container_cb/execution_stream.c b/src/daemon/executor/container_cb/execution_stream.c
index 7e84cca3..aae9c234 100644
--- a/src/daemon/executor/container_cb/execution_stream.c
+++ b/src/daemon/executor/container_cb/execution_stream.c
@@ -536,7 +536,7 @@ static container_path_stat *do_container_stat_path(const char *rootpath, const c
     nret = lstat(resolvedpath, &st);
     if (nret < 0) {
         SYSERROR("lstat %s failed.", resolvedpath);
-        isulad_set_error_message("lstat %s: %s", resolvedpath, strerror(errno));
+        isulad_set_error_message("lstat %s failed.", resolvedpath);
         goto cleanup;
     }
 
@@ -922,7 +922,7 @@ static int copy_to_container_check_path_valid(const container_t *cont, const cha
     nret = lstat(resolvedpath, &st);
     if (nret < 0) {
         SYSERROR("lstat %s failed", resolvedpath);
-        isulad_set_error_message("lstat %s: %s", resolvedpath, strerror(errno));
+        isulad_set_error_message("lstat %s failed", resolvedpath);
         goto cleanup;
     }
 
diff --git a/src/daemon/modules/container/container_unix.c b/src/daemon/modules/container/container_unix.c
index e8c98441..fa53a85f 100644
--- a/src/daemon/modules/container/container_unix.c
+++ b/src/daemon/modules/container/container_unix.c
@@ -518,7 +518,7 @@ static int save_json_config_file(const char *id, const char *rootpath, const cha
     nret = util_atomic_write_file(filename, json_data, strlen(json_data), CONFIG_FILE_MODE, false);
     if (nret != 0) {
         SYSERROR("Write file %s failed.", filename);
-        isulad_set_error_message("Write file '%s' failed: %s", filename, strerror(errno));
+        isulad_set_error_message("Write file '%s' failed.", filename);
         ret = -1;
     }
 
diff --git a/src/daemon/modules/image/external/ext_image.c b/src/daemon/modules/image/external/ext_image.c
index 10af82a3..e1706469 100644
--- a/src/daemon/modules/image/external/ext_image.c
+++ b/src/daemon/modules/image/external/ext_image.c
@@ -65,8 +65,8 @@ int ext_prepare_rf(const im_prepare_request *request, char **real_rootfs)
                 return -1;
             }
             if (realpath(request->rootfs, real_path) == NULL) {
-                SYSERROR("Failed to clean rootfs path '%s'", request->rootfs);
-                isulad_set_error_message("Failed to clean rootfs path '%s': %s", request->rootfs, strerror(errno));
+                SYSERROR("Failed to clean rootfs path '%s'.", request->rootfs);
+                isulad_set_error_message("Failed to clean rootfs path '%s'.", request->rootfs);
                 return -1;
             }
             *real_rootfs = util_strdup_s(real_path);
diff --git a/src/daemon/modules/image/oci/oci_load.c b/src/daemon/modules/image/oci/oci_load.c
index d2efab81..5511a70c 100644
--- a/src/daemon/modules/image/oci/oci_load.c
+++ b/src/daemon/modules/image/oci/oci_load.c
@@ -1046,7 +1046,7 @@ static char *oci_load_path_create()
 
     if (mkdtemp(tmp_dir) == NULL) {
         SYSERROR("make temporary dir failed");
-        isulad_try_set_error_message("make temporary dir failed: %s", strerror(errno));
+        isulad_try_set_error_message("make temporary dir failed");
         ret = -1;
         goto out;
     }
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 e985cfc1..f61316d0 100644
--- a/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c
+++ b/src/daemon/modules/runtime/engines/lcr/lcr_rt_ops.c
@@ -209,9 +209,8 @@ static int remove_container_rootpath(const char *id, const char *root_path)
     }
     ret = util_recursive_rmdir(cont_root_path, 0);
     if (ret != 0) {
-        const char *tmp_err = (errno != 0) ? strerror(errno) : "error";
         SYSERROR("Failed to delete container's root directory %s.", cont_root_path);
-        isulad_set_error_message("Failed to delete container's root directory %s: %s", cont_root_path, tmp_err);
+        isulad_set_error_message("Failed to delete container's root directory %s.", cont_root_path);
         ret = -1;
         goto out;
     }
diff --git a/src/daemon/modules/service/service_container.c b/src/daemon/modules/service/service_container.c
index 483670de..370ba059 100644
--- a/src/daemon/modules/service/service_container.c
+++ b/src/daemon/modules/service/service_container.c
@@ -596,7 +596,7 @@ static int valid_mount_point(container_config_v2_common_config_mount_points_elem
 
     if (lstat(mp->source, &st) != 0) {
         SYSERROR("lstat %s failed", mp->source);
-        isulad_set_error_message("lstat %s: %s", mp->source, strerror(errno));
+        isulad_set_error_message("lstat %s failed", mp->source);
         return -1;
     }
 
diff --git a/src/daemon/modules/spec/verify.c b/src/daemon/modules/spec/verify.c
index 6180b887..92029cbd 100644
--- a/src/daemon/modules/spec/verify.c
+++ b/src/daemon/modules/spec/verify.c
@@ -1536,7 +1536,7 @@ static int verify_custom_mount(defs_mount **mounts, size_t len)
         if (!util_file_exists(iter->source) && util_mkdir_p(iter->source, mode)) {
 #endif
             SYSERROR("Failed to create directory '%s'", iter->source);
-            isulad_try_set_error_message("Failed to create directory '%s': %s", iter->source, strerror(errno));
+            isulad_try_set_error_message("Failed to create directory '%s'", iter->source);
             ret = -1;
             goto out;
         }
diff --git a/src/daemon/modules/volume/local.c b/src/daemon/modules/volume/local.c
index 7f95757d..6c3354dc 100644
--- a/src/daemon/modules/volume/local.c
+++ b/src/daemon/modules/volume/local.c
@@ -556,15 +556,15 @@ static int remove_volume_dir(char *path)
     // remain untouched if we remove the data directory failed.
     ret = util_recursive_rmdir(path, 0);
     if (ret != 0) {
-        SYSERROR("failed to remove volume data dir %s", path);
-        isulad_try_set_error_message("failed to remove volume data dir %s: %s", path, strerror(errno));
+        SYSERROR("failed to remove volume data dir %s.", path);
+        isulad_try_set_error_message("failed to remove volume data dir %s.", path);
         goto out;
     }
 
     ret = util_recursive_rmdir(vol_dir, 0);
     if (ret != 0) {
-        SYSERROR("failed to remove volume dir %s", vol_dir);
-        isulad_try_set_error_message("failed to remove volume dir %s: %s", vol_dir, strerror(errno));
+        SYSERROR("failed to remove volume dir %s.", vol_dir);
+        isulad_try_set_error_message("failed to remove volume dir %s.", vol_dir);
         goto out;
     }
 
diff --git a/src/utils/tar/isulad_tar.c b/src/utils/tar/isulad_tar.c
index 7218cca8..bffbb43b 100644
--- a/src/utils/tar/isulad_tar.c
+++ b/src/utils/tar/isulad_tar.c
@@ -114,7 +114,7 @@ static int resolve_host_source_path(const char *path, bool follow_link, char **r
     if (follow_link) {
         if (realpath(path, real_path) == NULL) {
             SYSERROR("Can not get real path of %s.", real_path);
-            format_errorf(err, "Can not get real path of %s: %s", real_path, strerror(errno));
+            format_errorf(err, "Can not get real path of %s.", real_path);
             return -1;
         }
         nret = get_rebase_name(path, real_path, resolved_path, rebase_name);
@@ -131,7 +131,7 @@ static int resolve_host_source_path(const char *path, bool follow_link, char **r
         }
         if (realpath(dirpath, real_path) == NULL) {
             SYSERROR("Can not get real path of %s.", dirpath);
-            format_errorf(err, "Can not get real path of %s: %s", dirpath, strerror(errno));
+            format_errorf(err, "Can not get real path of %s.", dirpath);
             goto cleanup;
         }
         nret = snprintf(resolved, sizeof(resolved), "%s/%s", real_path, basepath);
@@ -192,7 +192,7 @@ struct archive_copy_info *copy_info_source_path(const char *path, bool follow_li
     nret = lstat(resolved_path, &st);
     if (nret < 0) {
         SYSERROR("lstat %s failed", resolved_path);
-        format_errorf(err, "lstat %s: %s", resolved_path, strerror(errno));
+        format_errorf(err, "lstat %s failed", resolved_path);
         goto cleanup;
     }
 
@@ -225,8 +225,8 @@ static int copy_info_destination_path_ret(struct archive_copy_info *info, struct
 
         ret = (int)readlink(iter_path, target, PATH_MAX);
         if (ret < 0) {
-            SYSERROR("Failed to read link of %s", iter_path);
-            format_errorf(err, "Failed to read link of %s: %s", iter_path, strerror(errno));
+            SYSERROR("Failed to read link of %s.", iter_path);
+            format_errorf(err, "Failed to read link of %s.", iter_path);
             goto cleanup;
         }
         // is not absolutely path
@@ -258,8 +258,8 @@ static int copy_info_destination_path_ret(struct archive_copy_info *info, struct
     if (ret != 0) {
         char *dst_parent = NULL;
         if (errno != ENOENT) {
-            SYSERROR("Can not stat %s", iter_path);
-            format_errorf(err, "Can not stat %s: %s", iter_path, strerror(errno));
+            SYSERROR("Can not stat %s.", iter_path);
+            format_errorf(err, "Can not stat %s.", iter_path);
             goto cleanup;
         }
 
@@ -429,7 +429,7 @@ static int tar_resource_rebase(const char *path, const char *rebase, const char
 
     if (lstat(path, &st) < 0) {
         SYSERROR("lstat %s failed", path);
-        format_errorf(err, "lstat %s: %s", path, strerror(errno));
+        format_errorf(err, "lstat %s failed", path);
         return -1;
     }
     if (util_split_path_dir_entry(path, &srcdir, &srcbase) < 0) {
diff --git a/src/utils/tar/util_archive.c b/src/utils/tar/util_archive.c
index f34572ae..82194654 100644
--- a/src/utils/tar/util_archive.c
+++ b/src/utils/tar/util_archive.c
@@ -257,8 +257,8 @@ static int do_safe_chroot(const char *dstdir)
     prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);
 
     if (chroot(dstdir) != 0) {
-        SYSERROR("Failed to chroot to %s", dstdir);
-        fprintf(stderr, "Failed to chroot to %s: %s", dstdir, strerror(errno));
+        SYSERROR("Failed to chroot to %s.", dstdir);
+        fprintf(stderr, "Failed to chroot to %s.", dstdir);
         return -1;
     }
 
@@ -846,15 +846,15 @@ int archive_unpack(const struct io_read_wrapper *content, const char *dstdir, co
         }
 
         if (do_safe_chroot(safe_dir) != 0) {
-            SYSERROR("Failed to chroot to %s", safe_dir);
-            fprintf(stderr, "Failed to chroot to %s: %s", safe_dir, strerror(errno));
+            SYSERROR("Failed to chroot to %s.", safe_dir);
+            fprintf(stderr, "Failed to chroot to %s.", safe_dir);
             ret = -1;
             goto child_out;
         }
 
         if (chdir("/") != 0) {
             SYSERROR("Failed to chroot to /");
-            fprintf(stderr, "Failed to chroot to /: %s", strerror(errno));
+            fprintf(stderr, "Failed to chroot to /");
             ret = -1;
             goto child_out;
         }
@@ -1253,7 +1253,7 @@ int archive_chroot_tar(const char *path, const char *file, const char *root_dir,
         fd = open(file, TAR_DEFAULT_FLAG, TAR_DEFAULT_MODE);
         if (fd < 0) {
             SYSERROR("Failed to open file %s for export", file);
-            fprintf(stderr, "Failed to open file %s for export: %s\n", file, strerror(errno));
+            fprintf(stderr, "Failed to open file %s for export\n", file);
             ret = -1;
             goto child_out;
         }
-- 
2.40.1