Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Kube OVN
Commits
15f676f6
Unverified
Commit
15f676f6
authored
2 years ago
by
hzma
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
add vm pod to ipam by ip when initIPAM (#1974)
parent
afe06d81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pkg/controller/controller.go
+5
-3
pkg/controller/controller.go
pkg/controller/init.go
+15
-3
pkg/controller/init.go
pkg/controller/pod.go
+4
-0
pkg/controller/pod.go
with
24 additions
and
6 deletions
+24
-6
pkg/controller/controller.go
+
5
-
3
View file @
15f676f6
...
...
@@ -540,6 +540,11 @@ func (c *Controller) Run(stopCh <-chan struct{}) {
klog
.
Fatalf
(
"failed to init ovn resource: %v"
,
err
)
}
// sync ip crd before initIPAM since ip crd will be used to restore vm and statefulset pod in initIPAM
if
err
:=
c
.
initSyncCrdIPs
();
err
!=
nil
{
klog
.
Errorf
(
"failed to sync crd ips: %v"
,
err
)
}
if
err
:=
c
.
InitIPAM
();
err
!=
nil
{
klog
.
Fatalf
(
"failed to init ipam: %v"
,
err
)
}
...
...
@@ -562,9 +567,6 @@ func (c *Controller) Run(stopCh <-chan struct{}) {
}
c
.
registerSubnetMetrics
()
if
err
:=
c
.
initSyncCrdIPs
();
err
!=
nil
{
klog
.
Errorf
(
"failed to sync crd ips: %v"
,
err
)
}
if
err
:=
c
.
initSyncCrdSubnets
();
err
!=
nil
{
klog
.
Errorf
(
"failed to sync crd subnets: %v"
,
err
)
}
...
...
This diff is collapsed.
Click to expand it.
pkg/controller/init.go
+
15
-
3
View file @
15f676f6
...
...
@@ -330,8 +330,8 @@ func (c *Controller) InitIPAM() error {
ipsMap
:=
make
(
map
[
string
]
*
kubeovnv1
.
IP
,
len
(
ips
))
for
_
,
ip
:=
range
ips
{
ipsMap
[
ip
.
Name
]
=
ip
//
just
recover sts
ip, old sts ip with empty pod type and
other ip recover in later pod loop
if
ip
.
Spec
.
PodType
!=
"StatefulSet"
{
// recover sts
and kubevirt vm ip,
other ip recover in later pod loop
if
ip
.
Spec
.
PodType
!=
"StatefulSet"
&&
ip
.
Spec
.
PodType
!=
util
.
Vm
{
continue
}
...
...
@@ -582,10 +582,22 @@ func (c *Controller) initSyncCrdIPs() error {
return
err
}
vmLsps
:=
c
.
getVmLsps
()
ipMap
:=
make
(
map
[
string
]
struct
{},
len
(
vmLsps
))
for
_
,
vmLsp
:=
range
vmLsps
{
ipMap
[
vmLsp
]
=
struct
{}{}
}
for
_
,
ipCr
:=
range
ips
.
Items
{
ip
:=
ipCr
.
DeepCopy
()
changed
:=
false
if
_
,
ok
:=
ipMap
[
ip
.
Name
];
ok
&&
ip
.
Spec
.
PodType
==
""
{
ip
.
Spec
.
PodType
=
util
.
Vm
changed
=
true
}
v4IP
,
v6IP
:=
util
.
SplitStringIP
(
ip
.
Spec
.
IPAddress
)
if
ip
.
Spec
.
V4IPAddress
==
v4IP
&&
ip
.
Spec
.
V6IPAddress
==
v6IP
{
if
ip
.
Spec
.
V4IPAddress
==
v4IP
&&
ip
.
Spec
.
V6IPAddress
==
v6IP
&&
!
changed
{
continue
}
ip
.
Spec
.
V4IPAddress
=
v4IP
...
...
This diff is collapsed.
Click to expand it.
pkg/controller/pod.go
+
4
-
0
View file @
15f676f6
...
...
@@ -1632,5 +1632,9 @@ func getPodType(pod *v1.Pod) string {
if
ok
,
_
:=
isStatefulSetPod
(
pod
);
ok
{
return
"StatefulSet"
}
if
isVmPod
,
_
:=
isVmPod
(
pod
);
isVmPod
{
return
util
.
Vm
}
return
""
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment