提交 a21b9a21 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!176 Do not use rootfs to fill field image_name

Merge pull request !176 from wangfengtu/ps_image
......@@ -9,7 +9,7 @@ include(cmake/set_build_flags.cmake)
#set(CMAKE_C_COMPILER "gcc" CACHE PATH "c compiler")
set(GIT_COMMIT_HASH "836228b6be4f000597c484a2862564134d25d9d0")
set(GIT_COMMIT_HASH "f2a6e59b14e430d166e350cac06ec188fb7ca47e")
message("-- commit id: " ${GIT_COMMIT_HASH})
add_definitions(-DISULAD_GIT_COMMIT="${GIT_COMMIT_HASH}")
......
%global _version 2.0.0
%global _release 20200403.055852.git836228b6
%global _release 20200406.224326.gitf2a6e59b
%global is_systemd 1
%global debug_package %{nil}
......
......@@ -60,16 +60,16 @@ int ext_prepare_rf(const im_prepare_request *request, char **real_rootfs)
}
if (real_rootfs != NULL) {
if (request->image_name != NULL) {
if (request->rootfs != NULL) {
char real_path[PATH_MAX] = { 0 };
if (request->image_name[0] != '/') {
if (request->rootfs[0] != '/') {
ERROR("Rootfs should be absolutely path");
isulad_set_error_message("Rootfs should be absolutely path");
return -1;
}
if (realpath(request->image_name, real_path) == NULL) {
ERROR("Failed to clean rootfs path '%s': %s", request->image_name, strerror(errno));
isulad_set_error_message("Failed to clean rootfs path '%s': %s", request->image_name, strerror(errno));
if (realpath(request->rootfs, real_path) == NULL) {
ERROR("Failed to clean rootfs path '%s': %s", request->rootfs, strerror(errno));
isulad_set_error_message("Failed to clean rootfs path '%s': %s", request->rootfs, strerror(errno));
return -1;
}
*real_rootfs = util_strdup_s(real_path);
......@@ -128,15 +128,15 @@ int ext_merge_conf(const host_config *host_spec, container_config *container_spe
}
// No config neeed merge if NULL.
if (request->ext_config_image == NULL) {
if (request->image_name == NULL) {
ret = 0;
goto out;
}
// Get image's config and merge configs.
resolved_name = oci_resolve_image_name(request->ext_config_image);
resolved_name = oci_resolve_image_name(request->image_name);
if (resolved_name == NULL) {
ERROR("Resolve external config image name failed, image name is %s", request->ext_config_image);
ERROR("Resolve external config image name failed, image name is %s", request->image_name);
ret = -1;
goto out;
}
......
......@@ -534,8 +534,8 @@ void free_im_prepare_request(im_prepare_request *request)
request->image_name = NULL;
free(request->container_id);
request->container_id = NULL;
free(request->ext_config_image);
request->ext_config_image = NULL;
free(request->rootfs);
request->rootfs = NULL;
free_json_map_string_string(request->storage_opt);
request->storage_opt = NULL;
......@@ -706,8 +706,7 @@ bool im_config_image_exist(const char *image_name)
}
int im_merge_image_config(const char *id, const char *image_type, const char *image_name,
const char *ext_config_image,
host_config *host_spec, container_config *container_spec,
const char *rootfs, host_config *host_spec, container_config *container_spec,
char **real_rootfs)
{
int ret = 0;
......@@ -720,7 +719,7 @@ int im_merge_image_config(const char *id, const char *image_type, const char *im
goto out;
}
bim = bim_get(image_type, image_name, ext_config_image, id);
bim = bim_get(image_type, image_name, rootfs, id);
if (bim == NULL) {
ERROR("Failed to init bim of image %s", image_name);
ret = -1;
......@@ -739,7 +738,7 @@ int im_merge_image_config(const char *id, const char *image_type, const char *im
}
request->container_id = util_strdup_s(id);
request->image_name = util_strdup_s(image_name);
request->ext_config_image = util_strdup_s(ext_config_image);
request->rootfs = util_strdup_s(rootfs);
if (host_spec != NULL) {
request->storage_opt = host_spec->storage_opt;
}
......@@ -749,7 +748,7 @@ int im_merge_image_config(const char *id, const char *image_type, const char *im
ret = bim->ops->merge_conf(host_spec, container_spec, request, real_rootfs);
request->storage_opt = NULL;
if (ret != 0) {
ERROR("Failed to merge image %s config, config image is %s", image_name, ext_config_image);
ERROR("Failed to merge image %s config", image_name);
ret = -1;
goto out;
}
......
......@@ -187,7 +187,7 @@ typedef struct {
typedef struct {
char *image_name;
char *container_id;
char *ext_config_image;
char *rootfs;
json_map_string_string *storage_opt;
} im_prepare_request;
......@@ -300,8 +300,7 @@ int im_umount_container_rootfs(const char *image_type, const char *image_name, c
int im_remove_container_rootfs(const char *image_type, const char *container_id);
int im_merge_image_config(const char *id, const char *image_type, const char *image_name,
const char *ext_config_image,
host_config *host_spec, container_config *container_spec,
const char *rootfs, host_config *host_spec, container_config *container_spec,
char **real_rootfs);
int im_get_user_conf(const char *image_type, const char *basefs, host_config *hc, const char *userstr,
......
......@@ -776,27 +776,21 @@ static int get_request_container_info(const container_create_request *request, c
return 0;
}
static int get_request_image_info(const container_create_request *request, char **image_type,
const char **ext_config_image, const char **image_name)
static int get_request_image_info(const container_create_request *request, char **image_type, char **image_name)
{
*image_type = im_get_image_type(request->image, request->rootfs);
if (*image_type == NULL) {
return -1;
}
if (request->rootfs != NULL) {
*image_name = request->rootfs;
// Do not use none image because none image has no config.
if (strcmp(request->image, "none") && strcmp(request->image, "none:latest")) {
*ext_config_image = request->image;
}
} else {
*image_name = request->image;
// Do not use none image because none image has no config.
if (strcmp(request->image, "none") && strcmp(request->image, "none:latest")) {
*image_name = util_strdup_s(request->image);
}
// Check if config image exist if provided.
if (*ext_config_image != NULL) {
if (!im_config_image_exist(*ext_config_image)) {
if (*image_name != NULL) {
if (!im_config_image_exist(*image_name)) {
return -1;
}
}
......@@ -881,8 +875,7 @@ int container_create_cb(const container_create_request *request,
char *runtime = NULL;
char *name = NULL;
char *id = NULL;
const char *image_name = NULL;
const char *ext_config_image = NULL;
char *image_name = NULL;
oci_runtime_spec *oci_spec = NULL;
host_config *host_spec = NULL;
container_config *container_spec = NULL;
......@@ -900,7 +893,7 @@ int container_create_cb(const container_create_request *request,
goto pack_response;
}
if (get_request_image_info(request, &image_type, &ext_config_image, &image_name) != 0) {
if (get_request_image_info(request, &image_type, &image_name) != 0) {
cc = ISULAD_ERR_EXEC;
goto clean_nameindex;
}
......@@ -941,7 +934,7 @@ int container_create_cb(const container_create_request *request,
goto clean_container_root_dir;
}
ret = im_merge_image_config(id, image_type, image_name, ext_config_image, host_spec,
ret = im_merge_image_config(id, image_type, image_name, request->rootfs, host_spec,
v2_spec->config, &real_rootfs);
if (ret != 0) {
ERROR("Can not merge container_spec with image config");
......@@ -1042,6 +1035,7 @@ pack_response:
free(runtime_root);
free(real_rootfs);
free(image_type);
free(image_name);
free(name);
free(id);
free_oci_runtime_spec(oci_spec);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册