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
|
From e47abc01c8778cc07c11a331ae31ce46b6fd06a0 Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Thu, 14 Dec 2023 10:59:34 +0800
Subject: [PATCH 59/64] improve code of pull
1. ignore unneccessary error log;
2. do not show progress, if stdout is not tty;
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
src/cmd/isula/images/pull.c | 6 ++++++
.../modules/image/oci/storage/image_store/image_type.c | 8 ++++++++
.../layer_store/graphdriver/overlay2/driver_overlay2.c | 5 +++++
3 files changed, 19 insertions(+)
diff --git a/src/cmd/isula/images/pull.c b/src/cmd/isula/images/pull.c
index 9d420778..b30cc0bd 100644
--- a/src/cmd/isula/images/pull.c
+++ b/src/cmd/isula/images/pull.c
@@ -36,6 +36,12 @@ struct client_arguments g_cmd_pull_args = {};
static bool is_terminal_show_supported()
{
#ifdef GRPC_CONNECTOR
+ // if stdout is not tty, just ingore progress
+ if (!isatty(STDOUT_FILENO)) {
+ WARN("Stdout is not tty device, just ignore progress.");
+ return false;
+ }
+
// Initialize the terminfo database
setupterm(NULL, STDOUT_FILENO, (int *)0);
diff --git a/src/daemon/modules/image/oci/storage/image_store/image_type.c b/src/daemon/modules/image/oci/storage/image_store/image_type.c
index 50af0a69..50a81db2 100644
--- a/src/daemon/modules/image/oci/storage/image_store/image_type.c
+++ b/src/daemon/modules/image/oci/storage/image_store/image_type.c
@@ -77,6 +77,14 @@ int try_fill_image_spec(image_t *img, const char *id, const char *image_store_di
goto out;
}
+ // for new_image(), first try will failed because config file not exist
+ // and image_store_set_big_data() will retry this function
+ if (!util_file_exists(config_file)) {
+ WARN("Oci image spec: %s not found.", config_file);
+ ret = -1;
+ goto out;
+ }
+
img->spec = oci_image_spec_parse_file(config_file, NULL, &err);
if (img->spec == NULL) {
ERROR("Failed to parse oci image spec: %s", err);
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c
index 3bc433ae..3d814954 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/overlay2/driver_overlay2.c
@@ -1133,7 +1133,12 @@ static char *read_layer_lower_file(const char *layer_dir)
goto out;
}
+ // lowest layer do not have lower file
+ if (!util_file_exists(lower_file)) {
+ goto out;
+ }
lower = util_read_text_file(lower_file);
+
out:
free(lower_file);
return lower;
--
2.42.0
|