Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
37281a40
Unverified
Commit
37281a40
authored
May 15, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 15, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #76442 from viegasdom/fix-golint-utils-bandwith
Fix golint failures of util/bandwith/*.go
parents
929adb69
9d3d7a7b
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
20 additions
and
10 deletions
+20
-10
.golint_failures
hack/.golint_failures
+0
-1
kubenet_linux.go
pkg/kubelet/dockershim/network/kubenet/kubenet_linux.go
+2
-2
fake_shaper.go
pkg/util/bandwidth/fake_shaper.go
+7
-0
interfaces.go
pkg/util/bandwidth/interfaces.go
+3
-1
linux.go
pkg/util/bandwidth/linux.go
+5
-5
unsupported.go
pkg/util/bandwidth/unsupported.go
+2
-1
utils.go
pkg/util/bandwidth/utils.go
+1
-0
No files found.
hack/.golint_failures
View file @
37281a40
...
...
@@ -287,7 +287,6 @@ pkg/security/podsecuritypolicy/user
pkg/security/podsecuritypolicy/util
pkg/serviceaccount
pkg/ssh
pkg/util/bandwidth
pkg/util/config
pkg/util/ebtables
pkg/util/env
...
...
pkg/kubelet/dockershim/network/kubenet/kubenet_linux.go
View file @
37281a40
...
...
@@ -74,7 +74,7 @@ type kubenetNetworkPlugin struct {
netConfig
*
libcni
.
NetworkConfig
loConfig
*
libcni
.
NetworkConfig
cniConfig
libcni
.
CNI
bandwidthShaper
bandwidth
.
Bandwidth
Shaper
bandwidthShaper
bandwidth
.
Shaper
mu
sync
.
Mutex
//Mutex for protecting podIPs map, netConfig, and shaper initialization
podIPs
map
[
kubecontainer
.
ContainerID
]
string
mtu
int
...
...
@@ -597,7 +597,7 @@ func (plugin *kubenetNetworkPlugin) delContainerFromNetwork(config *libcni.Netwo
// shaper retrieves the bandwidth shaper and, if it hasn't been fetched before,
// initializes it and ensures the bridge is appropriately configured
// This function should only be called while holding the `plugin.mu` lock
func
(
plugin
*
kubenetNetworkPlugin
)
shaper
()
bandwidth
.
Bandwidth
Shaper
{
func
(
plugin
*
kubenetNetworkPlugin
)
shaper
()
bandwidth
.
Shaper
{
if
plugin
.
bandwidthShaper
==
nil
{
plugin
.
bandwidthShaper
=
bandwidth
.
NewTCShaper
(
BridgeName
)
plugin
.
bandwidthShaper
.
ReconcileInterface
()
...
...
pkg/util/bandwidth/fake_shaper.go
View file @
37281a40
...
...
@@ -22,28 +22,35 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
)
// FakeShaper provides an implementation of the bandwith.Shaper.
// Beware this is implementation has no features besides Reset and GetCIDRs.
type
FakeShaper
struct
{
CIDRs
[]
string
ResetCIDRs
[]
string
}
// Limit is not implemented
func
(
f
*
FakeShaper
)
Limit
(
cidr
string
,
egress
,
ingress
*
resource
.
Quantity
)
error
{
return
errors
.
New
(
"unimplemented"
)
}
// Reset appends a particular CIDR to the set of ResetCIDRs being managed by this shaper
func
(
f
*
FakeShaper
)
Reset
(
cidr
string
)
error
{
f
.
ResetCIDRs
=
append
(
f
.
ResetCIDRs
,
cidr
)
return
nil
}
// ReconcileInterface is not implemented
func
(
f
*
FakeShaper
)
ReconcileInterface
()
error
{
return
errors
.
New
(
"unimplemented"
)
}
// ReconcileCIDR is not implemented
func
(
f
*
FakeShaper
)
ReconcileCIDR
(
cidr
string
,
egress
,
ingress
*
resource
.
Quantity
)
error
{
return
errors
.
New
(
"unimplemented"
)
}
// GetCIDRs returns the set of CIDRs that are being managed by this shaper
func
(
f
*
FakeShaper
)
GetCIDRs
()
([]
string
,
error
)
{
return
f
.
CIDRs
,
nil
}
pkg/util/bandwidth/interfaces.go
View file @
37281a40
...
...
@@ -18,7 +18,9 @@ package bandwidth
import
"k8s.io/apimachinery/pkg/api/resource"
type
BandwidthShaper
interface
{
// Shaper is designed so that the shaper structs created
// satisfy the Shaper interface.
type
Shaper
interface
{
// Limit the bandwidth for a particular CIDR on a particular interface
// * ingress and egress are in bits/second
// * cidr is expected to be a valid network CIDR (e.g. '1.2.3.4/32' or '10.20.0.1/16')
...
...
pkg/util/bandwidth/linux.go
View file @
37281a40
...
...
@@ -33,7 +33,7 @@ import (
"k8s.io/klog"
)
// tcShaper provides an implementation of the
Bandwidth
Shaper interface on Linux using the 'tc' tool.
// tcShaper provides an implementation of the Shaper interface on Linux using the 'tc' tool.
// In general, using this requires that the caller posses the NET_CAP_ADMIN capability, though if you
// do this within an container, it only requires the NS_CAPABLE capability for manipulations to that
// container's network namespace.
...
...
@@ -44,7 +44,8 @@ type tcShaper struct {
iface
string
}
func
NewTCShaper
(
iface
string
)
BandwidthShaper
{
// NewTCShaper makes a new tcShaper for the given interface
func
NewTCShaper
(
iface
string
)
Shaper
{
shaper
:=
&
tcShaper
{
e
:
exec
.
New
(),
iface
:
iface
,
...
...
@@ -157,10 +158,9 @@ func (t *tcShaper) findCIDRClass(cidr string) (classAndHandleList [][]string, fo
// filter parent 1: protocol ip pref 1 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1
if
len
(
parts
)
!=
19
{
return
classAndHandleList
,
false
,
fmt
.
Errorf
(
"unexpected output from tc: %s %d (%v)"
,
filter
,
len
(
parts
),
parts
)
}
else
{
resultTmp
:=
[]
string
{
parts
[
18
],
parts
[
9
]}
classAndHandleList
=
append
(
classAndHandleList
,
resultTmp
)
}
resultTmp
:=
[]
string
{
parts
[
18
],
parts
[
9
]}
classAndHandleList
=
append
(
classAndHandleList
,
resultTmp
)
}
}
if
len
(
classAndHandleList
)
>
0
{
...
...
pkg/util/bandwidth/unsupported.go
View file @
37281a40
...
...
@@ -27,7 +27,8 @@ import (
type
unsupportedShaper
struct
{
}
func
NewTCShaper
(
iface
string
)
BandwidthShaper
{
// NewTCShaper makes a new unsupportedShapper for the given interface
func
NewTCShaper
(
iface
string
)
Shaper
{
return
&
unsupportedShaper
{}
}
...
...
pkg/util/bandwidth/utils.go
View file @
37281a40
...
...
@@ -35,6 +35,7 @@ func validateBandwidthIsReasonable(rsrc *resource.Quantity) error {
return
nil
}
// ExtractPodBandwidthResources extracts the ingress and egress from the given pod annotations
func
ExtractPodBandwidthResources
(
podAnnotations
map
[
string
]
string
)
(
ingress
,
egress
*
resource
.
Quantity
,
err
error
)
{
if
podAnnotations
==
nil
{
return
nil
,
nil
,
nil
...
...
Write
Preview
Markdown
is supported
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