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
|
From d611f18abac0f4077c9bf85f76162719cc5e55eb Mon Sep 17 00:00:00 2001
From: haozi007 <liuhao27@huawei.com>
Date: Tue, 14 Nov 2023 15:12:39 +0800
Subject: [PATCH 16/64] improve event logs
Signed-off-by: haozi007 <liuhao27@huawei.com>
---
.../grpc/cri/v1/cri_v1_runtime_runtime_service.cc | 13 ++++++++-----
.../grpc/cri/v1alpha/cri_runtime_runtime_service.cc | 10 +++++++---
src/daemon/entry/cri/cni_network_plugin.cc | 6 +++---
.../cri/v1alpha/cri_pod_sandbox_manager_service.cc | 3 ++-
src/daemon/executor/volume_cb/volume_cb.c | 4 ++--
src/daemon/modules/network/native/adaptor_native.c | 8 ++++----
6 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/daemon/entry/connect/grpc/cri/v1/cri_v1_runtime_runtime_service.cc b/src/daemon/entry/connect/grpc/cri/v1/cri_v1_runtime_runtime_service.cc
index b8d5746c..1db79307 100644
--- a/src/daemon/entry/connect/grpc/cri/v1/cri_v1_runtime_runtime_service.cc
+++ b/src/daemon/entry/connect/grpc/cri/v1/cri_v1_runtime_runtime_service.cc
@@ -75,7 +75,7 @@ grpc::Status RuntimeV1RuntimeServiceImpl::CreateContainer(grpc::ServerContext *c
return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
}
- EVENT("Event: {Object: CRI, Type: Creating Container}");
+ EVENT("Event: {Object: CRI, Type: Creating Container for sandbox: %s}", request->pod_sandbox_id().c_str());
std::string responseID =
m_rService->CreateContainer(request->pod_sandbox_id(), request->config(), request->sandbox_config(), error);
@@ -316,17 +316,20 @@ grpc::Status RuntimeV1RuntimeServiceImpl::RunPodSandbox(grpc::ServerContext *con
ERROR("Invalid input arguments");
return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
}
-
- EVENT("Event: {Object: CRI, Type: Running Pod}");
+ if (request->has_config() && request->config().has_metadata()) {
+ EVENT("Event: {Object: CRI, Type: Running Pod: %s}", request->config().metadata().name().c_str());
+ } else {
+ EVENT("Event: {Object: CRI, Type: Running Pod}");
+ }
std::string responseID = m_rService->RunPodSandbox(request->config(), request->runtime_handler(), error);
if (!error.Empty() || responseID.empty()) {
- ERROR("Object: CRI, Type: Failed to run pod:%s", error.GetMessage().c_str());
+ ERROR("Object: CRI, Type: Failed to run pod: %s", error.GetMessage().c_str());
return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
}
reply->set_pod_sandbox_id(responseID);
- EVENT("Event: {Object: CRI, Type: Run Pod success}");
+ EVENT("Event: {Object: CRI, Type: Run Pod: %s success}", responseID.c_str());
return grpc::Status::OK;
}
diff --git a/src/daemon/entry/connect/grpc/cri/v1alpha/cri_runtime_runtime_service.cc b/src/daemon/entry/connect/grpc/cri/v1alpha/cri_runtime_runtime_service.cc
index ec3f01cd..a56b167c 100644
--- a/src/daemon/entry/connect/grpc/cri/v1alpha/cri_runtime_runtime_service.cc
+++ b/src/daemon/entry/connect/grpc/cri/v1alpha/cri_runtime_runtime_service.cc
@@ -73,7 +73,7 @@ grpc::Status RuntimeRuntimeServiceImpl::CreateContainer(grpc::ServerContext *con
return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
}
- EVENT("Event: {Object: CRI, Type: Creating Container}");
+ EVENT("Event: {Object: CRI, Type: Creating Container for sandbox: %s}", request->pod_sandbox_id().c_str());
std::string responseID =
m_rService->CreateContainer(request->pod_sandbox_id(), request->config(), request->sandbox_config(), error);
@@ -315,7 +315,11 @@ grpc::Status RuntimeRuntimeServiceImpl::RunPodSandbox(grpc::ServerContext *conte
return grpc::Status(grpc::StatusCode::INVALID_ARGUMENT, "Invalid input arguments");
}
- EVENT("Event: {Object: CRI, Type: Running Pod}");
+ if (request->has_config() && request->config().has_metadata()) {
+ EVENT("Event: {Object: CRI, Type: Running Pod: %s}", request->config().metadata().name().c_str());
+ } else {
+ EVENT("Event: {Object: CRI, Type: Running Pod}");
+ }
std::string responseID = m_rService->RunPodSandbox(request->config(), request->runtime_handler(), error);
if (!error.Empty() || responseID.empty()) {
@@ -324,7 +328,7 @@ grpc::Status RuntimeRuntimeServiceImpl::RunPodSandbox(grpc::ServerContext *conte
}
reply->set_pod_sandbox_id(responseID);
- EVENT("Event: {Object: CRI, Type: Run Pod success}");
+ EVENT("Event: {Object: CRI, Type: Run Pod: %s success}", responseID.c_str());
return grpc::Status::OK;
}
diff --git a/src/daemon/entry/cri/cni_network_plugin.cc b/src/daemon/entry/cri/cni_network_plugin.cc
index 656fceda..377796ee 100644
--- a/src/daemon/entry/cri/cni_network_plugin.cc
+++ b/src/daemon/entry/cri/cni_network_plugin.cc
@@ -612,12 +612,12 @@ void CniNetworkPlugin::SetUpPod(const std::string &ns, const std::string &name,
if (g_isulad_errmsg != nullptr) {
err.SetError(g_isulad_errmsg);
} else {
- err.Errorf("setup cni for container: %s failed", id.c_str());
+ err.Errorf("setup cni for sandbox: %s failed", id.c_str());
}
// rollback all network plane
// if mutl-networks, one network plane failed, cause to left network can not be delete.
if (network_module_detach(config, NETWOKR_API_TYPE_CRI) != 0) {
- WARN("rollback all network for: %s failed", id.c_str());
+ WARN("rollback all network for sandbox: %s failed", id.c_str());
}
}
@@ -671,7 +671,7 @@ void CniNetworkPlugin::TearDownPod(const std::string &ns, const std::string &nam
}
if (network_module_detach(config, NETWOKR_API_TYPE_CRI) != 0) {
- err.Errorf("teardown cni for container: %s failed", id.c_str());
+ err.Errorf("teardown cni for sandbox: %s failed", id.c_str());
}
UnlockNetworkMap(err);
diff --git a/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc b/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
index 8533bb8c..8eff22ac 100644
--- a/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
+++ b/src/daemon/entry/cri/v1alpha/cri_pod_sandbox_manager_service.cc
@@ -618,6 +618,7 @@ auto PodSandboxManagerService::RunPodSandbox(const runtime::v1alpha2::PodSandbox
// Step 2: Create the sandbox container.
response_id = CreateSandboxContainer(config, image, jsonCheckpoint, runtimeHandler, error);
if (error.NotEmpty()) {
+ ERROR("Create sandbox failed: %s", error.GetCMessage());
goto cleanup;
}
@@ -672,7 +673,7 @@ auto PodSandboxManagerService::RunPodSandbox(const runtime::v1alpha2::PodSandbox
UpdatePodSandboxNetworkSettings(response_id, network_setting_json, tmpErr);
// If saving network settings failed, ignore error
if (tmpErr.NotEmpty()) {
- WARN("%s", tmpErr.GetCMessage());
+ WARN("Update sandbox network setting err: %s", tmpErr.GetCMessage());
}
}
goto cleanup;
diff --git a/src/daemon/executor/volume_cb/volume_cb.c b/src/daemon/executor/volume_cb/volume_cb.c
index 2148922e..ff5973b8 100644
--- a/src/daemon/executor/volume_cb/volume_cb.c
+++ b/src/daemon/executor/volume_cb/volume_cb.c
@@ -52,7 +52,7 @@ static int volume_list_cb(const volume_list_volume_request *request, volume_list
goto err_out;
}
- EVENT("Volume Event: {Object: list volumes, Type: listing}");
+ INFO("Volume Event: {Object: list volumes, Type: listing}");
list = volume_list();
if (list == NULL) {
@@ -85,7 +85,7 @@ static int volume_list_cb(const volume_list_volume_request *request, volume_list
}
out:
- EVENT("Volume Event: {Object: list volumes, Type: listed");
+ INFO("Volume Event: {Object: list volumes, Type: listed");
err_out:
if (*response != NULL) {
diff --git a/src/daemon/modules/network/native/adaptor_native.c b/src/daemon/modules/network/native/adaptor_native.c
index 45288d7e..baaecc32 100644
--- a/src/daemon/modules/network/native/adaptor_native.c
+++ b/src/daemon/modules/network/native/adaptor_native.c
@@ -1510,7 +1510,7 @@ int native_config_inspect(const char *name, char **network_json)
return -1;
}
- EVENT("Event: {Object: network, Type: inspecting, Target: %s}", name);
+ INFO("Event: {Object: network, Type: inspecting, Target: %s}", name);
if (!native_store_lock(SHARED)) {
return -1;
@@ -1538,7 +1538,7 @@ int native_config_inspect(const char *name, char **network_json)
// TODO: inspect the linked containers ip info
- EVENT("Event: {Object: network, Type: inspected, Target: %s}", name);
+ INFO("Event: {Object: network, Type: inspected, Target: %s}", name);
goto out;
}
@@ -1635,7 +1635,7 @@ int native_config_list(const struct filters_args *filters, network_network_info
return -1;
}
- EVENT("Event: {Object: network, Type: listing}");
+ INFO("Event: {Object: network, Type: listing}");
if (!native_store_lock(SHARED)) {
return -1;
@@ -1693,7 +1693,7 @@ int native_config_list(const struct filters_args *filters, network_network_info
*networks_len = nets_len;
nets_len = 0;
- EVENT("Event: {Object: network, Type: listed}");
+ INFO("Event: {Object: network, Type: listed}");
out:
map_itor_free(itor);
--
2.42.0
|