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
7704fb6e
Unverified
Commit
7704fb6e
authored
Jul 28, 2021
by
Jamie Phillips
Committed by
GitHub
Jul 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exporting the AddFeatureGate function and adding a unit test for it. (#3661)
parent
fc19b805
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
11 deletions
+56
-11
agent.go
pkg/daemons/agent/agent.go
+0
-7
agent_linux.go
pkg/daemons/agent/agent_linux.go
+3
-3
agent_windows.go
pkg/daemons/agent/agent_windows.go
+1
-1
gates.go
pkg/util/gates.go
+9
-0
gates_test.go
pkg/util/gates_test.go
+43
-0
No files found.
pkg/daemons/agent/agent.go
View file @
7704fb6e
...
...
@@ -57,13 +57,6 @@ func startKubelet(cfg *daemonconfig.Agent) error {
return
executor
.
Kubelet
(
args
)
}
func
addFeatureGate
(
current
,
new
string
)
string
{
if
current
==
""
{
return
new
}
return
current
+
","
+
new
}
// ImageCredProvAvailable checks to see if the kubelet image credential provider bin dir and config
// files exist and are of the correct types. This is exported so that it may be used by downstream projects.
func
ImageCredProvAvailable
(
cfg
*
daemonconfig
.
Agent
)
bool
{
...
...
pkg/daemons/agent/agent_linux.go
View file @
7704fb6e
...
...
@@ -134,7 +134,7 @@ func kubeletArgs(cfg *config.Agent) map[string]string {
logrus
.
Warn
(
"Disabling pod PIDs limit feature due to missing cgroup pids support"
)
argsMap
[
"cgroups-per-qos"
]
=
"false"
argsMap
[
"enforce-node-allocatable"
]
=
""
argsMap
[
"feature-gates"
]
=
a
ddFeatureGate
(
argsMap
[
"feature-gates"
],
"SupportPodPidsLimit=false"
)
argsMap
[
"feature-gates"
]
=
util
.
A
ddFeatureGate
(
argsMap
[
"feature-gates"
],
"SupportPodPidsLimit=false"
)
}
if
kubeletRoot
!=
""
{
argsMap
[
"kubelet-cgroups"
]
=
kubeletRoot
...
...
@@ -143,7 +143,7 @@ func kubeletArgs(cfg *config.Agent) map[string]string {
argsMap
[
"runtime-cgroups"
]
=
runtimeRoot
}
if
system
.
RunningInUserNS
()
{
argsMap
[
"feature-gates"
]
=
a
ddFeatureGate
(
argsMap
[
"feature-gates"
],
"DevicePlugins=false"
)
argsMap
[
"feature-gates"
]
=
util
.
A
ddFeatureGate
(
argsMap
[
"feature-gates"
],
"DevicePlugins=false"
)
}
argsMap
[
"node-labels"
]
=
strings
.
Join
(
cfg
.
NodeLabels
,
","
)
...
...
@@ -156,7 +156,7 @@ func kubeletArgs(cfg *config.Agent) map[string]string {
if
ImageCredProvAvailable
(
cfg
)
{
logrus
.
Infof
(
"Kubelet image credential provider bin dir and configuration file found."
)
argsMap
[
"feature-gates"
]
=
a
ddFeatureGate
(
argsMap
[
"feature-gates"
],
"KubeletCredentialProviders=true"
)
argsMap
[
"feature-gates"
]
=
util
.
A
ddFeatureGate
(
argsMap
[
"feature-gates"
],
"KubeletCredentialProviders=true"
)
argsMap
[
"image-credential-provider-bin-dir"
]
=
cfg
.
ImageCredProvBinDir
argsMap
[
"image-credential-provider-config"
]
=
cfg
.
ImageCredProvConfig
}
...
...
pkg/daemons/agent/agent_windows.go
View file @
7704fb6e
...
...
@@ -120,7 +120,7 @@ func kubeletArgs(cfg *config.Agent) map[string]string {
if
ImageCredProvAvailable
(
cfg
)
{
logrus
.
Infof
(
"Kubelet image credential provider bin dir and configuration file found."
)
argsMap
[
"feature-gates"
]
=
a
ddFeatureGate
(
argsMap
[
"feature-gates"
],
"KubeletCredentialProviders=true"
)
argsMap
[
"feature-gates"
]
=
util
.
A
ddFeatureGate
(
argsMap
[
"feature-gates"
],
"KubeletCredentialProviders=true"
)
argsMap
[
"image-credential-provider-bin-dir"
]
=
cfg
.
ImageCredProvBinDir
argsMap
[
"image-credential-provider-config"
]
=
cfg
.
ImageCredProvConfig
}
...
...
pkg/util/gates.go
0 → 100644
View file @
7704fb6e
package
util
// AddFeatureGate correctly appends a feature gate key pair to the feature gates CLI switch.
func
AddFeatureGate
(
current
,
new
string
)
string
{
if
current
==
""
{
return
new
}
return
current
+
","
+
new
}
pkg/util/gates_test.go
0 → 100644
View file @
7704fb6e
package
util
import
(
"testing"
)
func
TestAddFeatureGate
(
t
*
testing
.
T
)
{
type
args
struct
{
currentArg
string
featureGate
string
}
tests
:=
[]
struct
{
name
string
args
args
want
string
}{
{
name
:
"Feature gate added to empty arg"
,
args
:
args
{
currentArg
:
""
,
featureGate
:
"SupportPodPidsLimit=false"
,
},
want
:
"SupportPodPidsLimit=false"
,
},
{
name
:
"Feature gate added to existing arg"
,
args
:
args
{
currentArg
:
"SupportPodPidsLimit=false"
,
featureGate
:
"DevicePlugins=false"
,
},
want
:
"SupportPodPidsLimit=false,DevicePlugins=false"
,
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
:=
AddFeatureGate
(
tt
.
args
.
currentArg
,
tt
.
args
.
featureGate
)
if
got
!=
tt
.
want
{
t
.
Errorf
(
"error, should be "
+
tt
.
want
+
", but got "
+
got
)
}
})
}
}
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