Merge pull request #81932 from palnabarun/fix-staticcheck-tests-e2e_node

Fixes static check failures in test/e2e_node/*
This commit is contained in:
Kubernetes Prow Robot 2019-09-20 22:55:37 -07:00 committed by GitHub
commit 946df1a914
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 41 deletions

View File

@ -107,10 +107,6 @@ test/e2e/storage/vsphere
test/e2e/upgrades
test/e2e/upgrades/storage
test/e2e/windows
test/e2e_node
test/e2e_node/environment
test/e2e_node/remote
test/e2e_node/runner/remote
test/images/agnhost/dns
test/images/agnhost/inclusterclient
test/images/agnhost/net/nat

View File

@ -1190,8 +1190,3 @@ func (tc *nodeConfigTestCase) checkConfigMetrics(f *framework.Framework) {
return nil
}, timeout, interval).Should(gomega.BeNil())
}
// constructs the expected SelfLink for a config map
func configMapAPIPath(cm *v1.ConfigMap) string {
return fmt.Sprintf("/api/v1/namespaces/%s/configmaps/%s", cm.Namespace, cm.Name)
}

View File

@ -144,6 +144,10 @@ func dns() error {
}
kubecmd, err := exec.Command("ps", "aux").CombinedOutput()
if err != nil {
// Executing ps aux shouldn't have failed
panic(err)
}
// look for the dns flag and parse the value
dns := dnsRegex.FindStringSubmatch(string(kubecmd))

View File

@ -87,16 +87,24 @@ func checkIPTables() (err error) {
func checkPublicGCR() error {
const image = "k8s.gcr.io/busybox"
output, err := runCommand("docker", "images", "-q", image)
if err != nil {
return err
}
if len(output) != 0 {
if _, err := runCommand("docker", "rmi", "-f", image); err != nil {
return err
}
}
output, err = runCommand("docker", "pull", image)
if err != nil {
return err
}
if len(output) == 0 {
return fmt.Errorf("failed to pull %s", image)
}
if _, err = runCommand("docker", "rmi", "-f", image); err != nil {
if _, err := runCommand("docker", "rmi", "-f", image); err != nil {
return err
}
return nil

View File

@ -18,7 +18,7 @@ package e2e_node
import (
"github.com/onsi/ginkgo"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/pkg/kubelet"
@ -158,6 +158,7 @@ var _ = framework.KubeDescribe("ContainerLogPath [NodeConformance]", func() {
// get podID from created Pod
createdLogPod, err := podClient.Get(logPodName, metav1.GetOptions{})
framework.ExpectNoError(err, "Failed to get pod: %s", logPodName)
podNs := createdLogPod.Namespace
podName := createdLogPod.Name
podID := string(createdLogPod.UID)

View File

@ -18,7 +18,6 @@ package e2e_node
import (
"fmt"
"time"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
@ -32,7 +31,6 @@ import (
imageutils "k8s.io/kubernetes/test/utils/image"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
)
// makePodToVerifyPids returns a pod that verifies specified cgroup with pids
@ -81,28 +79,6 @@ func makePodToVerifyPids(baseName string, pidsLimit resource.Quantity) *v1.Pod {
return pod
}
// enablePodPidsLimitInKubelet enables pod pid limit feature for kubelet with a sensible default test limit
func enablePodPidsLimitInKubelet(f *framework.Framework) *kubeletconfig.KubeletConfiguration {
oldCfg, err := getCurrentKubeletConfig()
framework.ExpectNoError(err)
newCfg := oldCfg.DeepCopy()
if newCfg.FeatureGates == nil {
newCfg.FeatureGates = make(map[string]bool)
newCfg.FeatureGates["SupportPodPidsLimit"] = true
}
newCfg.PodPidsLimit = int64(1024)
// Update the Kubelet configuration.
framework.ExpectNoError(setKubeletConfiguration(f, newCfg))
// Wait for the Kubelet to be ready.
gomega.Eventually(func() bool {
nodeList := framework.GetReadySchedulableNodesOrDie(f.ClientSet)
return len(nodeList.Items) == 1
}, time.Minute, time.Second).Should(gomega.BeTrue())
return oldCfg
}
func runPodPidsLimitTests(f *framework.Framework) {
ginkgo.It("should set pids.max for Pod", func() {
ginkgo.By("by creating a G pod")

View File

@ -136,7 +136,7 @@ const (
)
func getTimestamp() string {
return fmt.Sprintf(time.Now().Format(timestampFormat))
return fmt.Sprint(time.Now().Format(timestampFormat))
}
func newWorkspaceDir() string {

View File

@ -19,9 +19,9 @@ go_library(
"//test/e2e_node/remote:go_default_library",
"//test/e2e_node/system:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/golang.org/x/oauth2:go_default_library",
"//vendor/golang.org/x/oauth2/google:go_default_library",
"//vendor/google.golang.org/api/compute/v0.beta:go_default_library",
"//vendor/google.golang.org/api/option:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/sigs.k8s.io/yaml:go_default_library",
],

View File

@ -40,9 +40,9 @@ import (
"k8s.io/kubernetes/test/e2e_node/system"
"github.com/pborman/uuid"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
compute "google.golang.org/api/compute/v0.beta"
"google.golang.org/api/option"
"k8s.io/klog"
"sigs.k8s.io/yaml"
)
@ -726,12 +726,12 @@ func getComputeClient() (*compute.Service, error) {
}
var client *http.Client
client, err = google.DefaultClient(oauth2.NoContext, compute.ComputeScope)
client, err = google.DefaultClient(context.Background(), compute.ComputeScope)
if err != nil {
continue
}
cs, err = compute.New(client)
cs, err = compute.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
continue
}

View File

@ -64,7 +64,6 @@ var kubeletAddress = flag.String("kubelet-address", "http://127.0.0.1:10255", "H
var startServices = flag.Bool("start-services", true, "If true, start local node services")
var stopServices = flag.Bool("stop-services", true, "If true, stop local node services after running tests")
var busyboxImage = imageutils.GetE2EImage(imageutils.BusyBox)
var perlImage = imageutils.GetE2EImage(imageutils.Perl)
const (
// Kubelet internal cgroup name for node allocatable cgroup.