mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
e2e: node: inline getSampleDevicePluginPod
Starting golangci-lint >= 1.45, the tool is complaining about the function being unused: ```bash test/e2e_node/device_plugin_test.go:82:6: func `getSampleDevicePluginPod` is unused (unused) func getSampleDevicePluginPod() *v1.Pod { ^ Please review the above warnings. You can test via "./hack/verify-golangci-lint.sh" If the above warnings do not make sense, you can exempt this warning with a comment (if your reviewer is okay with it). In general please prefer to fix the error, we have already disabled specific lints that the project chooses to ignore. See: https://golangci-lint.run/usage/false-positives/} ``` thing is the code is not changed lately, and manual inspection trivially confirms it is used. Older versions of golangci-lint (tested with ``` golangci-lint has version 1.41.1 built from a2074809 on 2021-06-19T16:01:50Z ```) indeed do NOT complain about the function, so this seems a golangci-lint bug. To move forward, we can disable the warning, but this leaves a sour taste. Instead, since the function is pretty trivias, was used just once and the caller was undoing some of the work done by the function, we just inline it, which solves the linter warning and makes the code a bit better. Signed-off-by: Francesco Romani <fromani@redhat.com>
This commit is contained in:
parent
017998e889
commit
19ae360af9
@ -78,26 +78,6 @@ func numberOfSampleResources(node *v1.Node) int64 {
|
||||
return val.Value()
|
||||
}
|
||||
|
||||
// getSampleDevicePluginPod returns the Device Plugin pod for sample resources in e2e tests.
|
||||
func getSampleDevicePluginPod() *v1.Pod {
|
||||
data, err := e2etestfiles.Read(SampleDevicePluginDSYAML)
|
||||
if err != nil {
|
||||
framework.Fail(err.Error())
|
||||
}
|
||||
|
||||
ds := readDaemonSetV1OrDie(data)
|
||||
p := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: sampleDevicePluginName,
|
||||
Namespace: metav1.NamespaceSystem,
|
||||
},
|
||||
|
||||
Spec: ds.Spec.Template.Spec,
|
||||
}
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
// readDaemonSetV1OrDie reads daemonset object from bytes. Panics on error.
|
||||
func readDaemonSetV1OrDie(objBytes []byte) *appsv1.DaemonSet {
|
||||
appsv1.AddToScheme(appsScheme)
|
||||
@ -127,8 +107,19 @@ func testDevicePlugin(f *framework.Framework, pluginSockDir string) {
|
||||
}, time.Minute, time.Second).Should(gomega.BeTrue())
|
||||
|
||||
ginkgo.By("Scheduling a sample device plugin pod")
|
||||
dp := getSampleDevicePluginPod()
|
||||
dp.Namespace = ""
|
||||
data, err := e2etestfiles.Read(SampleDevicePluginDSYAML)
|
||||
if err != nil {
|
||||
framework.Fail(err.Error())
|
||||
}
|
||||
ds := readDaemonSetV1OrDie(data)
|
||||
|
||||
dp := &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: sampleDevicePluginName,
|
||||
},
|
||||
Spec: ds.Spec.Template.Spec,
|
||||
}
|
||||
|
||||
for i := range dp.Spec.Containers[0].Env {
|
||||
if dp.Spec.Containers[0].Env[i].Name == envVarNamePluginSockDir {
|
||||
dp.Spec.Containers[0].Env[i].Value = pluginSockDir
|
||||
|
Loading…
Reference in New Issue
Block a user