Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
af6a8590
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,发现更多精彩内容 >>
提交
af6a8590
编写于
4月 21, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
4月 21, 2020
浏览文件
操作
浏览文件
下载
差异文件
!202 optimize cni
Merge pull request !202 from haozi007/newwork
上级
0e8cc4c5
766cad9e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
63 addition
and
41 deletion
+63
-41
CI/test_cases/basic_cases/cni_test.bash
CI/test_cases/basic_cases/cni_test.bash
+12
-3
CMakeLists.txt
CMakeLists.txt
+1
-1
iSulad.spec
iSulad.spec
+1
-1
src/services/cri/cni_network_plugin.cc
src/services/cri/cni_network_plugin.cc
+47
-34
src/services/cri/cni_network_plugin.h
src/services/cri/cni_network_plugin.h
+2
-2
未找到文件。
CI/test_cases/basic_cases/cni_test.bash
浏览文件 @
af6a8590
...
...
@@ -117,10 +117,19 @@ function default_cni_config()
function
new_cni_config
()
{
cp
${
data_path
}
/bridge.json /etc/cni/net.d/
# wait cni updated
crictl info
sync
;
sync
;
sleep
2
tail
$ISUALD_LOG
# wait cni updated
s
=
`
date
"+%s"
`
for
((
i
=
0
;
i<30
;
i++
))
;
do
sleep
1
cur
=
`
date
"+%s"
`
let
"t=cur-s"
if
[
$t
-gt
6
]
;
then
break
fi
done
tail
$ISUALD_LOG
do_test_help
"10
\.
2
\.
"
}
...
...
CMakeLists.txt
浏览文件 @
af6a8590
...
...
@@ -9,7 +9,7 @@ include(cmake/set_build_flags.cmake)
#set(CMAKE_C_COMPILER "gcc" CACHE PATH "c compiler")
set
(
GIT_COMMIT_HASH
"
f2a6e59b14e430d166e350cac06ec188fb7ca47e
"
)
set
(
GIT_COMMIT_HASH
"
c5d55826dcf94d804412c7ccba7cc2c387df88c0
"
)
message
(
"-- commit id: "
${
GIT_COMMIT_HASH
}
)
add_definitions
(
-DISULAD_GIT_COMMIT=
"
${
GIT_COMMIT_HASH
}
"
)
...
...
iSulad.spec
浏览文件 @
af6a8590
%global _version 2.0.0
%global _release 202004
06.224326.gitf2a6e59b
%global _release 202004
21.092611.gitc5d55826
%global is_systemd 1
%global debug_package %{nil}
...
...
src/services/cri/cni_network_plugin.cc
浏览文件 @
af6a8590
...
...
@@ -101,10 +101,25 @@ void CniNetworkPlugin::SetLoNetwork(std::unique_ptr<CNINetwork> lo)
}
}
void
CniNetworkPlugin
::
SetDefaultNetwork
(
std
::
unique_ptr
<
CNINetwork
>
network
)
void
CniNetworkPlugin
::
SetDefaultNetwork
(
std
::
unique_ptr
<
CNINetwork
>
network
,
std
::
vector
<
std
::
string
>
&
binDirs
,
Errors
&
err
)
{
if
(
network
!=
nullptr
)
{
m_defaultNetwork
=
std
::
move
(
network
);
if
(
network
==
nullptr
)
{
return
;
}
WLockNetworkMap
(
err
);
if
(
err
.
NotEmpty
())
{
ERROR
(
"%s"
,
err
.
GetCMessage
());
return
;
}
m_defaultNetwork
=
std
::
move
(
network
);
m_defaultNetwork
->
SetPaths
(
binDirs
);
DEBUG
(
"Update new cni network:
\"
%s
\"
"
,
m_defaultNetwork
->
GetName
().
c_str
());
UnlockNetworkMap
(
err
);
if
(
err
.
NotEmpty
())
{
ERROR
(
"%s"
,
err
.
GetCMessage
());
}
}
...
...
@@ -264,8 +279,7 @@ void CniNetworkPlugin::GetDefaultCNINetwork(const std::string &confDir, std::vec
continue
;
}
m_defaultNetwork
=
std
::
unique_ptr
<
CNINetwork
>
(
new
(
std
::
nothrow
)
CNINetwork
(
n_list
->
name
,
n_list
));
m_defaultNetwork
->
SetPaths
(
binDirs
);
SetDefaultNetwork
(
std
::
unique_ptr
<
CNINetwork
>
(
new
(
std
::
nothrow
)
CNINetwork
(
n_list
->
name
,
n_list
)),
binDirs
,
err
);
found
=
true
;
break
;
}
...
...
@@ -294,19 +308,10 @@ void CniNetworkPlugin::CheckInitialized(Errors &err)
void
CniNetworkPlugin
::
SyncNetworkConfig
()
{
Errors
err
;
WLockNetworkMap
(
err
);
if
(
err
.
NotEmpty
())
{
ERROR
(
"%s"
,
err
.
GetCMessage
());
return
;
}
GetDefaultCNINetwork
(
m_confDir
,
m_binDirs
,
err
);
if
(
err
.
NotEmpty
())
{
WARN
(
"Unable to update cni config: %s"
,
err
.
GetCMessage
());
}
UnlockNetworkMap
(
err
);
if
(
err
.
NotEmpty
())
{
ERROR
(
"%s"
,
err
.
GetCMessage
());
}
}
void
CniNetworkPlugin
::
Init
(
CRIRuntimeServiceImpl
*
criImpl
,
const
std
::
string
&
hairpinMode
,
...
...
@@ -341,8 +346,6 @@ const std::string &CniNetworkPlugin::Name() const
void
CniNetworkPlugin
::
Status
(
Errors
&
err
)
{
SyncNetworkConfig
();
CheckInitialized
(
err
);
}
...
...
@@ -420,34 +423,42 @@ std::map<int, bool> *CniNetworkPlugin::Capabilities()
return
m_noop
.
Capabilities
();
}
void
CniNetworkPlugin
::
Event
(
const
std
::
string
&
name
,
std
::
map
<
std
::
string
,
std
::
string
>
&
details
)
void
CniNetworkPlugin
::
SetPodCidr
(
const
std
::
string
&
podCidr
)
{
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
());
if
(
!
m_podCidr
.
empty
())
{
WARN
(
"Ignoring subsequent pod CIDR update to %s"
,
podCidr
.
c_str
());
goto
unlock_out
;
}
m_podCidr
=
iter
->
second
;
m_podCidr
=
podCidr
;
unlock_out:
UnlockNetworkMap
(
err
);
}
void
CniNetworkPlugin
::
Event
(
const
std
::
string
&
name
,
std
::
map
<
std
::
string
,
std
::
string
>
&
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
;
}
SetPodCidr
(
iter
->
second
);
}
void
CniNetworkPlugin
::
GetPodNetworkStatus
(
const
std
::
string
&
ns
,
const
std
::
string
&
name
,
const
std
::
string
&
interfaceName
,
const
std
::
string
&
podSandboxID
,
PodNetworkStatus
&
status
,
Errors
&
err
)
...
...
@@ -724,12 +735,14 @@ void CniNetworkPlugin::UnlockNetworkMap(Errors &error)
void
CniNetworkPlugin
::
UpdateDefaultNetwork
()
{
#define DEFAULT_SYNC_CONFIG_CNT 50
#define DEFAULT_SYNC_CONFIG_PERIOD 100
const
int
defaultSyncConfigCnt
=
5
;
const
int
defaultSyncConfigPeriod
=
1000
;
pthread_setname_np
(
pthread_self
(),
"CNIUpdater"
);
while
(
true
)
{
for
(
int
i
=
0
;
i
<
DEFAULT_SYNC_CONFIG_PERIOD
;
i
++
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
DEFAULT_SYNC_CONFIG_PERIOD
));
for
(
int
i
=
0
;
i
<
defaultSyncConfigCnt
;
i
++
)
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
defaultSyncConfigPeriod
));
if
(
m_needFinish
)
{
return
;
}
...
...
src/services/cri/cni_network_plugin.h
浏览文件 @
af6a8590
...
...
@@ -115,8 +115,6 @@ 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
();
...
...
@@ -149,6 +147,8 @@ private:
void
RLockNetworkMap
(
Errors
&
error
);
void
WLockNetworkMap
(
Errors
&
error
);
void
UnlockNetworkMap
(
Errors
&
error
);
void
SetDefaultNetwork
(
std
::
unique_ptr
<
CNINetwork
>
network
,
std
::
vector
<
std
::
string
>
&
binDirs
,
Errors
&
err
);
void
SetPodCidr
(
const
std
::
string
&
podCidr
);
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
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录