From 26c4a702ad9c919d8413b64f498d58b13375bbda Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 18 Apr 2023 17:30:03 +0800
Subject: [PATCH 45/46] if the exit code in the response of execSync is not
 zero, an error will be returned in cri

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 src/daemon/entry/connect/grpc/runtime_runtime_service.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/daemon/entry/connect/grpc/runtime_runtime_service.cc b/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
index 451eeeef..4cc5a4ee 100644
--- a/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
+++ b/src/daemon/entry/connect/grpc/runtime_runtime_service.cc
@@ -289,6 +289,13 @@ grpc::Status RuntimeRuntimeServiceImpl::ExecSync(grpc::ServerContext *context,
         return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
     }
 
+    if (reply->exit_code() != 0) {
+        ERROR("Object: CRI, Type: Sync exec in container: %s with exit code: %d", request->container_id().c_str(),
+              reply->exit_code());
+        error.SetError(reply->stderr());
+        return grpc::Status(grpc::StatusCode::UNKNOWN, error.GetMessage());
+    }
+
     WARN("Event: {Object: CRI, Type: sync execed Container: %s}", request->container_id().c_str());
 
     return grpc::Status::OK;
-- 
2.25.1

