Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Kube OVN
Commits
9df5f2f5
Commit
9df5f2f5
authored
3 years ago
by
hzma
Browse files
Options
Download
Email Patches
Plain Diff
filter used qos when delete qos
parent
90950dac
delete-qos-queue
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pkg/ovs/ovs-vsctl.go
+94
-9
pkg/ovs/ovs-vsctl.go
with
94 additions
and
9 deletions
+94
-9
pkg/ovs/ovs-vsctl.go
+
94
-
9
View file @
9df5f2f5
...
...
@@ -106,28 +106,59 @@ func ovsGet(table, record, column, key string) (string, error) {
return
Exec
(
args
...
)
}
func
ovsRemove
(
table
,
record
,
column
,
key
string
)
error
{
args
:=
[]
string
{
"remove"
}
if
key
==
""
{
args
=
append
(
args
,
table
,
record
,
column
)
}
else
{
args
=
append
(
args
,
table
,
record
,
column
,
key
)
}
_
,
err
:=
Exec
(
args
...
)
return
err
}
// Bridges returns bridges created by Kube-OVN
func
Bridges
()
([]
string
,
error
)
{
return
ovsFind
(
"bridge"
,
"name"
,
fmt
.
Sprintf
(
"external-ids:vendor=%s"
,
util
.
CniTypeName
))
}
// ClearPodBandwidth remove qos related to this pod.
func
ClearPodBandwidth
(
podName
,
podNamespace
,
ifaceID
string
)
error
{
var
qosList
,
qosListByPod
[]
string
func
GetQosList
(
podName
,
podNamespace
,
ifaceID
string
)
([]
string
,
error
)
{
var
qosList
[]
string
var
err
error
if
ifaceID
!=
""
{
qosList
,
err
=
ovsFind
(
"qos"
,
"_uuid"
,
fmt
.
Sprintf
(
`external-ids:iface-id="%s"`
,
ifaceID
))
if
err
!=
nil
{
return
err
return
qosList
,
err
}
}
else
{
qosList
ByPod
,
err
=
ovsFind
(
"qos"
,
"_uuid"
,
fmt
.
Sprintf
(
`external-ids:pod="%s/%s"`
,
podNamespace
,
podName
))
qosList
,
err
=
ovsFind
(
"qos"
,
"_uuid"
,
fmt
.
Sprintf
(
`external-ids:pod="%s/%s"`
,
podNamespace
,
podName
))
if
err
!=
nil
{
return
err
return
qosList
,
err
}
}
return
qosList
,
nil
}
// ClearPodBandwidth remove qos related to this pod.
func
ClearPodBandwidth
(
podName
,
podNamespace
,
ifaceID
string
)
error
{
qosList
,
err
:=
GetQosList
(
podName
,
podNamespace
,
ifaceID
)
if
err
!=
nil
{
return
err
}
// https://github.com/kubeovn/kube-ovn/issues/1191
usedQosList
,
err
:=
ovsFind
(
"port"
,
"qos"
,
"qos!=[]"
)
if
err
!=
nil
{
return
err
}
for
_
,
usedQosId
:=
range
usedQosList
{
if
util
.
ContainsString
(
qosList
,
usedQosId
)
{
qosList
=
util
.
RemoveString
(
qosList
,
usedQosId
)
}
}
qosList
=
append
(
qosList
,
qosListByPod
...
)
qosList
=
util
.
UniqString
(
qosList
)
for
_
,
qos
:=
range
qosList
{
if
err
:=
ovsDestroy
(
"qos"
,
qos
);
err
!=
nil
{
return
err
...
...
@@ -357,6 +388,17 @@ func ClearHtbQosQueue(podName, podNamespace, iface string) error {
}
}
// https://github.com/kubeovn/kube-ovn/issues/1191
qosQueueMap
,
err
:=
ListQosQueueIds
()
if
err
!=
nil
{
return
err
}
for
_
,
queueId
:=
range
qosQueueMap
{
if
util
.
ContainsString
(
queueList
,
queueId
)
{
queueList
=
util
.
RemoveString
(
queueList
,
queueId
)
}
}
for
_
,
queueId
:=
range
queueList
{
if
err
:=
ovsDestroy
(
"queue"
,
queueId
);
err
!=
nil
{
return
err
...
...
@@ -540,7 +582,7 @@ func SetNetemQos(podName, podNamespace, iface, latency, limit, loss string) erro
}
for
_
,
ifName
:=
range
interfaceList
{
qosList
,
err
:=
ovsFind
(
"qos"
,
"_uuid"
,
fmt
.
Sprintf
(
"external-ids:iface-id=%s"
,
iface
)
)
qosList
,
err
:=
GetQosList
(
podName
,
podNamespace
,
iface
)
if
err
!=
nil
{
return
err
}
...
...
@@ -584,6 +626,22 @@ func SetNetemQos(podName, podNamespace, iface, latency, limit, loss string) erro
if
err
:=
ovsSet
(
"qos"
,
qos
,
qosCommandValues
...
);
err
!=
nil
{
return
err
}
if
latencyMs
==
0
{
if
err
:=
ovsRemove
(
"qos"
,
qos
,
"other_config"
,
"latency"
);
err
!=
nil
{
return
err
}
}
if
limitPkts
==
0
{
if
err
:=
ovsRemove
(
"qos"
,
qos
,
"other_config"
,
"limit"
);
err
!=
nil
{
return
err
}
}
if
lossPercent
==
0
{
if
err
:=
ovsRemove
(
"qos"
,
qos
,
"other_config"
,
"loss"
);
err
!=
nil
{
return
err
}
}
}
}
}
else
{
...
...
@@ -639,3 +697,30 @@ func ListExternalIds(table string) (map[string]string, error) {
}
return
result
,
nil
}
func
ListQosQueueIds
()
(
map
[
string
]
string
,
error
)
{
args
:=
[]
string
{
"--data=bare"
,
"--format=csv"
,
"--no-heading"
,
"--columns=_uuid,queues"
,
"find"
,
"qos"
,
"queues:0!=[]"
}
output
,
err
:=
Exec
(
args
...
)
if
err
!=
nil
{
klog
.
Errorf
(
"failed to list qos, %v"
,
err
)
return
nil
,
err
}
lines
:=
strings
.
Split
(
output
,
"
\n
"
)
result
:=
make
(
map
[
string
]
string
,
len
(
lines
))
for
_
,
l
:=
range
lines
{
if
len
(
strings
.
TrimSpace
(
l
))
==
0
{
continue
}
parts
:=
strings
.
Split
(
strings
.
TrimSpace
(
l
),
","
)
if
len
(
parts
)
!=
2
{
continue
}
qosId
:=
strings
.
TrimSpace
(
parts
[
0
])
if
!
strings
.
Contains
(
strings
.
TrimSpace
(
parts
[
1
]),
"0="
)
{
continue
}
queueId
:=
strings
.
TrimPrefix
(
strings
.
TrimSpace
(
parts
[
1
]),
"0="
)
result
[
qosId
]
=
queueId
}
return
result
,
nil
}
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
Menu
Projects
Groups
Snippets
Help