Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
b8cd5aba
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b8cd5aba
编写于
2月 15, 2020
作者:
G
gaohuatao
提交者:
jingrui
2月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
iSulad: prepare for oci supported isulad-shim
Signed-off-by:
N
gaohuatao
<
gaohuatao@huawei.com
>
上级
6da699de
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
175 addition
and
32 deletion
+175
-32
src/cmd/isula/base/create.c
src/cmd/isula/base/create.c
+1
-1
src/cmd/isula/base/run.c
src/cmd/isula/base/run.c
+1
-1
src/config/isulad_config.c
src/config/isulad_config.c
+26
-0
src/config/isulad_config.h
src/config/isulad_config.h
+2
-0
src/connect/client/grpc/grpc_containers_client.cc
src/connect/client/grpc/grpc_containers_client.cc
+0
-4
src/container_def.h
src/container_def.h
+1
-1
src/contrib/config/config.json
src/contrib/config/config.json
+1
-1
src/contrib/config/daemon.json
src/contrib/config/daemon.json
+1
-0
src/contrib/config/systemcontainer_config.json
src/contrib/config/systemcontainer_config.json
+1
-1
src/cutils/utils.c
src/cutils/utils.c
+0
-1
src/cutils/utils_file.c
src/cutils/utils_file.c
+1
-1
src/cutils/utils_file.h
src/cutils/utils_file.h
+2
-0
src/cutils/utils_string.c
src/cutils/utils_string.c
+12
-0
src/cutils/utils_string.h
src/cutils/utils_string.h
+2
-0
src/cutils/utils_verify.c
src/cutils/utils_verify.c
+1
-1
src/json/schema/schema/defs.json
src/json/schema/schema/defs.json
+19
-0
src/json/schema/schema/isulad-daemon-configs.json
src/json/schema/schema/isulad-daemon-configs.json
+6
-0
src/services/cri/cri_container.cc
src/services/cri/cri_container.cc
+13
-2
src/services/cri/cri_helpers.cc
src/services/cri/cri_helpers.cc
+4
-0
src/services/cri/cri_helpers.h
src/services/cri/cri_helpers.h
+4
-0
src/services/cri/cri_sandbox.cc
src/services/cri/cri_sandbox.cc
+6
-1
src/services/execution/execute/execution_create.c
src/services/execution/execute/execution_create.c
+69
-15
src/services/execution/manager/health_check.c
src/services/execution/manager/health_check.c
+1
-1
test/image/oci/oci_config_merge/oci_runtime_spec.json
test/image/oci/oci_config_merge/oci_runtime_spec.json
+1
-1
未找到文件。
src/cmd/isula/base/create.c
浏览文件 @
b8cd5aba
...
...
@@ -37,7 +37,7 @@ const char g_cmd_create_desc[] = "Create a new container";
const
char
g_cmd_create_usage
[]
=
"create [OPTIONS] --external-rootfs=PATH|IMAGE [COMMAND] [ARG...]"
;
struct
client_arguments
g_cmd_create_args
=
{
.
runtime
=
"
lcr
"
,
.
runtime
=
""
,
.
restart
=
"no"
,
.
log_file_size
=
"1MB"
,
.
log_file_rotate
=
7
,
...
...
src/cmd/isula/base/run.c
浏览文件 @
b8cd5aba
...
...
@@ -29,7 +29,7 @@ const char g_cmd_run_desc[] = "Run a command in a new container";
const
char
g_cmd_run_usage
[]
=
"run [OPTIONS] ROOTFS|IMAGE [COMMAND] [ARG...]"
;
static
int
run_checker
(
struct
client_arguments
*
args
);
struct
client_arguments
g_cmd_run_args
=
{
.
runtime
=
"
lcr
"
,
.
runtime
=
""
,
.
restart
=
"no"
,
.
log_file
=
NULL
,
.
log_file_size
=
"1MB"
,
...
...
src/config/isulad_config.c
浏览文件 @
b8cd5aba
...
...
@@ -1206,6 +1206,28 @@ out:
return
result
;
}
char
*
conf_get_default_runtime
()
{
struct
service_arguments
*
conf
=
NULL
;
char
*
result
=
NULL
;
if
(
isulad_server_conf_rdlock
())
{
ERROR
(
"BUG conf_rdlock failed"
);
return
NULL
;
}
conf
=
conf_get_server_conf
();
if
(
conf
==
NULL
||
conf
->
json_confs
==
NULL
)
{
goto
out
;
}
result
=
strings_to_lower
(
conf
->
json_confs
->
default_runtime
);
out:
(
void
)
isulad_server_conf_unlock
();
return
result
;
}
bool
conf_update_im_server_sock_addr
(
const
char
*
new_sock_addr
)
{
struct
service_arguments
*
conf
=
NULL
;
...
...
@@ -1765,6 +1787,7 @@ int merge_json_confs_into_global(struct service_arguments *args)
goto
out
;
}
override_string_value
(
&
args
->
json_confs
->
default_runtime
,
&
tmp_json_confs
->
default_runtime
);
override_string_value
(
&
args
->
json_confs
->
group
,
&
tmp_json_confs
->
group
);
override_string_value
(
&
args
->
json_confs
->
graph
,
&
tmp_json_confs
->
graph
);
override_string_value
(
&
args
->
json_confs
->
state
,
&
tmp_json_confs
->
state
);
...
...
@@ -1790,6 +1813,9 @@ int merge_json_confs_into_global(struct service_arguments *args)
override_string_value
(
&
args
->
json_confs
->
cni_bin_dir
,
&
tmp_json_confs
->
cni_bin_dir
);
override_string_value
(
&
args
->
json_confs
->
cni_conf_dir
,
&
tmp_json_confs
->
cni_conf_dir
);
args
->
json_confs
->
runtimes
=
tmp_json_confs
->
runtimes
;
tmp_json_confs
->
runtimes
=
NULL
;
// Daemon storage-driver
if
(
merge_storage_conf_into_global
(
args
,
tmp_json_confs
))
{
ret
=
-
1
;
...
...
src/config/isulad_config.h
浏览文件 @
b8cd5aba
...
...
@@ -92,6 +92,8 @@ unsigned int conf_get_im_opt_timeout();
char
*
conf_get_im_server_sock_addr
();
char
*
conf_get_default_runtime
();
bool
conf_update_im_server_sock_addr
(
const
char
*
new_sock_addr
);
char
*
conf_get_graph_check_flag_file
();
...
...
src/connect/client/grpc/grpc_containers_client.cc
浏览文件 @
b8cd5aba
...
...
@@ -230,10 +230,6 @@ public:
{
int
nret
=
-
1
;
if
(
req
.
runtime
().
empty
())
{
ERROR
(
"Missing runtime in the request"
);
return
nret
;
}
if
(
req
.
rootfs
().
empty
()
&&
req
.
image
().
empty
())
{
ERROR
(
"Missing container rootfs or image arguments in the request"
);
return
nret
;
...
...
src/container_def.h
浏览文件 @
b8cd5aba
...
...
@@ -40,7 +40,7 @@ extern "C" {
#define SECCOMP_DEFAULT_PATH "/etc/isulad/seccomp_default.json"
#endif
#ifndef OCI_VERSION
#define OCI_VERSION "1.0.
0-rc5-dev
"
#define OCI_VERSION "1.0.
1
"
#endif
typedef
enum
{
...
...
src/contrib/config/config.json
浏览文件 @
b8cd5aba
{
"ociVersion"
:
"1.0.
0-rc5-dev
"
,
"ociVersion"
:
"1.0.
1
"
,
"process"
:
{
"terminal"
:
true
,
"consoleSize"
:
{
...
...
src/contrib/config/daemon.json
浏览文件 @
b8cd5aba
{
"group"
:
"isulad"
,
"default-runtime"
:
"lcr"
,
"graph"
:
"/var/lib/isulad"
,
"state"
:
"/var/run/isulad"
,
"engine"
:
"lcr"
,
...
...
src/contrib/config/systemcontainer_config.json
浏览文件 @
b8cd5aba
{
"ociVersion"
:
"1.0.
0-rc5-dev
"
,
"ociVersion"
:
"1.0.
1
"
,
"process"
:
{
"terminal"
:
true
,
"consoleSize"
:
{
...
...
src/cutils/utils.c
浏览文件 @
b8cd5aba
...
...
@@ -34,7 +34,6 @@
#include <fcntl.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/types.h>
...
...
src/cutils/utils_file.c
浏览文件 @
b8cd5aba
...
...
@@ -552,7 +552,7 @@ char *util_full_file_digest(const char *filename)
return
full_digest
;
}
static
char
*
util_path_dir
(
const
char
*
path
)
char
*
util_path_dir
(
const
char
*
path
)
{
char
*
dir
=
NULL
;
int
len
=
0
;
...
...
src/cutils/utils_file.h
浏览文件 @
b8cd5aba
...
...
@@ -55,6 +55,8 @@ FILE *util_fopen(const char *filename, const char *mode);
char
*
util_full_file_digest
(
const
char
*
filename
);
char
*
util_path_dir
(
const
char
*
path
);
char
*
util_add_path
(
const
char
*
path
,
const
char
*
name
);
char
*
util_read_text_file
(
const
char
*
path
);
...
...
src/cutils/utils_string.c
浏览文件 @
b8cd5aba
...
...
@@ -79,6 +79,18 @@ bool strings_contains_any(const char *str, const char *substr)
return
false
;
}
bool
strings_contains_word
(
const
char
*
str
,
const
char
*
substr
)
{
if
(
str
==
NULL
||
substr
==
NULL
)
{
return
false
;
}
if
(
strcasestr
(
str
,
substr
)
!=
NULL
)
{
return
true
;
}
return
false
;
}
int
strings_count
(
const
char
*
str
,
unsigned
char
c
)
{
size_t
i
=
0
;
...
...
src/cutils/utils_string.h
浏览文件 @
b8cd5aba
...
...
@@ -25,6 +25,8 @@ extern "C" {
bool
strings_contains_any
(
const
char
*
str
,
const
char
*
substr
);
bool
strings_contains_word
(
const
char
*
str
,
const
char
*
substr
);
int
strings_count
(
const
char
*
str
,
unsigned
char
c
);
bool
strings_in_slice
(
const
char
**
strarray
,
size_t
alen
,
const
char
*
str
);
...
...
src/cutils/utils_verify.c
浏览文件 @
b8cd5aba
...
...
@@ -274,7 +274,7 @@ bool util_valid_runtime_name(const char *name)
return
false
;
}
return
strcasecmp
(
name
,
"lcr"
)
==
0
;
return
true
;
}
bool
util_valid_host_name
(
const
char
*
name
)
...
...
src/json/schema/schema/defs.json
浏览文件 @
b8cd5aba
...
...
@@ -232,6 +232,25 @@
}
}
},
"mapStringObjectRuntimes"
:
{
"type"
:
"object"
,
"patternProperties"
:
{
".{1,}"
:
{
"type"
:
"object"
,
"properties"
:
{
"path"
:
{
"type"
:
"string"
},
"runtime-args"
:
{
"type"
:
"array"
,
"items"
:
{
"type"
:
"string"
}
}
}
}
}
},
"ociVersion"
:
{
"description"
:
"The version of Open Container Runtime Specification that the document complies with"
,
"type"
:
"string"
...
...
src/json/schema/schema/isulad-daemon-configs.json
浏览文件 @
b8cd5aba
...
...
@@ -5,6 +5,9 @@
"hosts"
:
{
"type"
:
"ArrayOfStrings"
},
"default-runtime"
:
{
"type"
:
"string"
},
"group"
:
{
"type"
:
"string"
},
...
...
@@ -144,6 +147,9 @@
}
}
}
},
"runtimes"
:
{
"$ref"
:
"defs.json#/definitions/mapStringObjectRuntimes"
}
}
}
src/services/cri/cri_container.cc
浏览文件 @
b8cd5aba
...
...
@@ -155,6 +155,19 @@ container_config *CRIRuntimeServiceImpl::GenerateCreateContainerCustomConfig(
}
}
if
(
append_json_map_string_string
(
custom_config
->
annotations
,
CRIHelpers
::
Constants
::
CONTAINER_TYPE_ANNOTATION_KEY
.
c_str
(),
CRIHelpers
::
Constants
::
CONTAINER_TYPE_ANNOTATION_CONTAINER
.
c_str
()))
{
error
.
SetError
(
"Append map string string failed"
);
goto
cleanup
;
}
if
(
append_json_map_string_string
(
custom_config
->
annotations
,
CRIHelpers
::
Constants
::
SANDBOX_ID_ANNOTATION_KEY
.
c_str
(),
realPodSandboxID
.
c_str
()))
{
error
.
SetError
(
"Append map string string failed"
);
goto
cleanup
;
}
if
(
append_json_map_string_string
(
custom_config
->
labels
,
CRIHelpers
::
Constants
::
SANDBOX_ID_LABEL_KEY
.
c_str
(),
realPodSandboxID
.
c_str
()))
{
error
.
SetError
(
"Append map string string failed"
);
...
...
@@ -301,8 +314,6 @@ container_create_request *CRIRuntimeServiceImpl::GenerateCreateContainerRequest(
std
::
string
cname
=
CRINaming
::
MakeContainerName
(
podSandboxConfig
,
containerConfig
);
request
->
id
=
util_strdup_s
(
cname
.
c_str
());
request
->
runtime
=
util_strdup_s
(
CRIHelpers
::
Constants
::
DEFAULT_RUNTIME_NAME
.
c_str
());
if
(
!
containerConfig
.
image
().
image
().
empty
())
{
request
->
image
=
util_strdup_s
(
containerConfig
.
image
().
image
().
c_str
());
}
...
...
src/services/cri/cri_helpers.cc
浏览文件 @
b8cd5aba
...
...
@@ -45,6 +45,10 @@ const std::string Constants::DOCKER_PULLABLE_IMAGEID_PREFIX { "docker-pullable:/
const
std
::
string
Constants
::
RUNTIME_READY
{
"RuntimeReady"
};
const
std
::
string
Constants
::
NETWORK_READY
{
"NetworkReady"
};
const
std
::
string
Constants
::
POD_CHECKPOINT_KEY
{
"cri.sandbox.isulad.checkpoint"
};
const
std
::
string
Constants
::
CONTAINER_TYPE_ANNOTATION_KEY
{
"io.kubernetes.cri.container-type"
};
const
std
::
string
Constants
::
CONTAINER_TYPE_ANNOTATION_CONTAINER
{
"container"
};
const
std
::
string
Constants
::
CONTAINER_TYPE_ANNOTATION_SANDBOX
{
"sandbox"
};
const
std
::
string
Constants
::
SANDBOX_ID_ANNOTATION_KEY
{
"io.kubernetes.cri.sandbox-id"
};
const
char
*
InternalLabelKeys
[]
=
{
CRIHelpers
::
Constants
::
CONTAINER_TYPE_LABEL_KEY
.
c_str
(),
...
...
src/services/cri/cri_helpers.h
浏览文件 @
b8cd5aba
...
...
@@ -49,6 +49,10 @@ public:
static
const
std
::
string
NETWORK_READY
;
static
const
std
::
string
POD_CHECKPOINT_KEY
;
static
const
size_t
MAX_CHECKPOINT_KEY_LEN
{
250
};
static
const
std
::
string
CONTAINER_TYPE_ANNOTATION_KEY
;
static
const
std
::
string
CONTAINER_TYPE_ANNOTATION_CONTAINER
;
static
const
std
::
string
CONTAINER_TYPE_ANNOTATION_SANDBOX
;
static
const
std
::
string
SANDBOX_ID_ANNOTATION_KEY
;
};
std
::
string
GetDefaultSandboxImage
(
Errors
&
err
);
...
...
src/services/cri/cri_sandbox.cc
浏览文件 @
b8cd5aba
...
...
@@ -217,6 +217,12 @@ void CRIRuntimeServiceImpl::MakeSandboxIsuladConfig(const runtime::v1alpha2::Pod
if
(
error
.
NotEmpty
())
{
return
;
}
if
(
append_json_map_string_string
(
custom_config
->
annotations
,
CRIHelpers
::
Constants
::
CONTAINER_TYPE_ANNOTATION_KEY
.
c_str
(),
CRIHelpers
::
Constants
::
CONTAINER_TYPE_ANNOTATION_SANDBOX
.
c_str
())
!=
0
)
{
error
.
SetError
(
"Append container type into annotation failed"
);
return
;
}
if
(
!
c
.
hostname
().
empty
())
{
custom_config
->
hostname
=
util_strdup_s
(
c
.
hostname
().
c_str
());
...
...
@@ -323,7 +329,6 @@ container_create_request *CRIRuntimeServiceImpl::PackCreateContainerRequest(
std
::
string
sandboxName
=
CRINaming
::
MakeSandboxName
(
config
.
metadata
());
create_request
->
id
=
util_strdup_s
(
sandboxName
.
c_str
());
create_request
->
runtime
=
util_strdup_s
(
CRIHelpers
::
Constants
::
DEFAULT_RUNTIME_NAME
.
c_str
());
create_request
->
image
=
util_strdup_s
(
image
.
c_str
());
create_request
->
hostconfig
=
host_config_generate_json
(
hostconfig
,
&
ctx
,
&
perror
);
...
...
src/services/execution/execute/execution_create.c
浏览文件 @
b8cd5aba
...
...
@@ -44,6 +44,56 @@
#include "error.h"
#include "constants.h"
static
int
runtime_check
(
const
char
*
name
,
bool
*
runtime_res
)
{
int
ret
=
0
;
struct
service_arguments
*
args
=
NULL
;
defs_map_string_object_runtimes
*
runtimes
=
NULL
;
if
(
isulad_server_conf_rdlock
())
{
ret
=
-
1
;
goto
out
;
}
args
=
conf_get_server_conf
();
if
(
args
==
NULL
)
{
ERROR
(
"Failed to get isulad server config"
);
ret
=
-
1
;
goto
unlock_out
;
}
if
(
args
->
json_confs
!=
NULL
)
{
runtimes
=
args
->
json_confs
->
runtimes
;
}
if
(
runtimes
==
NULL
)
{
EVENT
(
"isulad runtimes param is null"
);
goto
unlock_out
;
}
size_t
runtime_nums
=
runtimes
->
len
;
for
(
size_t
i
=
0
;
i
<
runtime_nums
;
i
++
)
{
if
(
strcmp
(
name
,
runtimes
->
keys
[
i
])
==
0
)
{
*
runtime_res
=
true
;
goto
unlock_out
;
}
}
unlock_out:
if
(
isulad_server_conf_unlock
())
{
ERROR
(
"Failed to unlock isulad server config"
);
ret
=
-
1
;
}
out:
if
(
strcmp
(
name
,
"runc"
)
==
0
||
strcmp
(
name
,
"lcr"
)
==
0
)
{
*
runtime_res
=
true
;
}
if
(
strcmp
(
name
,
"kata-runtime"
)
==
0
)
{
*
runtime_res
=
true
;
}
return
ret
;
}
static
int
create_request_check
(
const
container_create_request
*
request
)
{
int
ret
=
0
;
...
...
@@ -68,20 +118,6 @@ static int create_request_check(const container_create_request *request)
goto
out
;
}
if
(
request
->
runtime
==
NULL
)
{
ERROR
(
"Receive NULL Request runtime"
);
ret
=
-
1
;
goto
out
;
}
if
(
!
util_valid_runtime_name
(
request
->
runtime
))
{
ERROR
(
"Invalid runtime name:%s"
,
request
->
runtime
);
isulad_set_error_message
(
"Invalid runtime name (%s), only
\"
lcr
\"
supported."
,
request
->
runtime
);
ret
=
-
1
;
goto
out
;
}
if
(
request
->
hostconfig
==
NULL
)
{
ERROR
(
"Receive NULL Request hostconfig"
);
ret
=
-
1
;
...
...
@@ -685,12 +721,30 @@ static int get_request_image_info(const container_create_request *request, char
static
int
preparate_runtime_environment
(
const
container_create_request
*
request
,
const
char
*
id
,
char
**
runtime
,
char
**
runtime_root
,
uint32_t
*
cc
)
{
*
runtime
=
get_runtime_from_request
(
request
);
bool
runtime_res
=
false
;
if
(
request
->
runtime
)
{
*
runtime
=
get_runtime_from_request
(
request
);
}
else
{
*
runtime
=
conf_get_default_runtime
();
}
if
(
*
runtime
==
NULL
)
{
*
cc
=
ISULAD_ERR_INPUT
;
return
-
1
;
}
if
(
runtime_check
(
*
runtime
,
&
runtime_res
)
!=
0
)
{
ERROR
(
"Runtimes param check failed"
);
return
-
1
;
}
if
(
!
runtime_res
)
{
ERROR
(
"Invalid runtime name:%s"
,
*
runtime
);
isulad_set_error_message
(
"Invalid runtime name (%s)."
,
*
runtime
);
return
-
1
;
}
*
runtime_root
=
conf_get_routine_rootdir
(
*
runtime
);
if
(
*
runtime_root
==
NULL
)
{
*
cc
=
ISULAD_ERR_EXEC
;
...
...
src/services/execution/manager/health_check.c
浏览文件 @
b8cd5aba
...
...
@@ -559,7 +559,7 @@ void *health_check_run(void *arg)
container_req
->
tty
=
false
;
container_req
->
attach_stdin
=
false
;
container_req
->
attach_stdout
=
true
;
container_req
->
attach_stderr
=
tru
e
;
container_req
->
attach_stderr
=
fals
e
;
container_req
->
timeout
=
timeout_with_default
(
config
->
health_check
->
timeout
,
DEFAULT_PROBE_TIMEOUT
)
/
Time_Second
;
container_req
->
container_id
=
util_strdup_s
(
cont
->
common_config
->
id
);
container_req
->
argv
=
cmd_slice
;
...
...
test/image/oci/oci_config_merge/oci_runtime_spec.json
浏览文件 @
b8cd5aba
{
"ociVersion"
:
"1.0.
0-rc5-dev
"
,
"ociVersion"
:
"1.0.
1
"
,
"hooks"
:
{
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录