Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
c043e010
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,发现更多精彩内容 >>
提交
c043e010
编写于
4月 02, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
4月 02, 2020
浏览文件
操作
浏览文件
下载
差异文件
!150 adapt CNI of K8S 1.15
Merge pull request !150 from haozi007/newwork
上级
9c02d230
91f58029
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
825 addition
and
207 deletion
+825
-207
CI/build.sh
CI/build.sh
+1
-0
CI/install_depends.sh
CI/install_depends.sh
+28
-1
CI/test_cases/basic_cases/cni_test.bash
CI/test_cases/basic_cases/cni_test.bash
+146
-0
CI/test_cases/basic_cases/criconfigs/bins/isulad-cni
CI/test_cases/basic_cases/criconfigs/bins/isulad-cni
+23
-0
CI/test_cases/basic_cases/criconfigs/bridge.json
CI/test_cases/basic_cases/criconfigs/bridge.json
+10
-0
CI/test_cases/basic_cases/criconfigs/container-config.json
CI/test_cases/basic_cases/criconfigs/container-config.json
+45
-0
CI/test_cases/basic_cases/criconfigs/good.conflist
CI/test_cases/basic_cases/criconfigs/good.conflist
+20
-0
CI/test_cases/basic_cases/criconfigs/invalid.conflist
CI/test_cases/basic_cases/criconfigs/invalid.conflist
+18
-0
CI/test_cases/basic_cases/criconfigs/sandbox-config.json
CI/test_cases/basic_cases/criconfigs/sandbox-config.json
+11
-0
CI/test_cases/helpers.bash
CI/test_cases/helpers.bash
+284
-0
src/services/cri/cni_network_plugin.cc
src/services/cri/cni_network_plugin.cc
+150
-135
src/services/cri/cni_network_plugin.h
src/services/cri/cni_network_plugin.h
+42
-23
src/services/cri/cri_helpers.cc
src/services/cri/cri_helpers.cc
+2
-0
src/services/cri/cri_helpers.h
src/services/cri/cri_helpers.h
+4
-0
src/services/cri/cri_runtime_service.cc
src/services/cri/cri_runtime_service.cc
+2
-5
src/services/cri/cri_runtime_service.h
src/services/cri/cri_runtime_service.h
+1
-1
src/services/cri/cri_sandbox.cc
src/services/cri/cri_sandbox.cc
+13
-22
src/services/cri/network_plugin.cc
src/services/cri/network_plugin.cc
+12
-10
src/services/cri/network_plugin.h
src/services/cri/network_plugin.h
+12
-9
test/test.sh
test/test.sh
+1
-1
未找到文件。
CI/build.sh
浏览文件 @
c043e010
...
...
@@ -343,6 +343,7 @@ done
for
container
in
${
containers
[@]
}
do
{
docker
cp
${
cptemp
}
/cni
${
container
}
:/opt
docker
cp
${
cptemp
}
/bin
${
container
}
:/usr
docker
cp
${
cptemp
}
/etc
${
container
}
:/
docker
cp
${
cptemp
}
/usr/bin
${
container
}
:/usr
...
...
CI/install_depends.sh
浏览文件 @
c043e010
...
...
@@ -25,7 +25,9 @@ buildstatus=${builddir}/build.fail
declare
-a
buildlogs
build_log_isulad_img
=
${
builddir
}
/build.isulad_img.log
buildlogs+
=(
${
build_log_isulad_img
}
)
build_log_crictl
=
${
builddir
}
/build.crictl.log
build_log_cni_plugins
=
${
builddir
}
/build.cni_plugins.log
buildlogs+
=(
${
build_log_isulad_img
}
${
build_log_crictl
}
${
build_log_cni_plugins
}
)
mkdir
-p
${
builddir
}
/rpm
mkdir
-p
${
builddir
}
/bin
...
...
@@ -45,6 +47,29 @@ function make_isulad_img()
make
DESTDIR
=
${
builddir
}
install
}
#install crictl
function
make_crictl
()
{
cd
~
git clone
-b
release-1.14 https://gitee.com/duguhaotian/cri-tools.git
cd
cri-tools
make
-j
$nproc
cp
./_output/bin/crictl
${
builddir
}
/bin/
}
#install cni plugins
function
make_cni_plugins
()
{
local
CNI_PLUGINS_COMMIT
=
b93d284d18dfc8ba93265fa0aa859c7e92df411b
cd
~
git clone https://gitee.com/duguhaotian/plugins.git
cd
plugins
git checkout
-q
"
$CNI_PLUGINS_COMMIT
"
./build.sh
mkdir
-p
${
builddir
}
/cni/bin/
cp
bin/
*
${
builddir
}
/cni/bin/
}
function
check_make_status
()
{
set
+e
...
...
@@ -61,6 +86,8 @@ function check_make_status()
rm
-rf
${
buildstatus
}
check_make_status make_isulad_img
${
build_log_isulad_img
}
&
check_make_status make_crictl
${
build_log_crictl
}
&
check_make_status make_cni_plugins
${
build_log_cni_plugins
}
&
# install lxc
cd
~
...
...
CI/test_cases/basic_cases/cni_test.bash
0 → 100644
浏览文件 @
c043e010
#!/bin/bash
#
# attributes: isulad cri cni
# concurrent: NA
# spend time: 10
curr_path
=
$(
dirname
$(
readlink
-f
"
$0
"
))
data_path
=
$(
realpath
$curr_path
/criconfigs
)
source
../helpers.bash
function
do_pre
()
{
cp
/etc/isulad/daemon.json /etc/isulad/daemon.bak
sed
-i
"s#
\"
pod-sandbox-image
\"
:
\"\"
#
\"
pod-sandbox-image
\"
:
\"
rancher/pause-amd64:3.0
\"
#g"
/etc/isulad/daemon.json
init_cni_conf
$data_path
if
[
$?
-ne
0
]
;
then
ERROR
"Failed to init cni config"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
return
$TC_RET_T
fi
}
function
do_post
()
{
cp
-f
/etc/isulad/daemon.bak /etc/isulad/daemon.json
stop_isulad_without_valgrind
start_isulad_without_valgrind
}
function
do_test_help
()
{
INFO
"this is
$0
do_test"
crictl images |
grep
busybox
if
[
$?
-ne
0
]
;
then
ERROR
"Failed to find busybox image"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
sid
=
`
crictl runp
${
data_path
}
/sandbox-config.json
`
if
[
$?
-ne
0
]
;
then
ERROR
"Failed to run sandbox"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
spid
=
`
isula inspect
-f
'{{json .State.Pid}}'
$sid
`
nsenter
-t
$spid
-n
ifconfig eth0
if
[
$?
-ne
0
]
;
then
ERROR
"Sandbox network config failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
cid
=
`
crictl create
$sid
${
data_path
}
/container-config.json
${
data_path
}
/sandbox-config.json
`
if
[
$?
-ne
0
]
;
then
ERROR
"create container failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
crictl start
$cid
if
[
$?
-ne
0
]
;
then
ERROR
"start container failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
# check whether container use pod network namespace
pod_pid
=
`
isula inspect
-f
'{{json .State.Pid}}'
$sid
`
pod_net_ns_id
=
`
ls
-l
/proc/
${
pod_pid
}
/ns/net |
awk
-F
[
'{print $2}'
|awk
-F
]
'{print $1}'
`
con_pid
=
`
isula inspect
-f
'{{json .State.Pid}}'
$cid
`
con_net_ns_id
=
`
ls
-l
/proc/
${
con_pid
}
/ns/net |
awk
-F
[
'{print $2}'
|awk
-F
]
'{print $1}'
`
if
[
"
$pod_net_ns_id
"
!=
"
$con_net_ns_id
"
]
;
then
ERROR
"Pod and container use different network namespace"
nsenter
-t
$pod_pid
-n
ifconfig eth0
nsenter
-t
$con_pid
-n
ifconfig eth0
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
nsenter
-t
$pod_pid
-n
ifconfig eth0 |
grep
"
$1
"
if
[
$?
-ne
0
]
;
then
ERROR
"expect ip:
$1
, get: "
nsenter
-t
$pod_pid
-n
ifconfig eth0
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
crictl stop
$cid
if
[
$?
-ne
0
]
;
then
ERROR
"stop container failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
crictl
rm
$cid
if
[
$?
-ne
0
]
;
then
ERROR
"stop container failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
crictl stopp
$sid
if
[
$?
-ne
0
]
;
then
ERROR
"stop sandbox failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
crictl rmp
$sid
if
[
$?
-ne
0
]
;
then
ERROR
"rm sandbox failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
return
$TC_RET_T
}
function
default_cni_config
()
{
do_test_help
"10
\.
1
\.
"
}
function
new_cni_config
()
{
cp
${
data_path
}
/bridge.json /etc/cni/net.d/
# wait cni updated
crictl info
sync
;
sync
;
sleep
2
do_test_help
"10
\.
2
\.
"
}
ret
=
0
do_pre
if
[
$?
-ne
0
]
;
then
let
"ret=
$ret
+ 1"
fi
default_cni_config
if
[
$?
-ne
0
]
;
then
let
"ret=
$ret
+ 1"
fi
new_cni_config
if
[
$?
-ne
0
]
;
then
let
"ret=
$ret
+ 1"
fi
do_post
show_result
$ret
"cni base test"
CI/test_cases/basic_cases/criconfigs/bins/isulad-cni
0 → 100755
浏览文件 @
c043e010
#!/bin/bash
basepath
=
/tmp/cnilogs/
mkdir
-p
$basepath
secs
=
`
date
"+%s"
`
confpath
=
${
basepath
}
/
${
secs
}
.netconf
envpath
=
${
basepath
}
/
${
secs
}
.env
env
|
grep
CNI_CONTAINERID
>
/dev/null 2>&1
if
[
$?
-eq
0
]
;
then
confpath
=
${
basepath
}
/
${
CNI_CONTAINERID
}
.netconf
envpath
=
${
basepath
}
/
${
CNI_CONTAINERID
}
.env
fi
read
-r
line
echo
$line
>
${
confpath
}
env
>
${
envpath
}
echo
"{
\"
cniVersion
\"
:
\"
0.3.1
\"
,
\"
dns
\"
: {}
}"
CI/test_cases/basic_cases/criconfigs/bridge.json
0 → 100644
浏览文件 @
c043e010
{
"cniVersion"
:
"0.3.0"
,
"name"
:
"ok"
,
"type"
:
"bridge"
,
"bridge"
:
"cni0"
,
"ipam"
:
{
"type"
:
"host-local"
,
"subnet"
:
"10.2.0.0/16"
}
}
CI/test_cases/basic_cases/criconfigs/container-config.json
0 → 100644
浏览文件 @
c043e010
{
"metadata"
:
{
"name"
:
"haozi"
},
"image"
:{
"image"
:
"busybox:latest"
},
"command"
:
[
"/bin/sh"
,
"-c"
,
"i=0; while true; do echo
\"
$i: $(date)
\"
; i=$((i+1)); sleep 10; done"
],
"labels"
:
{
"filter_label_key"
:
"filter_label_val"
},
"annotations"
:
{
"extension.network.kubernetes.io/cni/instancename"
:
"pod_instance_name"
},
"mounts"
:
[
{
"container_path"
:
"/tmp/contpath"
,
"host_path"
:
"/tmp/hostpath"
,
"readonly"
:
true
,
"selinux_relabel"
:
true
,
"propagation"
:
0
},
{
"container_path"
:
"/tmp/contpath2"
,
"host_path"
:
"/tmp/hostpath2"
,
"readonly"
:
false
,
"selinux_relabel"
:
false
,
"propagation"
:
0
}
],
"linux"
:
{
"security_context"
:
{
"namespace_options"
:
{
"host_network"
:
true
,
"host_pid"
:
false
,
"host_ipc"
:
false
}
}
},
"log_path"
:
"cri_test.log"
}
CI/test_cases/basic_cases/criconfigs/good.conflist
0 → 100644
浏览文件 @
c043e010
{
"cniVersion": "0.3.1",
"name": "good",
"plugins": [
{
"name": "good",
"type": "ptp",
"ipam": {
"type": "host-local",
"subnet": "10.1.0.0/16"
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
}
]
}
CI/test_cases/basic_cases/criconfigs/invalid.conflist
0 → 100644
浏览文件 @
c043e010
{
"cniVersion": "0.3.1",
"name": 666,
"plugins": [
{
"name": "default",
"type": "ptp",
"ipam": {
"type": "host-local",
"subnet": "10.1.0.0/16"
}
},
{
"type": "portmap",
"capabilities": {"portMappings": true}
}
]
}
CI/test_cases/basic_cases/criconfigs/sandbox-config.json
0 → 100644
浏览文件 @
c043e010
{
"port_mappings"
:[{
"protocol"
:
1
,
"container_port"
:
80
,
"host_port"
:
8080
}],
"metadata"
:
{
"name"
:
"test"
,
"namespace"
:
"default"
,
"attempt"
:
1
,
"uid"
:
"hdishd83djaidwnduwk28bcsb"
},
"linux"
:
{
}
}
CI/test_cases/helpers.bash
0 → 100755
浏览文件 @
c043e010
#!/bin/bash
set
-x
CRICTL
=
$(
which crictl
)
# testcase result
TC_RET_T
=
0
# image to pull and run container
BUSYBOX_IMAGE
=
"busybox:latest"
PAUSE_IMAGE
=
"rancher/pause-amd64:3.0"
valgrind_log
=
"/tmp/valgrind.log"
ISUALD_LOG
=
"/var/lib/isulad/isulad.log"
ISULAD_ROOT_DIR
=
"/var/lib/isulad"
ISULAD_LCR_ENGINE_DIR
=
"
$ISULAD_ROOT_DIR
/engines/lcr"
kubeAPIVersion
=
"0.1.0"
iSulaRuntimeName
=
"iSulad"
RuntimeVersion
=
"2.0"
RuntimeAPIVersion
=
"1.0"
Logging_Driver
=
"json-file"
Cgroup_Driver
=
"cgroupfs"
# ===================================================
function
echo_text
()
{
local
TXT
=
$1
local
COLOR
=
$2
if
[
"
${
COLOR
}
"
=
"red"
]
;
then
echo
-e
"
\e
[1;31m
${
TXT
}
\e
[0m"
elif
[
"
${
COLOR
}
"
=
"green"
]
;
then
echo
-e
"
\e
[1;32m
${
TXT
}
\e
[0m"
elif
[
"
${
COLOR
}
"
=
"yellow"
]
;
then
echo
-e
"
\e
[1;33m
${
TXT
}
\e
[0m"
else
echo
${
TXT
}
fi
}
function
ERROR
()
{
txt_str
=
$1
echo_text
"
$txt_str
"
red
}
function
INFO
()
{
txt_str
=
$1
echo_text
"
$txt_str
"
green
}
function
DEBUG
()
{
txt_str
=
$1
echo_text
"
$txt_str
"
yellow
}
# ===============================================
function
is_new_oci_image
()
{
ps aux |
grep
"isulad_kit"
|
grep
"isula_image
\.
sock"
>
/dev/null 2>&1
if
[
$?
-ne
0
]
;
then
DEBUG
"Current use old oci image mechanism, Skip this testcase......"
exit
0
fi
}
function
check_fn_return
()
{
if
[[
"
$1
"
!=
"
$2
"
]]
;
then
ERROR
"[
`
date
`
] Expect '
$1
' but got '
$2
': FAILED (
$3
)"
((
TC_RET_T++
))
else
INFO
"[
`
date
`
] Expect '
$1
' and got '
$2
': SUCCESS (
$3
)"
fi
}
function
check_fn_return_noskip
()
{
if
[[
"
$1
"
!=
"
$2
"
]]
;
then
ERROR
"[
`
date
`
] Expect '
$1
' but got '
$2
': FAILED (
$3
)"
exit
1
else
INFO
"[
`
date
`
] Expect '
$1
' and got '
$2
': SUCCESS (
$3
)"
fi
}
function
isulad_is_running
()
{
local
ret
=
1
for
i
in
`
seq
3
`
;
do
isula version
if
[
$?
-eq
0
]
;
then
ret
=
0
break
fi
sleep
1
done
return
${
ret
}
}
function
wait_isulad_running
()
{
echo
"-------waiting iSulad running--------"
waitcnt
=
0
maxcnt
=
60
while
[
0
]
do
isula version
if
[
$?
-eq
0
]
;
then
break
fi
if
[
$waitcnt
-gt
$maxcnt
]
;
then
echo
"iSulad is not running after
${
maxcnt
}
s"
return
1
fi
waitcnt
=
$((
$waitcnt
+
1
))
sleep
1
done
echo
"--------iSulad is running-----------"
}
function
start_isulad_with_valgrind
()
{
valgrind
--fair-sched
=
yes
--log-file
=
$valgrind_log
--tool
=
memcheck
--leak-check
=
yes
-v
--track-origins
=
yes
isulad
$@
-l
DEBUG
>
/dev/null 2>&1 &
wait_isulad_running
}
function
start_isulad_without_valgrind
()
{
isulad
$@
-l
DEBUG
>
/dev/null 2>&1 &
wait_isulad_running
}
function
check_isulad_stopped
()
{
maxtimes
=
15
curcnt
=
0
spid
=
$1
while
[
$curcnt
-lt
$maxtimes
]
do
ps aux |
grep
isulad |
grep
-v
"grep"
|
grep
-w
$spid
if
[
$?
-ne
0
]
;
then
return
0
fi
let
"curcnt=
$curcnt
+ 1"
sleep
1
done
return
1
}
function
stop_isulad_without_valgrind
()
{
pid
=
`
cat
/var/run/isulad.pid
`
kill
-15
$pid
check_isulad_stopped
$pid
if
[
$?
-ne
0
]
;
then
echo
"iSulad process is still alive"
return
1
fi
return
0
}
function
check_valgrind_log
()
{
pid
=
`
cat
/var/run/isulad.pid
`
kill
-15
$pid
check_isulad_stopped
$pid
if
[
$?
-ne
0
]
;
then
echo
"Stop iSulad with valgrind failed"
kill
-9
$pid
sleep
1
fi
cat
$valgrind_log
|
grep
"are definitely lost"
|
grep
$pid
if
[
$?
-eq
0
]
;
then
echo
"Memory leak may checked by valgrind, see valgrind log file:
$valgrind_log
"
sed
-n
'/definitely lost/,// p'
$valgrind_log
exit
1
fi
return
0
}
# Wrapper for crictl
function
crictl
()
{
"
$CRICTL
"
-i
unix:///var/run/isulad.sock
-r
unix:///var/run/isulad.sock
"
$@
"
}
function
get_cgroup_real_path
()
{
cat
/proc/1/cgroup |
head
-n
1 |
awk
-F
':'
'{print $3}'
}
function
get_container_interface_ip_by_pid
()
{
if
[
$#
-ne
2
]
;
then
return
""
fi
nsenter
-t
$1
-n
ifconfig
$2
|
grep
'inet '
|
sed
's/netmask.*//g'
|
grep
-Eoe
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])
\.
){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"
}
function
set_ip_for_cni_bridge
()
{
if
[
$#
-ne
2
]
;
then
echo
"set_ip_for_cni_bridge: invalid arguments, usage: set_ip_for_cni_bridge cni0 10.1.0.1"
return
1
fi
ifconfig
$1
$2
}
function
show_result
()
{
if
[
$1
-ne
0
]
;
then
echo
"TESTSUIT:
$2
FAILED"
return
1
fi
echo
"TESTSUIT:
$2
SUCCESS"
}
function
msleep
()
{
if
[
$#
-ne
1
]
;
then
echo
"use default sleep"
sleep
$@
return
fi
sec
=
$1
env
|
grep
GCOV
if
[
$?
-eq
0
]
;
then
((
sec
=
$sec
+2
))
fi
sleep
$sec
}
function
err
()
{
echo
"[
$(
date
+
'%Y-%m-%dT%H:%M:%S%z'
)
]:
$@
"
>
&2
}
function
init_cni_conf
()
{
dtpath
=
"
$1
"
mkdir
-p
/etc/cni/net.d/
rm
-rf
/etc/cni/net.d/
*
mkdir
-p
/opt/cni/bin
cp
$dtpath
/bins/isulad-cni /opt/cni/bin
cp
$dtpath
/good.conflist /etc/cni/net.d/
stop_isulad_without_valgrind
if
[
$?
-ne
0
]
;
then
echo
"stop isulad failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
start_isulad_without_valgrind
--network-plugin
cni
if
[
$?
-ne
0
]
;
then
echo
"start failed"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
return
$TC_RET_T
}
function
wait_container_state
()
{
while
true
do
isula inspect
-f
'{{json .State.Status}}'
"
$1
"
|
grep
"
$2
"
if
[
$?
-eq
0
]
;
then
return
;
fi
sleep
1
done
}
function
pull_images
()
{
isula inspect
$BUSYBOX_IMAGE
>
/dev/null
if
[
$?
-ne
0
]
;
then
isula pull
$BUSYBOX_IMAGE
if
[
$?
-ne
0
]
;
then
echo
"failed pull busybox image"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
fi
isula inspect
$PAUSE_IMAGE
>
/dev/null
if
[
$?
-ne
0
]
;
then
isula pull
$PAUSE_IMAGE
if
[
$?
-ne
0
]
;
then
echo
"failed pull pause image"
TC_RET_T
=
$((
$TC_RET_T
+
1
))
fi
fi
return
$TC_RET_T
}
pull_images
src/services/cri/cni_network_plugin.cc
浏览文件 @
c043e010
...
...
@@ -19,21 +19,18 @@
#include <vector>
#include <utility>
#include <set>
#include <chrono>
#include "cxxutils.h"
#include "log.h"
#include "utils.h"
#include "cri_helpers.h"
namespace
Network
{
static
std
::
string
VendorCNIDir
(
const
std
::
string
&
prefix
,
const
std
::
string
&
pluginType
)
{
return
prefix
+
"/opt/"
+
pluginType
+
"/bin"
;
}
static
std
::
unique_ptr
<
CNINetwork
>
GetLoNetwork
(
const
std
::
string
&
binDir
,
const
std
::
string
&
vendorDirPrefix
)
static
std
::
unique_ptr
<
CNINetwork
>
GetLoNetwork
(
std
::
vector
<
std
::
string
>
binDirs
,
const
std
::
string
&
vendorDirPrefix
)
{
const
std
::
string
loNetConfListJson
{
"{
\"
cniVersion
\"
:
\"
0.3.0
\"
,
\"
name
\"
:
\"
cni-loopback
\"
,"
"
\"
plugins
\"
:[{
\"
type
\"
:
\"
loopback
\"
}]}"
};
"
\"
plugins
\"
:[{
\"
type
\"
:
\"
loopback
\"
}]}"
};
char
*
cerr
{
nullptr
};
struct
cni_network_list_conf
*
loConf
{
...
...
@@ -62,8 +59,7 @@ static std::unique_ptr<CNINetwork> GetLoNetwork(const std::string &binDir, const
return
nullptr
;
}
result
->
InsertPath
(
VendorCNIDir
(
vendorDirPrefix
,
"loopback"
));
result
->
InsertPath
(
binDir
);
result
->
SetPaths
(
binDirs
);
return
result
;
}
...
...
@@ -92,8 +88,9 @@ void ProbeNetworkPlugins(const std::string &pluginDir, const std::string &binDir
std
::
vector
<
std
::
shared_ptr
<
NetworkPlugin
>>
*
plugins
)
{
const
std
::
string
useBinDir
=
binDir
.
empty
()
?
DEFAULT_CNI_DIR
:
binDir
;
auto
plugin
=
std
::
make_shared
<
CniNetworkPlugin
>
(
useBinDir
,
pluginDir
);
plugin
->
SetLoNetwork
(
GetLoNetwork
(
useBinDir
,
""
));
std
::
vector
<
std
::
string
>
binDirs
=
CXXUtils
::
Split
(
useBinDir
,
','
);
auto
plugin
=
std
::
make_shared
<
CniNetworkPlugin
>
(
binDirs
,
pluginDir
);
plugin
->
SetLoNetwork
(
GetLoNetwork
(
binDirs
,
""
));
plugins
->
push_back
(
plugin
);
}
...
...
@@ -104,17 +101,28 @@ void CniNetworkPlugin::SetLoNetwork(std::unique_ptr<CNINetwork> lo)
}
}
CniNetworkPlugin
::
CniNetworkPlugin
(
const
std
::
string
&
binDir
,
const
std
::
string
&
pluginDir
,
const
std
::
string
&
vendorCNIDirPrefix
)
:
m_pluginDir
(
pluginDir
)
,
m_vendorCNIDirPrefix
(
vendorCNIDirPrefix
)
,
m_binDir
(
binDir
)
void
CniNetworkPlugin
::
SetDefaultNetwork
(
std
::
unique_ptr
<
CNINetwork
>
network
)
{
if
(
network
!=
nullptr
)
{
m_defaultNetwork
=
std
::
move
(
network
);
}
}
CniNetworkPlugin
::
CniNetworkPlugin
(
std
::
vector
<
std
::
string
>
&
binDirs
,
const
std
::
string
&
confDir
,
const
std
::
string
&
podCidr
)
:
m_confDir
(
confDir
)
,
m_binDirs
(
binDirs
)
,
m_podCidr
(
podCidr
)
,
m_needFinish
(
false
)
{
}
CniNetworkPlugin
::~
CniNetworkPlugin
()
{
m_networks
.
clear
();
m_needFinish
=
true
;
if
(
m_syncThread
.
joinable
())
{
m_syncThread
.
join
();
}
}
void
CniNetworkPlugin
::
PlatformInit
(
Errors
&
error
)
...
...
@@ -232,65 +240,16 @@ out:
return
ret
;
}
int
CniNetworkPlugin
::
InsertNewNetwork
(
struct
cni_network_list_conf
*
n_list
,
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
CNINetwork
>>
&
newNets
,
const
std
::
string
&
binDir
,
const
std
::
string
&
vendorCNIDirPrefix
,
Errors
&
err
)
{
std
::
string
confType
{
""
};
if
(
n_list
==
nullptr
)
{
err
.
Errorf
(
"Invalid arguments"
);
return
-
1
;
}
if
(
n_list
->
first_plugin_type
!=
nullptr
)
{
confType
=
n_list
->
first_plugin_type
;
}
std
::
string
tpath
=
VendorCNIDir
(
vendorCNIDirPrefix
,
confType
);
if
(
tpath
.
empty
())
{
free_cni_network_list_conf
(
n_list
);
err
.
SetError
(
"Out of memory"
);
return
-
1
;
}
std
::
unique_ptr
<
CNINetwork
>
network
(
new
(
std
::
nothrow
)
CNINetwork
(
n_list
->
name
,
n_list
));
if
(
network
==
nullptr
)
{
free_cni_network_list_conf
(
n_list
);
err
.
SetError
(
"Out of memory"
);
return
-
1
;
}
network
->
InsertPath
(
tpath
);
network
->
InsertPath
(
binDir
);
std
::
string
n_key
(
network
->
GetName
());
newNets
.
insert
(
std
::
pair
<
std
::
string
,
std
::
unique_ptr
<
CNINetwork
>>
(
n_key
,
std
::
move
(
network
)));
DEBUG
(
"---parse cni network: %s finish ----"
,
n_key
.
c_str
());
return
0
;
}
void
CniNetworkPlugin
::
ResetCNINetwork
(
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
CNINetwork
>>
&
newNets
,
Errors
&
err
)
{
std
::
string
pluginNames
{
"map["
};
m_networks
.
clear
();
for
(
auto
iter
=
newNets
.
begin
();
iter
!=
newNets
.
end
();
iter
++
)
{
m_networks
[
iter
->
first
]
=
std
::
move
(
iter
->
second
);
pluginNames
+=
(
iter
->
first
+
" "
);
}
INFO
(
"Loaded cni plugins successfully, all plugins: %s]"
,
pluginNames
.
substr
(
0
,
pluginNames
.
length
()
-
1
).
c_str
());
}
void
CniNetworkPlugin
::
GetCNINetwork
(
const
std
::
string
&
pluginDir
,
const
std
::
string
&
binDir
,
const
std
::
string
&
vendorCNIDirPrefix
,
Errors
&
err
)
void
CniNetworkPlugin
::
GetDefaultCNINetwork
(
const
std
::
string
&
confDir
,
std
::
vector
<
std
::
string
>
&
binDirs
,
Errors
&
err
)
{
std
::
vector
<
std
::
string
>
files
;
std
::
set
<
std
::
string
>
allPanes
;
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
CNINetwork
>>
newNets
;
bool
found
=
false
;
if
(
GetCNIConfFiles
(
plugin
Dir
,
files
,
err
)
!=
0
)
{
if
(
GetCNIConfFiles
(
conf
Dir
,
files
,
err
)
!=
0
)
{
goto
free_out
;
}
sort
(
files
.
begin
(),
files
.
end
());
for
(
auto
elem
:
files
)
{
struct
cni_network_list_conf
*
n_list
=
nullptr
;
...
...
@@ -305,23 +264,16 @@ void CniNetworkPlugin::GetCNINetwork(const std::string &pluginDir, const std::st
continue
;
}
if
(
InsertConfNameToAllPanes
(
n_list
,
allPanes
,
err
)
!=
0
)
{
goto
free_out
;
}
if
(
InsertNewNetwork
(
n_list
,
newNets
,
binDir
,
vendorCNIDirPrefix
,
err
)
!=
0
)
{
goto
free_out
;
}
m_defaultNetwork
=
std
::
unique_ptr
<
CNINetwork
>
(
new
(
std
::
nothrow
)
CNINetwork
(
n_list
->
name
,
n_list
));
m_defaultNetwork
->
SetPaths
(
binDirs
);
found
=
true
;
break
;
}
if
(
newNets
.
size
()
==
0
)
{
err
.
Errorf
(
"No valid networks found in %s"
,
pluginDir
.
c_str
());
goto
free_out
;
if
(
!
found
)
{
err
.
Errorf
(
"No valid networks found in %s"
,
confDir
.
c_str
());
}
ResetCNINetwork
(
newNets
,
err
);
free_out:
newNets
.
clear
();
return
;
}
...
...
@@ -332,9 +284,9 @@ void CniNetworkPlugin::CheckInitialized(Errors &err)
ERROR
(
"%s"
,
err
.
GetCMessage
());
return
;
}
size_t
len
=
m_networks
.
size
(
);
bool
inited
=
(
m_defaultNetwork
!=
nullptr
);
UnlockNetworkMap
(
err
);
if
(
len
==
0
)
{
if
(
!
inited
)
{
err
.
AppendError
(
"cni config uninitialized"
);
}
}
...
...
@@ -347,7 +299,7 @@ void CniNetworkPlugin::SyncNetworkConfig()
ERROR
(
"%s"
,
err
.
GetCMessage
());
return
;
}
Get
CNINetwork
(
m_pluginDir
,
m_binDir
,
m_vendorCNIDirPrefix
,
err
);
Get
DefaultCNINetwork
(
m_confDir
,
m_binDirs
,
err
);
if
(
err
.
NotEmpty
())
{
WARN
(
"Unable to update cni config: %s"
,
err
.
GetCMessage
());
}
...
...
@@ -375,6 +327,10 @@ void CniNetworkPlugin::Init(CRIRuntimeServiceImpl *criImpl, const std::string &h
m_criImpl
=
criImpl
;
SyncNetworkConfig
();
// start a thread to sync network config from confDir periodically to detect network config updates in every 5 seconds
m_syncThread
=
std
::
thread
([
&
]()
{
UpdateDefaultNetwork
();
});
return
;
}
...
...
@@ -390,9 +346,10 @@ void CniNetworkPlugin::Status(Errors &err)
CheckInitialized
(
err
);
}
void
CniNetworkPlugin
::
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
void
CniNetworkPlugin
::
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
id
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
err
)
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
err
)
{
CheckInitialized
(
err
);
if
(
err
.
NotEmpty
())
{
...
...
@@ -403,16 +360,10 @@ void CniNetworkPlugin::SetUpPod(const std::string &ns, const std::string &name,
ERROR
(
"CNI failed to retrieve network namespace path: %s"
,
err
.
GetCMessage
());
return
;
}
auto
iter
=
annotations
.
find
(
CRIHelpers
::
Constants
::
POD_CHECKPOINT_KEY
);
std
::
string
jsonCheckpoint
{
""
};
if
(
iter
!=
annotations
.
end
())
{
jsonCheckpoint
=
iter
->
second
;
}
DEBUG
(
"add checkpoint: "
,
jsonCheckpoint
.
c_str
());
struct
result
*
preResult
=
nullptr
;
if
(
m_loNetwork
!=
nullptr
)
{
AddToNetwork
(
m_loNetwork
.
get
(),
jsonCheckpoint
,
name
,
ns
,
interfaceName
,
id
,
netnsPath
,
&
preResult
,
err
);
AddToNetwork
(
m_loNetwork
.
get
(),
name
,
ns
,
interfaceName
,
id
,
netnsPath
,
annotations
,
options
,
&
preResult
,
err
);
free_result
(
preResult
);
preResult
=
nullptr
;
if
(
err
.
NotEmpty
())
{
...
...
@@ -426,26 +377,20 @@ void CniNetworkPlugin::SetUpPod(const std::string &ns, const std::string &name,
ERROR
(
"%s"
,
err
.
GetCMessage
());
return
;
}
auto
netIter
=
m_networks
.
find
(
networkPlane
);
if
(
netIter
==
m_networks
.
end
())
{
ERROR
(
"Can't find cni plugin for network plane %s."
,
networkPlane
.
c_str
());
err
.
Errorf
(
"Can't find cni plugin for network plane %s."
,
networkPlane
.
c_str
());
goto
unlock_out
;
}
AddToNetwork
((
netIter
->
second
).
get
(),
jsonCheckpoint
,
name
,
ns
,
interfaceName
,
id
,
netnsPath
,
&
preResult
,
err
);
AddToNetwork
(
m_defaultNetwork
.
get
(),
name
,
ns
,
interfaceName
,
id
,
netnsPath
,
annotations
,
options
,
&
preResult
,
err
);
free_result
(
preResult
);
preResult
=
nullptr
;
if
(
err
.
NotEmpty
())
{
ERROR
(
"Error while adding to cni network: %s"
,
err
.
GetCMessage
());
}
unlock_out:
UnlockNetworkMap
(
err
);
}
void
CniNetworkPlugin
::
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlan
e
,
const
std
::
string
&
i
nterfaceName
,
const
std
::
string
&
i
d
,
void
CniNetworkPlugin
::
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceNam
e
,
const
std
::
string
&
id
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
err
)
{
CheckInitialized
(
err
);
...
...
@@ -459,27 +404,14 @@ void CniNetworkPlugin::TearDownPod(const std::string &ns, const std::string &nam
err
.
Clear
();
}
auto
iter
=
annotations
.
find
(
CRIHelpers
::
Constants
::
POD_CHECKPOINT_KEY
);
std
::
string
jsonCheckpoint
=
""
;
if
(
iter
!=
annotations
.
end
())
{
jsonCheckpoint
=
iter
->
second
;
}
DEBUG
(
"delete checkpoint: "
,
jsonCheckpoint
.
c_str
());
RLockNetworkMap
(
err
);
if
(
err
.
NotEmpty
())
{
ERROR
(
"%s"
,
err
.
GetCMessage
());
return
;
}
auto
netIter
=
m_networks
.
find
(
networkPlane
);
if
(
netIter
==
m_networks
.
end
())
{
ERROR
(
"Can't find cni plugin for network plane %s."
,
networkPlane
.
c_str
());
err
.
Errorf
(
"Can't find cni plugin for network plane %s."
,
networkPlane
.
c_str
());
goto
unlock_out
;
}
DeleteFromNetwork
(
(
netIter
->
second
).
get
(),
jsonCheckpoint
,
name
,
ns
,
interfaceName
,
id
,
netnsPath
,
err
);
DeleteFromNetwork
(
m_defaultNetwork
.
get
(),
name
,
ns
,
interfaceName
,
id
,
netnsPath
,
annotations
,
err
);
unlock_out:
UnlockNetworkMap
(
err
);
}
...
...
@@ -490,7 +422,30 @@ std::map<int, bool> *CniNetworkPlugin::Capabilities()
void
CniNetworkPlugin
::
Event
(
const
std
::
string
&
name
,
std
::
map
<
std
::
string
,
std
::
string
>
&
details
)
{
m_noop
.
Event
(
name
,
details
);
if
(
name
!=
CRIHelpers
::
Constants
::
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
)
{
return
;
}
auto
iter
=
details
.
find
(
CRIHelpers
::
Constants
::
NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR
);
if
(
iter
==
details
.
end
())
{
WARN
(
"%s event didn't contain pod CIDR"
,
CRIHelpers
::
Constants
::
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
.
c_str
());
return
;
}
Errors
err
;
WLockNetworkMap
(
err
);
if
(
err
.
NotEmpty
())
{
ERROR
(
"%s"
,
err
.
GetCMessage
());
return
;
}
if
(
m_podCidr
.
empty
())
{
WARN
(
"Ignoring subsequent pod CIDR update to %s"
,
iter
->
second
.
c_str
());
goto
unlock_out
;
}
m_podCidr
=
iter
->
second
;
unlock_out:
UnlockNetworkMap
(
err
);
}
void
CniNetworkPlugin
::
GetPodNetworkStatus
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
...
...
@@ -526,9 +481,11 @@ out:
INFO
(
"get_pod_network_status: %s"
,
podSandboxID
.
c_str
());
}
void
CniNetworkPlugin
::
AddToNetwork
(
CNINetwork
*
snetwork
,
const
std
::
string
&
jsonCheckpoint
,
const
std
::
string
&
podName
,
void
CniNetworkPlugin
::
AddToNetwork
(
CNINetwork
*
snetwork
,
const
std
::
string
&
podName
,
const
std
::
string
&
podNamespace
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
struct
result
**
presult
,
Errors
&
err
)
{
struct
runtime_conf
*
rc
{
...
...
@@ -540,7 +497,8 @@ void CniNetworkPlugin::AddToNetwork(CNINetwork *snetwork, const std::string &jso
ERROR
(
"Invalid arguments"
);
return
;
}
BuildCNIRuntimeConf
(
podName
,
jsonCheckpoint
,
podNamespace
,
interfaceName
,
podSandboxID
,
podNetnsPath
,
&
rc
,
err
);
BuildCNIRuntimeConf
(
podName
,
podNamespace
,
interfaceName
,
podSandboxID
,
podNetnsPath
,
annotations
,
options
,
&
rc
,
err
);
if
(
err
.
NotEmpty
())
{
ERROR
(
"Error adding network when building cni runtime conf: %s"
,
err
.
GetCMessage
());
return
;
...
...
@@ -566,10 +524,12 @@ void CniNetworkPlugin::AddToNetwork(CNINetwork *snetwork, const std::string &jso
free
(
serr
);
}
void
CniNetworkPlugin
::
DeleteFromNetwork
(
CNINetwork
*
network
,
const
std
::
string
&
jsonCheckpoint
,
void
CniNetworkPlugin
::
DeleteFromNetwork
(
CNINetwork
*
network
,
const
std
::
string
&
podName
,
const
std
::
string
&
podNamespace
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
Errors
&
err
)
const
std
::
string
&
podNetnsPath
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
err
)
{
struct
runtime_conf
*
rc
{
nullptr
...
...
@@ -580,7 +540,8 @@ void CniNetworkPlugin::DeleteFromNetwork(CNINetwork *network, const std::string
ERROR
(
"Invalid arguments"
);
return
;
}
BuildCNIRuntimeConf
(
podName
,
jsonCheckpoint
,
podNamespace
,
interfaceName
,
podSandboxID
,
podNetnsPath
,
&
rc
,
err
);
std
::
map
<
std
::
string
,
std
::
string
>
options
;
BuildCNIRuntimeConf
(
podName
,
podNamespace
,
interfaceName
,
podSandboxID
,
podNetnsPath
,
annotations
,
options
,
&
rc
,
err
);
if
(
err
.
NotEmpty
())
{
ERROR
(
"Error deleting network when building cni runtime conf: %s"
,
err
.
GetCMessage
());
return
;
...
...
@@ -606,20 +567,25 @@ void CniNetworkPlugin::DeleteFromNetwork(CNINetwork *network, const std::string
free
(
serr
);
}
void
CniNetworkPlugin
::
BuildCNIRuntimeConf
(
const
std
::
string
&
podName
,
const
std
::
string
&
jsonCheckpoint
,
const
std
::
string
&
podNs
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
struct
runtime_conf
**
cni_rc
,
Errors
&
err
)
static
void
PrepareRuntimeConf
(
const
std
::
string
&
podName
,
const
std
::
string
&
podNs
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
struct
runtime_conf
**
cni_rc
,
Errors
&
err
)
{
std
::
vector
<
cri
::
PortMapping
>
portMappings
;
INFO
(
"Got netns path %s"
,
podNetnsPath
.
c_str
());
INFO
(
"Using podns path %s"
,
podNs
.
c_str
());
const
size_t
defaultLen
=
5
;
if
(
cni_rc
==
nullptr
)
{
err
.
Errorf
(
"Invalid arguments"
);
ERROR
(
"Invalid arguments"
);
return
;
}
auto
iter
=
options
.
find
(
"UID"
);
std
::
string
podUID
{
""
};
if
(
iter
!=
options
.
end
())
{
podUID
=
iter
->
second
;
}
struct
runtime_conf
*
rt
=
(
struct
runtime_conf
*
)
util_common_calloc_s
(
sizeof
(
struct
runtime_conf
));
if
(
rt
==
nullptr
)
{
ERROR
(
"Out of memory"
);
...
...
@@ -631,13 +597,13 @@ void CniNetworkPlugin::BuildCNIRuntimeConf(const std::string &podName, const std
rt
->
netns
=
util_strdup_s
(
podNetnsPath
.
c_str
());
rt
->
ifname
=
util_strdup_s
(
interfaceName
.
c_str
());
rt
->
args
=
(
char
*
(
*
)[
2
])
util_common_calloc_s
(
sizeof
(
char
*
)
*
2
*
4
);
rt
->
args
=
(
char
*
(
*
)[
2
])
util_common_calloc_s
(
sizeof
(
char
*
)
*
2
*
defaultLen
);
if
(
rt
->
args
==
nullptr
)
{
ERROR
(
"Out of memory"
);
err
.
SetError
(
"Out of memory"
);
goto
free_out
;
}
rt
->
args_len
=
4
;
rt
->
args_len
=
defaultLen
;
rt
->
args
[
0
][
0
]
=
util_strdup_s
(
"IgnoreUnknown"
);
rt
->
args
[
0
][
1
]
=
util_strdup_s
(
"1"
);
rt
->
args
[
1
][
0
]
=
util_strdup_s
(
"K8S_POD_NAMESPACE"
);
...
...
@@ -646,6 +612,39 @@ void CniNetworkPlugin::BuildCNIRuntimeConf(const std::string &podName, const std
rt
->
args
[
2
][
1
]
=
util_strdup_s
(
podName
.
c_str
());
rt
->
args
[
3
][
0
]
=
util_strdup_s
(
"K8S_POD_INFRA_CONTAINER_ID"
);
rt
->
args
[
3
][
1
]
=
util_strdup_s
(
podSandboxID
.
c_str
());
rt
->
args
[
4
][
0
]
=
util_strdup_s
(
"K8S_POD_UID"
);
rt
->
args
[
4
][
1
]
=
util_strdup_s
(
podUID
.
c_str
());
*
cni_rc
=
rt
;
return
;
free_out:
free_runtime_conf
(
rt
);
}
void
CniNetworkPlugin
::
BuildCNIRuntimeConf
(
const
std
::
string
&
podName
,
const
std
::
string
&
podNs
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
struct
runtime_conf
**
cni_rc
,
Errors
&
err
)
{
PrepareRuntimeConf
(
podName
,
podNs
,
interfaceName
,
podSandboxID
,
podNetnsPath
,
options
,
cni_rc
,
err
);
if
(
err
.
NotEmpty
())
{
return
;
}
struct
runtime_conf
*
rt
=
*
cni_rc
;
*
cni_rc
=
nullptr
;
auto
iter
=
annotations
.
find
(
CRIHelpers
::
Constants
::
POD_CHECKPOINT_KEY
);
std
::
string
jsonCheckpoint
{
""
};
if
(
iter
!=
annotations
.
end
())
{
jsonCheckpoint
=
iter
->
second
;
}
DEBUG
(
"add checkpoint: "
,
jsonCheckpoint
.
c_str
());
std
::
vector
<
cri
::
PortMapping
>
portMappings
;
INFO
(
"Got netns path %s"
,
podNetnsPath
.
c_str
());
INFO
(
"Using podns path %s"
,
podNs
.
c_str
());
if
(
!
jsonCheckpoint
.
empty
())
{
cri
::
PodSandboxCheckpoint
checkpoint
;
...
...
@@ -723,4 +722,20 @@ void CniNetworkPlugin::UnlockNetworkMap(Errors &error)
}
}
void
CniNetworkPlugin
::
UpdateDefaultNetwork
()
{
#define DEFAULT_SYNC_CONFIG_CNT 50
#define DEFAULT_SYNC_CONFIG_PERIOD 100
while
(
true
)
{
for
(
int
i
=
0
;
i
<
DEFAULT_SYNC_CONFIG_PERIOD
;
i
++
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
DEFAULT_SYNC_CONFIG_PERIOD
));
if
(
m_needFinish
)
{
return
;
}
}
SyncNetworkConfig
();
}
}
}
// namespace Network
src/services/cri/cni_network_plugin.h
浏览文件 @
c043e010
...
...
@@ -20,6 +20,8 @@
#include <map>
#include <vector>
#include <set>
#include <thread>
#include <clibcni/api.h>
#include "network_plugin.h"
...
...
@@ -48,9 +50,9 @@ public:
{
m_name
=
name
;
}
void
InsertPath
(
const
std
::
string
&
path
)
void
SetPaths
(
std
::
vector
<
std
::
string
>
&
binDirs
)
{
m_path
.
push_back
(
path
)
;
m_path
=
binDirs
;
}
std
::
string
GetNetworkConfigJsonStr
()
{
...
...
@@ -64,6 +66,13 @@ public:
{
return
m_networkConfig
->
first_plugin_name
?
m_networkConfig
->
first_plugin_name
:
""
;
}
struct
cni_network_list_conf
*
UpdateCNIConfList
(
struct
cni_network_list_conf
*
newConf
)
{
struct
cni_network_list_conf
*
result
=
m_networkConfig
;
m_networkConfig
=
newConf
;
return
result
;
}
char
**
GetPaths
(
Errors
&
err
);
private:
...
...
@@ -76,8 +85,8 @@ private:
class
CniNetworkPlugin
:
public
NetworkPlugin
{
public:
CniNetworkPlugin
(
const
std
::
string
&
binDir
,
const
std
::
string
&
plugin
Dir
,
const
std
::
string
&
vendorCNIDirPrefix
=
""
);
CniNetworkPlugin
(
std
::
vector
<
std
::
string
>
&
binDirs
,
const
std
::
string
&
conf
Dir
,
const
std
::
string
&
podCidr
=
""
);
virtual
~
CniNetworkPlugin
();
...
...
@@ -90,12 +99,13 @@ public:
std
::
map
<
int
,
bool
>
*
Capabilities
()
override
;
void
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
void
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
override
;
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
error
)
override
;
void
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
const
std
::
string
&
interfaceNam
e
,
const
std
::
string
&
podSandboxID
,
void
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlan
e
,
const
std
::
string
&
podSandboxID
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
override
;
void
GetPodNetworkStatus
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
...
...
@@ -105,27 +115,34 @@ public:
virtual
void
SetLoNetwork
(
std
::
unique_ptr
<
CNINetwork
>
lo
);
virtual
void
SetDefaultNetwork
(
std
::
unique_ptr
<
CNINetwork
>
network
);
private:
virtual
void
PlatformInit
(
Errors
&
error
);
virtual
void
SyncNetworkConfig
();
virtual
void
GetCNINetwork
(
const
std
::
string
&
pluginDir
,
const
std
::
string
&
binDir
,
const
std
::
string
&
vendorCNIDirPrefix
,
Errors
&
error
);
virtual
void
GetDefaultCNINetwork
(
const
std
::
string
&
pluginDir
,
std
::
vector
<
std
::
string
>
&
binDirs
,
Errors
&
error
);
virtual
void
CheckInitialized
(
Errors
&
error
);
virtual
void
AddToNetwork
(
CNINetwork
*
network
,
const
std
::
string
&
jsonCheckpoint
,
const
std
::
string
&
podName
,
virtual
void
AddToNetwork
(
CNINetwork
*
network
,
const
std
::
string
&
podName
,
const
std
::
string
&
podNamespace
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
struct
result
**
presult
,
Errors
&
error
);
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
struct
result
**
presult
,
Errors
&
error
);
virtual
void
DeleteFromNetwork
(
CNINetwork
*
network
,
const
std
::
string
&
jsonCheckpoint
,
const
std
::
string
&
podName
,
virtual
void
DeleteFromNetwork
(
CNINetwork
*
network
,
const
std
::
string
&
podName
,
const
std
::
string
&
podNamespace
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
Errors
&
error
);
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
);
virtual
void
BuildCNIRuntimeConf
(
const
std
::
string
&
podName
,
const
std
::
string
&
jsonCheckpoint
,
virtual
void
BuildCNIRuntimeConf
(
const
std
::
string
&
podName
,
const
std
::
string
&
podNs
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podNetnsPath
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
struct
runtime_conf
**
cni_rc
,
Errors
&
error
);
private:
...
...
@@ -135,21 +152,23 @@ private:
int
GetCNIConfFiles
(
const
std
::
string
&
pluginDir
,
std
::
vector
<
std
::
string
>
&
vect_files
,
Errors
&
err
);
int
LoadCNIConfigFileList
(
const
std
::
string
&
elem
,
struct
cni_network_list_conf
**
n_list
);
int
InsertConfNameToAllPanes
(
struct
cni_network_list_conf
*
n_list
,
std
::
set
<
std
::
string
>
&
allPanes
,
Errors
&
err
);
int
InsertNewNetwork
(
struct
cni_network_list_conf
*
n_list
,
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
CNINetwork
>>
&
newNets
,
const
std
::
string
&
binDir
,
const
std
::
string
&
vendorCNIDirPrefix
,
Errors
&
err
);
void
ResetCNINetwork
(
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
CNINetwork
>>
&
newNets
,
Errors
&
err
);
void
UpdateDefaultNetwork
();
NoopNetworkPlugin
m_noop
;
std
::
unique_ptr
<
CNINetwork
>
m_loNetwork
{
nullptr
};
std
::
unique_ptr
<
CNINetwork
>
m_defaultNetwork
{
nullptr
};
CRIRuntimeServiceImpl
*
m_criImpl
{
nullptr
};
std
::
string
m_nsenterPath
;
std
::
string
m_
plugin
Dir
;
std
::
string
m_vendorCNIDirPrefix
;
std
::
string
m_
binDi
r
;
std
::
string
m_
conf
Dir
;
std
::
vector
<
std
::
string
>
m_binDirs
;
std
::
string
m_
podCid
r
;
pthread_rwlock_t
m_netsLock
=
PTHREAD_RWLOCK_INITIALIZER
;
std
::
map
<
std
::
string
,
std
::
unique_ptr
<
CNINetwork
>>
m_networks
;
std
::
thread
m_syncThread
;
bool
m_needFinish
;
};
}
// namespace Network
...
...
src/services/cri/cri_helpers.cc
浏览文件 @
c043e010
...
...
@@ -49,6 +49,8 @@ const std::string Constants::CONTAINER_TYPE_ANNOTATION_KEY { "io.kubernetes.cri.
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
std
::
string
Constants
::
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
{
"pod-cidr-change"
};
const
std
::
string
Constants
::
NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR
{
"pod-cidr"
};
const
char
*
InternalLabelKeys
[]
=
{
CRIHelpers
::
Constants
::
CONTAINER_TYPE_LABEL_KEY
.
c_str
(),
...
...
src/services/cri/cri_helpers.h
浏览文件 @
c043e010
...
...
@@ -53,7 +53,11 @@ public:
static
const
std
::
string
CONTAINER_TYPE_ANNOTATION_CONTAINER
;
static
const
std
::
string
CONTAINER_TYPE_ANNOTATION_SANDBOX
;
static
const
std
::
string
SANDBOX_ID_ANNOTATION_KEY
;
static
const
std
::
string
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
;
static
const
std
::
string
NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR
;
};
std
::
string
GetDefaultSandboxImage
(
Errors
&
err
);
json_map_string_string
*
MakeLabels
(
const
google
::
protobuf
::
Map
<
std
::
string
,
std
::
string
>
&
mapLabels
,
Errors
&
error
);
...
...
src/services/cri/cri_runtime_service.cc
浏览文件 @
c043e010
...
...
@@ -109,14 +109,11 @@ cleanup:
void
CRIRuntimeServiceImpl
::
UpdateRuntimeConfig
(
const
runtime
::
v1alpha2
::
RuntimeConfig
&
config
,
Errors
&
error
)
{
const
std
::
string
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
{
"pod-cidr-change"
};
const
std
::
string
NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR
{
"pod-cidr"
};
INFO
(
"iSulad cri received runtime config: %s"
,
config
.
network_config
().
pod_cidr
().
c_str
());
if
(
m_pluginManager
!=
nullptr
&&
config
.
has_network_config
()
&&
!
(
config
.
network_config
().
pod_cidr
().
empty
()))
{
std
::
map
<
std
::
string
,
std
::
string
>
events
;
events
[
NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR
]
=
config
.
network_config
().
pod_cidr
();
m_pluginManager
->
Event
(
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
,
events
);
events
[
CRIHelpers
::
Constants
::
NET_PLUGIN_EVENT_POD_CIDR_CHANGE_DETAIL_CIDR
]
=
config
.
network_config
().
pod_cidr
();
m_pluginManager
->
Event
(
CRIHelpers
::
Constants
::
NET_PLUGIN_EVENT_POD_CIDR_CHANGE
,
events
);
}
return
;
}
...
...
src/services/cri/cri_runtime_service.h
浏览文件 @
c043e010
...
...
@@ -247,7 +247,7 @@ private:
const
std
::
string
&
jsonCheckpoint
,
Errors
&
error
);
void
SetupUserDefinedNetworkPlane
(
const
runtime
::
v1alpha2
::
PodSandboxConfig
&
config
,
const
std
::
string
&
response_id
,
container_inspect
*
inspect_data
,
std
::
map
<
std
::
string
,
std
::
string
>
&
stdAnnos
,
Errors
&
error
);
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
error
);
void
StartSandboxContainer
(
const
std
::
string
&
response_id
,
Errors
&
error
);
std
::
string
CreateSandboxContainer
(
const
runtime
::
v1alpha2
::
PodSandboxConfig
&
config
,
const
std
::
string
&
image
,
std
::
string
&
jsonCheckpoint
,
const
std
::
string
&
runtimeHandler
,
Errors
&
error
);
...
...
src/services/cri/cri_sandbox.cc
浏览文件 @
c043e010
...
...
@@ -469,7 +469,8 @@ void CRIRuntimeServiceImpl::StartSandboxContainer(const std::string &response_id
void
CRIRuntimeServiceImpl
::
SetupUserDefinedNetworkPlane
(
const
runtime
::
v1alpha2
::
PodSandboxConfig
&
config
,
const
std
::
string
&
response_id
,
container_inspect
*
inspect_data
,
std
::
map
<
std
::
string
,
std
::
string
>
&
stdAnnos
,
Errors
&
error
)
std
::
map
<
std
::
string
,
std
::
string
>
&
stdAnnos
,
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
error
)
{
google
::
protobuf
::
Map
<
std
::
string
,
std
::
string
>
annotations
;
CRIHelpers
::
ExtractAnnotations
(
inspect_data
->
config
->
annotations
,
annotations
);
...
...
@@ -485,8 +486,8 @@ void CRIRuntimeServiceImpl::SetupUserDefinedNetworkPlane(const runtime::v1alpha2
if
(
networks
[
i
]
&&
networks
[
i
]
->
name
&&
networks
[
i
]
->
interface
&&
strcmp
(
networks
[
i
]
->
name
,
Network
::
DEFAULT_NETWORK_PLANE_NAME
.
c_str
())
!=
0
)
{
INFO
(
"SetupPod net: %s"
,
networks
[
i
]
->
name
);
m_pluginManager
->
SetUpPod
(
config
.
metadata
().
namespace_
(),
config
.
metadata
().
name
(),
networks
[
i
]
->
name
,
networks
[
i
]
->
interface
,
response_id
,
stdAnno
s
,
error
);
m_pluginManager
->
SetUpPod
(
config
.
metadata
().
namespace_
(),
config
.
metadata
().
name
(),
networks
[
i
]
->
interface
,
response_id
,
stdAnnos
,
option
s
,
error
);
if
(
error
.
Empty
())
{
continue
;
}
...
...
@@ -508,6 +509,8 @@ void CRIRuntimeServiceImpl::SetupSandboxNetwork(const runtime::v1alpha2::PodSand
Errors
&
error
)
{
std
::
map
<
std
::
string
,
std
::
string
>
stdAnnos
;
std
::
map
<
std
::
string
,
std
::
string
>
networkOptions
;
container_inspect
*
inspect_data
=
InspectContainer
(
response_id
,
error
);
if
(
error
.
NotEmpty
())
{
return
;
...
...
@@ -530,22 +533,16 @@ void CRIRuntimeServiceImpl::SetupSandboxNetwork(const runtime::v1alpha2::PodSand
// Setup networking for the sandbox.
CRIHelpers
::
ProtobufAnnoMapToStd
(
config
.
annotations
(),
stdAnnos
);
stdAnnos
[
CRIHelpers
::
Constants
::
POD_CHECKPOINT_KEY
]
=
jsonCheckpoint
;
networkOptions
[
"UID"
]
=
config
.
metadata
().
uid
();
m_pluginManager
->
SetUpPod
(
config
.
metadata
().
namespace_
(),
config
.
metadata
().
name
(),
Network
::
DEFAULT_NETWORK_PLANE_NAME
,
Network
::
DEFAULT_NETWORK_INTERFACE_NAME
,
response_id
,
stdAnnos
,
error
);
Network
::
DEFAULT_NETWORK_INTERFACE_NAME
,
response_id
,
stdAnnos
,
networkOptions
,
error
);
if
(
error
.
NotEmpty
())
{
ERROR
(
"SetupPod failed: %s"
,
error
.
GetCMessage
());
StopContainerHelper
(
response_id
,
error
);
goto
cleanup
;
}
// Multi network plane featrue
// Set up user defined network plane
SetupUserDefinedNetworkPlane
(
config
,
response_id
,
inspect_data
,
stdAnnos
,
error
);
if
(
error
.
NotEmpty
())
{
ERROR
(
"failed to user defined network plane"
);
goto
cleanup
;
}
cleanup:
free_container_inspect
(
inspect_data
);
}
...
...
@@ -723,8 +720,7 @@ int CRIRuntimeServiceImpl::TearDownPodCniNetwork(const std::string &realSandboxI
if
(
networks
[
i
]
&&
networks
[
i
]
->
name
&&
networks
[
i
]
->
interface
&&
strcmp
(
networks
[
i
]
->
name
,
Network
::
DEFAULT_NETWORK_PLANE_NAME
.
c_str
())
!=
0
)
{
Errors
tmpErr
;
m_pluginManager
->
TearDownPod
(
ns
,
name
,
networks
[
i
]
->
name
,
networks
[
i
]
->
interface
,
inspect_data
->
id
,
stdAnnos
,
tmpErr
);
m_pluginManager
->
TearDownPod
(
ns
,
name
,
networks
[
i
]
->
interface
,
inspect_data
->
id
,
stdAnnos
,
tmpErr
);
if
(
tmpErr
.
NotEmpty
())
{
WARN
(
"TearDownPod cni network failed: %s"
,
tmpErr
.
GetCMessage
());
errlist
.
push_back
(
tmpErr
.
GetMessage
());
...
...
@@ -746,22 +742,17 @@ int CRIRuntimeServiceImpl::ClearCniNetwork(const std::string &realSandboxID, boo
bool
ready
=
GetNetworkReady
(
realSandboxID
,
networkErr
);
if
(
!
hostNetwork
&&
(
ready
||
networkErr
.
NotEmpty
()))
{
Errors
pluginErr
;
m_pluginManager
->
TearDownPod
(
ns
,
name
,
Network
::
DEFAULT_NETWORK_PLANE_NAME
,
Network
::
DEFAULT_NETWORK_INTERFACE_NAME
,
realSandboxID
,
stdAnnos
,
pluginErr
);
m_pluginManager
->
TearDownPod
(
ns
,
name
,
Network
::
DEFAULT_NETWORK_INTERFACE_NAME
,
realSandboxID
,
stdAnnos
,
pluginErr
);
if
(
pluginErr
.
NotEmpty
())
{
WARN
(
"TearDownPod cni network: %s failed: %s"
,
Network
::
DEFAULT_NETWORK_PLANE_NAME
.
c_str
(),
pluginErr
.
GetCMessage
());
WARN
(
"TearDownPod cni network failed: %s"
,
pluginErr
.
GetCMessage
());
errlist
.
push_back
(
pluginErr
.
GetMessage
());
}
else
{
INFO
(
"TearDownPod cni network:
%s success"
,
Network
::
DEFAULT_NETWORK_PLANE_NAME
.
c_str
()
);
INFO
(
"TearDownPod cni network:
success"
);
SetNetworkReady
(
realSandboxID
,
false
,
pluginErr
);
if
(
pluginErr
.
NotEmpty
())
{
WARN
(
"set network ready: %s"
,
pluginErr
.
GetCMessage
());
}
}
if
(
TearDownPodCniNetwork
(
realSandboxID
,
errlist
,
stdAnnos
,
ns
,
name
,
error
))
{
return
-
1
;
}
}
return
0
;
}
...
...
src/services/cri/network_plugin.cc
浏览文件 @
c043e010
...
...
@@ -401,9 +401,10 @@ void PluginManager::GetPodNetworkStatus(const std::string &ns, const std::string
Unlock
(
fullName
,
error
);
}
void
PluginManager
::
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
void
PluginManager
::
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
error
)
{
if
(
m_plugin
==
nullptr
)
{
return
;
...
...
@@ -417,7 +418,7 @@ void PluginManager::SetUpPod(const std::string &ns, const std::string &name, con
INFO
(
"Calling network plugin %s to set up pod %s"
,
m_plugin
->
Name
().
c_str
(),
fullName
.
c_str
());
Errors
tmpErr
;
m_plugin
->
SetUpPod
(
ns
,
name
,
networkPlane
,
interfaceName
,
podSandboxID
,
annota
tions
,
tmpErr
);
m_plugin
->
SetUpPod
(
ns
,
name
,
interfaceName
,
podSandboxID
,
annotations
,
op
tions
,
tmpErr
);
if
(
tmpErr
.
NotEmpty
())
{
error
.
Errorf
(
"NetworkPlugin %s failed to set up pod %s network: %s"
,
m_plugin
->
Name
().
c_str
(),
fullName
.
c_str
(),
tmpErr
.
GetCMessage
());
...
...
@@ -425,8 +426,8 @@ void PluginManager::SetUpPod(const std::string &ns, const std::string &name, con
Unlock
(
fullName
,
error
);
}
void
PluginManager
::
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlan
e
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
void
PluginManager
::
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceNam
e
,
const
std
::
string
&
podSandboxID
,
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
{
Errors
tmpErr
;
...
...
@@ -440,7 +441,7 @@ void PluginManager::TearDownPod(const std::string &ns, const std::string &name,
}
INFO
(
"Calling network plugin %s to tear down pod %s"
,
m_plugin
->
Name
().
c_str
(),
fullName
.
c_str
());
m_plugin
->
TearDownPod
(
ns
,
name
,
networkPlane
,
interfaceName
,
podSandboxID
,
annotations
,
tmpErr
);
m_plugin
->
TearDownPod
(
ns
,
name
,
Network
::
DEFAULT_NETWORK_INTERFACE_NAME
,
podSandboxID
,
annotations
,
tmpErr
);
if
(
tmpErr
.
NotEmpty
())
{
error
.
Errorf
(
"NetworkPlugin %s failed to teardown pod %s network: %s"
,
m_plugin
->
Name
().
c_str
(),
fullName
.
c_str
(),
tmpErr
.
GetCMessage
());
...
...
@@ -499,15 +500,16 @@ std::map<int, bool> *NoopNetworkPlugin::Capabilities()
return
ret
;
}
void
NoopNetworkPlugin
::
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
void
NoopNetworkPlugin
::
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
error
)
{
return
;
}
void
NoopNetworkPlugin
::
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlan
e
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
void
NoopNetworkPlugin
::
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceNam
e
,
const
std
::
string
&
podSandboxID
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
{
return
;
...
...
src/services/cri/network_plugin.h
浏览文件 @
c043e010
...
...
@@ -102,12 +102,13 @@ public:
virtual
std
::
map
<
int
,
bool
>
*
Capabilities
()
=
0
;
virtual
void
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
virtual
void
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
=
0
;
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
error
)
=
0
;
virtual
void
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podSandboxID
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
=
0
;
virtual
void
GetPodNetworkStatus
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
...
...
@@ -136,12 +137,13 @@ public:
std
::
map
<
int
,
bool
>
*
Capabilities
()
override
;
void
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
void
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
override
;
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
error
)
override
;
void
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podSandboxID
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
)
override
;
void
GetPodNetworkStatus
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
...
...
@@ -201,11 +203,12 @@ public:
void
Status
(
Errors
&
error
);
void
GetPodNetworkStatus
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
PodNetworkStatus
&
status
,
Errors
&
error
);
void
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
void
SetUpPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
);
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
options
,
Errors
&
error
);
void
TearDownPod
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
networkPlane
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
const
std
::
string
&
podSandboxID
,
std
::
map
<
std
::
string
,
std
::
string
>
&
annotations
,
Errors
&
error
);
private:
...
...
test/test.sh
浏览文件 @
c043e010
...
...
@@ -16,7 +16,7 @@
#set -xe
usage
()
function
usage
()
{
echo
"Usage: sh llt.sh [OPTIONS]"
echo
"Use llt.sh to control llt operation"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录