From 34d4eaea08bbebbf34dac49ad41705852c1aa80f Mon Sep 17 00:00:00 2001 From: goltermann Date: Tue, 22 Mar 2016 17:26:50 -0700 Subject: [PATCH] Fixing several (but not all) go vet errors. Most are around string formatting, or unreachable code. --- cluster/addons/dns/kube2sky/kube2sky.go | 2 +- cmd/kube-apiserver/app/server_test.go | 6 +++--- cmd/kube-proxy/app/server.go | 4 ++-- pkg/api/rest/resttest/resttest.go | 8 ++++---- pkg/apiserver/proxy_test.go | 12 ++++++------ pkg/client/testing/core/fixture.go | 2 -- pkg/cloudprovider/providers/aws/aws.go | 2 +- pkg/cloudprovider/providers/aws/aws_routes.go | 2 +- pkg/cloudprovider/providers/aws/aws_test.go | 2 +- pkg/controller/job/controller_test.go | 4 ++-- pkg/credentialprovider/aws/aws_credentials.go | 2 +- pkg/kubectl/cmd/run_test.go | 2 +- pkg/kubectl/resource_printer.go | 2 +- pkg/kubelet/cm/container_manager_linux.go | 2 +- pkg/kubelet/dockertools/manager_test.go | 4 ++-- pkg/kubelet/kubelet_test.go | 2 +- pkg/kubelet/network/kubenet/kubenet_linux.go | 2 +- pkg/kubelet/pleg/generic.go | 1 - pkg/kubelet/prober/results/results_manager_test.go | 2 +- pkg/kubelet/rkt/log.go | 4 ++-- pkg/kubelet/rkt/rkt_test.go | 8 ++++---- pkg/kubelet/server/server.go | 4 ++-- pkg/kubelet/status/manager_test.go | 2 +- pkg/master/thirdparty_controller_test.go | 2 +- pkg/metrics/generic_metrics.go | 1 - pkg/quota/generic/evaluator.go | 2 +- pkg/quota/resources_test.go | 2 +- pkg/registry/generic/rest/proxy_test.go | 12 ++++++------ pkg/registry/thirdpartyresourcedata/codec_test.go | 2 +- pkg/runtime/scheme_test.go | 2 +- pkg/storage/etcd/etcd_watcher_test.go | 6 +++--- pkg/util/httpstream/httpstream_test.go | 2 +- pkg/util/oom/oom_linux.go | 2 +- pkg/util/strategicpatch/patch_test.go | 4 ++-- pkg/util/wsstream/stream_test.go | 2 +- .../pkg/admission/alwayspullimages/admission_test.go | 2 +- .../admission/namespace/lifecycle/admission_test.go | 6 +++--- test/e2e/reboot.go | 2 +- test/e2e/util.go | 2 +- test/e2e_node/e2e_node_suite_test.go | 2 +- test/e2e_node/e2e_service.go | 2 +- test/images/netexec/netexec.go | 4 ++-- 42 files changed, 68 insertions(+), 72 deletions(-) diff --git a/cluster/addons/dns/kube2sky/kube2sky.go b/cluster/addons/dns/kube2sky/kube2sky.go index fcb581eb05471..96b5be91d4070 100644 --- a/cluster/addons/dns/kube2sky/kube2sky.go +++ b/cluster/addons/dns/kube2sky/kube2sky.go @@ -377,7 +377,7 @@ func (ks *kube2sky) mutateEtcdOrDie(mutator func() error) { for { select { case <-timeout: - glog.Fatalf("Failed to mutate etcd for %v using mutator: %v", ks.etcdMutationTimeout, mutator) + glog.Fatalf("Failed to mutate etcd for %v using mutator: %v", ks.etcdMutationTimeout, mutator()) default: if err := mutator(); err != nil { delay := 50 * time.Millisecond diff --git a/cmd/kube-apiserver/app/server_test.go b/cmd/kube-apiserver/app/server_test.go index 958cab23a3b36..3d55406b1afce 100644 --- a/cmd/kube-apiserver/app/server_test.go +++ b/cmd/kube-apiserver/app/server_test.go @@ -211,13 +211,13 @@ func TestParseRuntimeConfig(t *testing.T) { apiGroupVersionOverrides, err := parseRuntimeConfig(s) if err == nil && test.err { - t.Fatalf("expected error for test: %q", test) + t.Fatalf("expected error for test: %v", test) } else if err != nil && !test.err { - t.Fatalf("unexpected error: %s, for test: %q", err, test) + t.Fatalf("unexpected error: %s, for test: %v", err, test) } if err == nil && !reflect.DeepEqual(apiGroupVersionOverrides, test.apiGroupVersionOverrides) { - t.Fatalf("unexpected apiGroupVersionOverrides. Actual: %q, expected: %q", apiGroupVersionOverrides, test.apiGroupVersionOverrides) + t.Fatalf("unexpected apiGroupVersionOverrides. Actual: %v, expected: %v", apiGroupVersionOverrides, test.apiGroupVersionOverrides) } } diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index 9481a506b9d88..23c0b3cf6e3bd 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -337,11 +337,11 @@ func getProxyMode(proxyMode string, client nodeGetter, hostname string, iptver i } node, err := client.Get(hostname) if err != nil { - glog.Errorf("Can't get Node %q, assuming iptables proxy: %v", hostname, err) + glog.Errorf("Can't get Node %q, assuming iptables proxy, err: %v", hostname, err) return tryIptablesProxy(iptver, kcompat) } if node == nil { - glog.Errorf("Got nil Node %q, assuming iptables proxy: %v", hostname) + glog.Errorf("Got nil Node %q, assuming iptables proxy", hostname) return tryIptablesProxy(iptver, kcompat) } proxyMode, found := node.Annotations[betaProxyModeAnnotation] diff --git a/pkg/api/rest/resttest/resttest.go b/pkg/api/rest/resttest/resttest.go index b17ae740df9b5..c7005b73db4e4 100644 --- a/pkg/api/rest/resttest/resttest.go +++ b/pkg/api/rest/resttest/resttest.go @@ -574,7 +574,7 @@ func (t *Tester) testDeleteGracefulHasDefault(obj runtime.Object, setFn SetFunc, t.Errorf("unexpected error: %v", err) } if _, err := getFn(ctx, foo); err != nil { - t.Fatalf("did not gracefully delete resource", err) + t.Fatalf("did not gracefully delete resource: %v", err) } object, err := t.storage.(rest.Getter).Get(ctx, objectMeta.Name) @@ -601,7 +601,7 @@ func (t *Tester) testDeleteGracefulWithValue(obj runtime.Object, setFn SetFunc, t.Errorf("unexpected error: %v", err) } if _, err := getFn(ctx, foo); err != nil { - t.Fatalf("did not gracefully delete resource", err) + t.Fatalf("did not gracefully delete resource: %v", err) } object, err := t.storage.(rest.Getter).Get(ctx, objectMeta.Name) @@ -628,7 +628,7 @@ func (t *Tester) testDeleteGracefulExtend(obj runtime.Object, setFn SetFunc, get t.Errorf("unexpected error: %v", err) } if _, err := getFn(ctx, foo); err != nil { - t.Fatalf("did not gracefully delete resource", err) + t.Fatalf("did not gracefully delete resource: %v", err) } // second delete duration is ignored @@ -660,7 +660,7 @@ func (t *Tester) testDeleteGracefulImmediate(obj runtime.Object, setFn SetFunc, t.Errorf("unexpected error: %v", err) } if _, err := getFn(ctx, foo); err != nil { - t.Fatalf("did not gracefully delete resource", err) + t.Fatalf("did not gracefully delete resource: %v", err) } // second delete is immediate, resource is deleted diff --git a/pkg/apiserver/proxy_test.go b/pkg/apiserver/proxy_test.go index 01dae4f0ececa..657bd0192c9f6 100644 --- a/pkg/apiserver/proxy_test.go +++ b/pkg/apiserver/proxy_test.go @@ -212,7 +212,7 @@ func TestProxyRequestContentLengthAndTransferEncoding(t *testing.T) { // Dial the proxy server conn, err := net.Dial(server.Listener.Addr().Network(), server.Listener.Addr().String()) if err != nil { - t.Errorf("%s: unexpected error %v", err) + t.Errorf("%s: unexpected error %v", k, err) continue } defer conn.Close() @@ -228,28 +228,28 @@ func TestProxyRequestContentLengthAndTransferEncoding(t *testing.T) { // Write the request headers post := fmt.Sprintf("POST /%s/%s/%s/proxy/namespaces/default/foo/id/some/dir HTTP/1.1\r\n", prefix, newGroupVersion.Group, newGroupVersion.Version) if _, err := fmt.Fprint(conn, post); err != nil { - t.Fatalf("%s: unexpected error %v", err) + t.Fatalf("%s: unexpected error %v", k, err) } for header, values := range item.reqHeaders { for _, value := range values { if _, err := fmt.Fprintf(conn, "%s: %s\r\n", header, value); err != nil { - t.Fatalf("%s: unexpected error %v", err) + t.Fatalf("%s: unexpected error %v", k, err) } } } // Header separator if _, err := fmt.Fprint(conn, "\r\n"); err != nil { - t.Fatalf("%s: unexpected error %v", err) + t.Fatalf("%s: unexpected error %v", k, err) } // Body if _, err := conn.Write(item.reqBody); err != nil { - t.Fatalf("%s: unexpected error %v", err) + t.Fatalf("%s: unexpected error %v", k, err) } // Read response response, err := ioutil.ReadAll(conn) if err != nil { - t.Errorf("%s: unexpected error %v", err) + t.Errorf("%s: unexpected error %v", k, err) continue } if !strings.HasSuffix(string(response), successfulResponse) { diff --git a/pkg/client/testing/core/fixture.go b/pkg/client/testing/core/fixture.go index e2a06a097924e..312051b58ec7f 100644 --- a/pkg/client/testing/core/fixture.go +++ b/pkg/client/testing/core/fixture.go @@ -97,8 +97,6 @@ func ObjectReaction(o ObjectRetriever, mapper meta.RESTMapper) ReactionFunc { default: return false, nil, fmt.Errorf("no reaction implemented for %s", action) } - - return true, nil, nil } } diff --git a/pkg/cloudprovider/providers/aws/aws.go b/pkg/cloudprovider/providers/aws/aws.go index 9db23bb61d828..25f705d7e1756 100644 --- a/pkg/cloudprovider/providers/aws/aws.go +++ b/pkg/cloudprovider/providers/aws/aws.go @@ -1486,7 +1486,7 @@ func (s *AWSCloud) describeLoadBalancer(name string) (*elb.LoadBalancerDescripti func (self *AWSCloud) findVPCID() (string, error) { macs, err := self.metadata.GetMetadata("network/interfaces/macs/") if err != nil { - return "", fmt.Errorf("Could not list interfaces of the instance", err) + return "", fmt.Errorf("Could not list interfaces of the instance: %v", err) } // loop over interfaces, first vpc id returned wins diff --git a/pkg/cloudprovider/providers/aws/aws_routes.go b/pkg/cloudprovider/providers/aws/aws_routes.go index c1ffddc3a25f8..a469e5f70b4c0 100644 --- a/pkg/cloudprovider/providers/aws/aws_routes.go +++ b/pkg/cloudprovider/providers/aws/aws_routes.go @@ -149,7 +149,7 @@ func (s *AWSCloud) CreateRoute(clusterName string, nameHint string, route *cloud _, err = s.ec2.DeleteRoute(request) if err != nil { - return fmt.Errorf("error deleting blackholed AWS route (%s): %v", deleteRoute.DestinationCidrBlock, err) + return fmt.Errorf("error deleting blackholed AWS route (%s): %v", aws.StringValue(deleteRoute.DestinationCidrBlock), err) } } diff --git a/pkg/cloudprovider/providers/aws/aws_test.go b/pkg/cloudprovider/providers/aws/aws_test.go index 24e3378224e39..09368d83c8a20 100644 --- a/pkg/cloudprovider/providers/aws/aws_test.go +++ b/pkg/cloudprovider/providers/aws/aws_test.go @@ -723,7 +723,7 @@ func TestFindVPCID(t *testing.T) { } vpcID, err := c.findVPCID() if err != nil { - t.Errorf("Unexpected error:", err) + t.Errorf("Unexpected error: %v", err) } if vpcID != "vpc-mac0" { t.Errorf("Unexpected vpcID: %s", vpcID) diff --git a/pkg/controller/job/controller_test.go b/pkg/controller/job/controller_test.go index e64b612ca3bd7..63235cb3846e7 100644 --- a/pkg/controller/job/controller_test.go +++ b/pkg/controller/job/controller_test.go @@ -234,7 +234,7 @@ func TestControllerSyncJob(t *testing.T) { // run err := manager.syncJob(getKey(job, t)) if err != nil { - t.Errorf("%s: unexpected error when syncing jobs %v", err) + t.Errorf("%s: unexpected error when syncing jobs %v", name, err) } // validate created/deleted pods @@ -332,7 +332,7 @@ func TestSyncJobPastDeadline(t *testing.T) { // run err := manager.syncJob(getKey(job, t)) if err != nil { - t.Errorf("%s: unexpected error when syncing jobs %v", err) + t.Errorf("%s: unexpected error when syncing jobs %v", name, err) } // validate created/deleted pods diff --git a/pkg/credentialprovider/aws/aws_credentials.go b/pkg/credentialprovider/aws/aws_credentials.go index 395c438edb773..aceda3853aa39 100644 --- a/pkg/credentialprovider/aws/aws_credentials.go +++ b/pkg/credentialprovider/aws/aws_credentials.go @@ -140,7 +140,7 @@ func (p *ecrProvider) Provide() credentialprovider.DockerConfig { data.AuthorizationToken != nil { decodedToken, err := base64.StdEncoding.DecodeString(aws.StringValue(data.AuthorizationToken)) if err != nil { - glog.Errorf("while decoding token for endpoint %s %v", data.ProxyEndpoint, err) + glog.Errorf("while decoding token for endpoint %v %v", data.ProxyEndpoint, err) return cfg } parts := strings.SplitN(string(decodedToken), ":", 2) diff --git a/pkg/kubectl/cmd/run_test.go b/pkg/kubectl/cmd/run_test.go index a6d18d7930949..d635c3781a378 100644 --- a/pkg/kubectl/cmd/run_test.go +++ b/pkg/kubectl/cmd/run_test.go @@ -325,7 +325,7 @@ func TestGenerateService(t *testing.T) { t.Errorf("unexpected error: %v", err) } if test.expectPOST != sawPOST { - t.Error("expectPost: %v, sawPost: %v", test.expectPOST, sawPOST) + t.Errorf("expectPost: %v, sawPost: %v", test.expectPOST, sawPOST) } } } diff --git a/pkg/kubectl/resource_printer.go b/pkg/kubectl/resource_printer.go index 7f9d4ab0ef731..59dba6e42af34 100644 --- a/pkg/kubectl/resource_printer.go +++ b/pkg/kubectl/resource_printer.go @@ -1584,7 +1584,7 @@ func printConfigMapList(list *api.ConfigMapList, w io.Writer, options PrintOptio } func printPodSecurityPolicy(item *extensions.PodSecurityPolicy, w io.Writer, options PrintOptions) error { - _, err := fmt.Fprintf(w, "%s\t%t\t%v\t%t\t%s\t%s\n", item.Name, item.Spec.Privileged, + _, err := fmt.Fprintf(w, "%s\t%t\t%v\t%v\t%s\t%s\n", item.Name, item.Spec.Privileged, item.Spec.Capabilities, item.Spec.Volumes, item.Spec.SELinux.Rule, item.Spec.RunAsUser.Rule) return err diff --git a/pkg/kubelet/cm/container_manager_linux.go b/pkg/kubelet/cm/container_manager_linux.go index 04ed034f585b7..45497dcb8f048 100644 --- a/pkg/kubelet/cm/container_manager_linux.go +++ b/pkg/kubelet/cm/container_manager_linux.go @@ -310,7 +310,7 @@ func (cm *containerManagerImpl) setupNode() error { cm.periodicTasks = append(cm.periodicTasks, func() { cont, err := getContainer(os.Getpid()) if err != nil { - glog.Error("failed to find cgroups of kubelet - %v", err) + glog.Errorf("failed to find cgroups of kubelet - %v", err) return } cm.Lock() diff --git a/pkg/kubelet/dockertools/manager_test.go b/pkg/kubelet/dockertools/manager_test.go index c5a6274157ac5..32e58a549cd03 100644 --- a/pkg/kubelet/dockertools/manager_test.go +++ b/pkg/kubelet/dockertools/manager_test.go @@ -1146,7 +1146,7 @@ func TestGetRestartCount(t *testing.T) { } cs := status.FindContainerStatusByName(containerName) if cs == nil { - t.Fatal("Can't find status for container %q", containerName) + t.Fatalf("Can't find status for container %q", containerName) } restartCount := cs.RestartCount if restartCount != expectedCount { @@ -1161,7 +1161,7 @@ func TestGetRestartCount(t *testing.T) { } cs := status.FindContainerStatusByName(containerName) if cs == nil { - t.Fatal("Can't find status for container %q", containerName) + t.Fatalf("Can't find status for container %q", containerName) } dm.KillContainerInPod(cs.ID, &pod.Spec.Containers[0], pod, "test container restart count.") } diff --git a/pkg/kubelet/kubelet_test.go b/pkg/kubelet/kubelet_test.go index 82954006b251d..0164adf60c38c 100644 --- a/pkg/kubelet/kubelet_test.go +++ b/pkg/kubelet/kubelet_test.go @@ -4165,7 +4165,7 @@ func TestCleanupBandwidthLimits(t *testing.T) { err := testKube.kubelet.cleanupBandwidthLimits(test.pods) if err != nil { - t.Errorf("unexpected error: %v (%s)", test.name) + t.Errorf("unexpected error: %v (%s)", test.name, err) } if !reflect.DeepEqual(shaper.ResetCIDRs, test.expectResetCIDRs) { t.Errorf("[%s]\nexpected: %v, saw: %v", test.name, test.expectResetCIDRs, shaper.ResetCIDRs) diff --git a/pkg/kubelet/network/kubenet/kubenet_linux.go b/pkg/kubelet/network/kubenet/kubenet_linux.go index 0cae97a29adcf..92826d036e5f7 100644 --- a/pkg/kubelet/network/kubenet/kubenet_linux.go +++ b/pkg/kubelet/network/kubenet/kubenet_linux.go @@ -91,7 +91,7 @@ func findMinMTU() (*net.Interface, error) { } if mtu >= 999999 || mtu < 576 || defIntfIndex < 0 { - return nil, fmt.Errorf("no suitable interface", BridgeName) + return nil, fmt.Errorf("no suitable interface: %v", BridgeName) } return &intfs[defIntfIndex], nil diff --git a/pkg/kubelet/pleg/generic.go b/pkg/kubelet/pleg/generic.go index 7c06b2960686d..bf0d44d37a664 100644 --- a/pkg/kubelet/pleg/generic.go +++ b/pkg/kubelet/pleg/generic.go @@ -158,7 +158,6 @@ func generateEvent(podID types.UID, cid string, oldState, newState plegContainer default: panic(fmt.Sprintf("unrecognized container state: %v", newState)) } - return nil } func (g *GenericPLEG) getRelistTime() time.Time { diff --git a/pkg/kubelet/prober/results/results_manager_test.go b/pkg/kubelet/prober/results/results_manager_test.go index 89f1da9f0922a..c3a62f4a342b5 100644 --- a/pkg/kubelet/prober/results/results_manager_test.go +++ b/pkg/kubelet/prober/results/results_manager_test.go @@ -56,7 +56,7 @@ func TestUpdates(t *testing.T) { select { case u := <-m.Updates(): if expected != u { - t.Errorf("Expected update %v, recieved %v: %s %s", expected, u, msg) + t.Errorf("Expected update %v, recieved %v: %s", expected, u, msg) } case <-time.After(wait.ForeverTestTimeout): t.Errorf("Timed out waiting for update %v: %s", expected, msg) diff --git a/pkg/kubelet/rkt/log.go b/pkg/kubelet/rkt/log.go index e469f653f6bcb..254758a22c9c8 100644 --- a/pkg/kubelet/rkt/log.go +++ b/pkg/kubelet/rkt/log.go @@ -143,12 +143,12 @@ func (r *Runtime) GetContainerLogs(pod *api.Pod, containerID kubecontainer.Conta outPipe, err := cmd.StdoutPipe() if err != nil { - glog.Errorf("rkt: cannot create pipe for journalctl's stdout", err) + glog.Errorf("rkt: cannot create pipe for journalctl's stdout: %v", err) return err } errPipe, err := cmd.StderrPipe() if err != nil { - glog.Errorf("rkt: cannot create pipe for journalctl's stderr", err) + glog.Errorf("rkt: cannot create pipe for journalctl's stderr: %v", err) return err } diff --git a/pkg/kubelet/rkt/rkt_test.go b/pkg/kubelet/rkt/rkt_test.go index 9b44105923074..e34930b8a5ab2 100644 --- a/pkg/kubelet/rkt/rkt_test.go +++ b/pkg/kubelet/rkt/rkt_test.go @@ -713,7 +713,7 @@ func TestGetPodStatus(t *testing.T) { func generateCapRetainIsolator(t *testing.T, caps ...string) appctypes.Isolator { retain, err := appctypes.NewLinuxCapabilitiesRetainSet(caps...) if err != nil { - t.Fatalf("Error generating cap retain isolator", err) + t.Fatalf("Error generating cap retain isolator: %v", err) } return retain.AsIsolator() } @@ -721,7 +721,7 @@ func generateCapRetainIsolator(t *testing.T, caps ...string) appctypes.Isolator func generateCapRevokeIsolator(t *testing.T, caps ...string) appctypes.Isolator { revoke, err := appctypes.NewLinuxCapabilitiesRevokeSet(caps...) if err != nil { - t.Fatalf("Error generating cap revoke isolator", err) + t.Fatalf("Error generating cap revoke isolator: %v", err) } return revoke.AsIsolator() } @@ -729,7 +729,7 @@ func generateCapRevokeIsolator(t *testing.T, caps ...string) appctypes.Isolator func generateCPUIsolator(t *testing.T, request, limit string) appctypes.Isolator { cpu, err := appctypes.NewResourceCPUIsolator(request, limit) if err != nil { - t.Fatalf("Error generating cpu resource isolator", err) + t.Fatalf("Error generating cpu resource isolator: %v", err) } return cpu.AsIsolator() } @@ -737,7 +737,7 @@ func generateCPUIsolator(t *testing.T, request, limit string) appctypes.Isolator func generateMemoryIsolator(t *testing.T, request, limit string) appctypes.Isolator { memory, err := appctypes.NewResourceMemoryIsolator(request, limit) if err != nil { - t.Fatalf("Error generating memory resource isolator", err) + t.Fatalf("Error generating memory resource isolator: %v", err) } return memory.AsIsolator() } diff --git a/pkg/kubelet/server/server.go b/pkg/kubelet/server/server.go index 44539aee01dda..4e31874fbd8e2 100644 --- a/pkg/kubelet/server/server.go +++ b/pkg/kubelet/server/server.go @@ -926,11 +926,11 @@ func (h *portForwardStreamHandler) getStreamPair(requestID string) (*portForward func (h *portForwardStreamHandler) monitorStreamPair(p *portForwardStreamPair, timeout <-chan time.Time) { select { case <-timeout: - err := fmt.Errorf("(conn=%p, request=%s) timed out waiting for streams", h.conn, p.requestID) + err := fmt.Errorf("(conn=%v, request=%s) timed out waiting for streams", h.conn, p.requestID) utilruntime.HandleError(err) p.printError(err.Error()) case <-p.complete: - glog.V(5).Infof("(conn=%p, request=%s) successfully received error and data streams", h.conn, p.requestID) + glog.V(5).Infof("(conn=%v, request=%s) successfully received error and data streams", h.conn, p.requestID) } h.removeStreamPair(p.requestID) } diff --git a/pkg/kubelet/status/manager_test.go b/pkg/kubelet/status/manager_test.go index d4a1d67492db3..904ec8b355050 100644 --- a/pkg/kubelet/status/manager_test.go +++ b/pkg/kubelet/status/manager_test.go @@ -674,7 +674,7 @@ func TestReconcilePodStatus(t *testing.T) { podStatus, ok := syncer.GetPodStatus(testPod.UID) if !ok { - t.Fatal("Should find pod status for pod: %+v", testPod) + t.Fatalf("Should find pod status for pod: %+v", testPod) } testPod.Status = podStatus diff --git a/pkg/master/thirdparty_controller_test.go b/pkg/master/thirdparty_controller_test.go index 47f618a7e42ac..be1b7775637fc 100644 --- a/pkg/master/thirdparty_controller_test.go +++ b/pkg/master/thirdparty_controller_test.go @@ -172,7 +172,7 @@ func TestSyncAPIs(t *testing.T) { cntrl := ThirdPartyController{master: &fake} if err := cntrl.syncResourceList(test.list); err != nil { - t.Errorf("[%s] unexpected error: %v", test.name) + t.Errorf("[%s] unexpected error: %v", test.name, err) } if len(test.expectedInstalled) != len(fake.installed) { t.Errorf("[%s] unexpected installed APIs: %d, expected %d (%#v)", test.name, len(fake.installed), len(test.expectedInstalled), fake.installed[0]) diff --git a/pkg/metrics/generic_metrics.go b/pkg/metrics/generic_metrics.go index d746c00d9724b..b0905bc5eef8e 100644 --- a/pkg/metrics/generic_metrics.go +++ b/pkg/metrics/generic_metrics.go @@ -141,7 +141,6 @@ func parseMetrics(data string, knownMetrics map[string][]string, output *Metrics } } } - return nil } func (g *MetricsGrabber) getMetricsFromPod(podName string, namespace string, port int) (string, error) { diff --git a/pkg/quota/generic/evaluator.go b/pkg/quota/generic/evaluator.go index b53057b7c3e72..905590e4a8c1f 100644 --- a/pkg/quota/generic/evaluator.go +++ b/pkg/quota/generic/evaluator.go @@ -172,7 +172,7 @@ func (g *GenericEvaluator) UsageStats(options quota.UsageStatsOptions) (quota.Us } list, err := g.ListFuncByNamespace(options.Namespace, api.ListOptions{}) if err != nil { - return result, fmt.Errorf("%s: Failed to list %v: %v", g.Name, g.GroupKind, err) + return result, fmt.Errorf("%s: Failed to list %v: %v", g.Name, g.GroupKind(), err) } _, err = meta.Accessor(list) if err != nil { diff --git a/pkg/quota/resources_test.go b/pkg/quota/resources_test.go index 5e2b3196aa233..79a3184f05c25 100644 --- a/pkg/quota/resources_test.go +++ b/pkg/quota/resources_test.go @@ -217,7 +217,7 @@ func TestIsZero(t *testing.T) { } for testName, testCase := range testCases { if result := IsZero(testCase.a); result != testCase.expected { - t.Errorf("%s expected: %v, actual: %v", testName, testCase.expected) + t.Errorf("%s expected: %v, actual: %v", testName, testCase.expected, result) } } } diff --git a/pkg/registry/generic/rest/proxy_test.go b/pkg/registry/generic/rest/proxy_test.go index 1386c8826ead8..7e4c279155e2a 100644 --- a/pkg/registry/generic/rest/proxy_test.go +++ b/pkg/registry/generic/rest/proxy_test.go @@ -638,7 +638,7 @@ func TestProxyRequestContentLengthAndTransferEncoding(t *testing.T) { // Dial the proxy server conn, err := net.Dial(proxyServer.Listener.Addr().Network(), proxyServer.Listener.Addr().String()) if err != nil { - t.Errorf("%s: unexpected error %v", err) + t.Errorf("unexpected error %v", err) continue } defer conn.Close() @@ -652,28 +652,28 @@ func TestProxyRequestContentLengthAndTransferEncoding(t *testing.T) { // Write the request headers if _, err := fmt.Fprint(conn, "POST / HTTP/1.1\r\n"); err != nil { - t.Fatalf("%s: unexpected error %v", err) + t.Fatalf("%s unexpected error %v", k, err) } for header, values := range item.reqHeaders { for _, value := range values { if _, err := fmt.Fprintf(conn, "%s: %s\r\n", header, value); err != nil { - t.Fatalf("%s: unexpected error %v", err) + t.Fatalf("%s: unexpected error %v", k, err) } } } // Header separator if _, err := fmt.Fprint(conn, "\r\n"); err != nil { - t.Fatalf("%s: unexpected error %v", err) + t.Fatalf("%s: unexpected error %v", k, err) } // Body if _, err := conn.Write(item.reqBody); err != nil { - t.Fatalf("%s: unexpected error %v", err) + t.Fatalf("%s: unexpected error %v", k, err) } // Read response response, err := ioutil.ReadAll(conn) if err != nil { - t.Errorf("%s: unexpected error %v", err) + t.Errorf("%s: unexpected error %v", k, err) continue } if !strings.HasSuffix(string(response), successfulResponse) { diff --git a/pkg/registry/thirdpartyresourcedata/codec_test.go b/pkg/registry/thirdpartyresourcedata/codec_test.go index 28cb84ee51e26..c7df150ec39df 100644 --- a/pkg/registry/thirdpartyresourcedata/codec_test.go +++ b/pkg/registry/thirdpartyresourcedata/codec_test.go @@ -173,7 +173,7 @@ func TestCreater(t *testing.T) { t.Errorf("[%s] unexpected non-error", test.name) } if !reflect.DeepEqual(test.expectedObj, out) { - t.Errorf("[%s] unexpected error: expect: %v, got: %v", test.expectedObj, out) + t.Errorf("[%s] unexpected error: expect: %v, got: %v", test.name, test.expectedObj, out) } } diff --git a/pkg/runtime/scheme_test.go b/pkg/runtime/scheme_test.go index f5a46d2fc1215..52cb796daa237 100644 --- a/pkg/runtime/scheme_test.go +++ b/pkg/runtime/scheme_test.go @@ -363,7 +363,7 @@ func TestUnversionedTypes(t *testing.T) { codec := serializer.NewCodecFactory(scheme).LegacyCodec(externalGV) if unv, ok := scheme.IsUnversioned(&InternalSimple{}); !unv || !ok { - t.Fatal("type not unversioned and in scheme: %t %t", unv, ok) + t.Fatalf("type not unversioned and in scheme: %t %t", unv, ok) } kind, err := scheme.ObjectKind(&InternalSimple{}) diff --git a/pkg/storage/etcd/etcd_watcher_test.go b/pkg/storage/etcd/etcd_watcher_test.go index 6a304ea86deb0..423d34eeb679c 100644 --- a/pkg/storage/etcd/etcd_watcher_test.go +++ b/pkg/storage/etcd/etcd_watcher_test.go @@ -317,7 +317,7 @@ func TestWatchEtcdState(t *testing.T) { } if e, a := endpoint, event.Object; !api.Semantic.DeepDerivative(e, a) { - t.Errorf("%s: expected %v, got %v", e, a) + t.Errorf("Unexpected error: expected %v, got %v", e, a) } } @@ -367,7 +367,7 @@ func TestWatchFromZeroIndex(t *testing.T) { } if e, a := pod, event.Object; !api.Semantic.DeepDerivative(e, a) { - t.Errorf("%s: expected %v, got %v", e, a) + t.Errorf("Unexpected error: expected %v, got %v", e, a) } } @@ -397,7 +397,7 @@ func TestWatchListFromZeroIndex(t *testing.T) { } if e, a := pod, event.Object; !api.Semantic.DeepDerivative(e, a) { - t.Errorf("%s: expected %v, got %v", e, a) + t.Errorf("Unexpected error: expected %v, got %v", e, a) } } diff --git a/pkg/util/httpstream/httpstream_test.go b/pkg/util/httpstream/httpstream_test.go index 7a1bbaefb89c7..4dd2e05792d34 100644 --- a/pkg/util/httpstream/httpstream_test.go +++ b/pkg/util/httpstream/httpstream_test.go @@ -109,7 +109,7 @@ func TestHandshake(t *testing.T) { continue } if w.statusCode != nil { - t.Errorf("%s: unexpected non-nil w.statusCode: %d", w.statusCode) + t.Errorf("%s: unexpected non-nil w.statusCode: %d", name, w.statusCode) } // verify response headers diff --git a/pkg/util/oom/oom_linux.go b/pkg/util/oom/oom_linux.go index 5503bad8c2ca5..90a753c16957d 100644 --- a/pkg/util/oom/oom_linux.go +++ b/pkg/util/oom/oom_linux.go @@ -82,7 +82,7 @@ func applyOOMScoreAdj(pid int, oomScoreAdj int) error { if syscallNotExists(err) { return os.ErrNotExist } - err = fmt.Errorf("failed to apply oom-score-adj to pid %d (%v)", err) + err = fmt.Errorf("failed to apply oom-score-adj to pid %d (%v)", pid, err) } } return err diff --git a/pkg/util/strategicpatch/patch_test.go b/pkg/util/strategicpatch/patch_test.go index 753d0d724518a..ac4027fc0c68f 100644 --- a/pkg/util/strategicpatch/patch_test.go +++ b/pkg/util/strategicpatch/patch_test.go @@ -239,7 +239,7 @@ func TestSortMergeLists(t *testing.T) { original := testObjectToJSONOrFail(t, c.Original, c.Description) sorted := testObjectToJSONOrFail(t, c.Sorted, c.Description) if !reflect.DeepEqual(original, sorted) { - t.Errorf("error in test case: %s\ncannot sort object:\n%s\n%sexpected:\n%s\ngot:\n%s\n", + t.Errorf("error in test case: %s\ncannot sort object:\n%s\nexpected:\n%s\ngot:\n%s\n", c.Description, toYAMLOrError(c.Original), toYAMLOrError(c.Sorted), jsonToYAMLOrError(original)) } } @@ -1814,7 +1814,7 @@ func testTwoWayPatch(t *testing.T, c StrategicMergePatchTestCase) { actual, err := CreateTwoWayMergePatch(original, modified, mergeItem) if err != nil { t.Errorf("error: %s\nin test case: %s\ncannot create two way patch: %s:\n%s\n", - err, c.Description, toYAMLOrError(c.StrategicMergePatchTestCaseData)) + err, c.Description, original, toYAMLOrError(c.StrategicMergePatchTestCaseData)) return } diff --git a/pkg/util/wsstream/stream_test.go b/pkg/util/wsstream/stream_test.go index 6d9e880547fb6..6bf1f4b139487 100644 --- a/pkg/util/wsstream/stream_test.go +++ b/pkg/util/wsstream/stream_test.go @@ -224,7 +224,7 @@ func expectWebSocketFrames(r *Reader, t *testing.T, fn func(*websocket.Conn), fr return err } if !reflect.DeepEqual(frames[i], data) { - return fmt.Errorf("frame %d did not match expected: %v", data) + return fmt.Errorf("frame %d did not match expected: %v", data, err) } } var data []byte diff --git a/plugin/pkg/admission/alwayspullimages/admission_test.go b/plugin/pkg/admission/alwayspullimages/admission_test.go index ba7d88b54bd93..ad9f14a857ed3 100644 --- a/plugin/pkg/admission/alwayspullimages/admission_test.go +++ b/plugin/pkg/admission/alwayspullimages/admission_test.go @@ -46,7 +46,7 @@ func TestAdmission(t *testing.T) { } for _, c := range pod.Spec.Containers { if c.ImagePullPolicy != api.PullAlways { - t.Errorf("Container %s: expected pull always, got %v", c.ImagePullPolicy) + t.Errorf("Container %v: expected pull always, got %v", c, c.ImagePullPolicy) } } } diff --git a/plugin/pkg/admission/namespace/lifecycle/admission_test.go b/plugin/pkg/admission/namespace/lifecycle/admission_test.go index 0d7c518d7689a..dd6cca0fc9343 100644 --- a/plugin/pkg/admission/namespace/lifecycle/admission_test.go +++ b/plugin/pkg/admission/namespace/lifecycle/admission_test.go @@ -121,16 +121,16 @@ func TestAdmission(t *testing.T) { // verify create/update/delete of object in non-existent namespace throws error err = handler.Admit(admission.NewAttributesRecord(&badPod, api.Kind("Pod"), badPod.Namespace, badPod.Name, api.Resource("pods"), "", admission.Create, nil)) if err == nil { - t.Errorf("Expected an aerror that objects cannot be created in non-existant namespaces", err) + t.Errorf("Expected, but didn't get, an error (%v) that objects cannot be created in non-existant namespaces", err) } err = handler.Admit(admission.NewAttributesRecord(&badPod, api.Kind("Pod"), badPod.Namespace, badPod.Name, api.Resource("pods"), "", admission.Update, nil)) if err == nil { - t.Errorf("Expected an aerror that objects cannot be updated in non-existant namespaces", err) + t.Errorf("Expected, but didn't get, an error (%v) that objects cannot be updated in non-existant namespaces", err) } err = handler.Admit(admission.NewAttributesRecord(&badPod, api.Kind("Pod"), badPod.Namespace, badPod.Name, api.Resource("pods"), "", admission.Delete, nil)) if err == nil { - t.Errorf("Expected an aerror that objects cannot be deleted in non-existant namespaces", err) + t.Errorf("Expected, but didn't get, an error (%v) that objects cannot be deleted in non-existant namespaces", err) } } diff --git a/test/e2e/reboot.go b/test/e2e/reboot.go index 0a6d0ef5c55b1..0bbddb4de8564 100644 --- a/test/e2e/reboot.go +++ b/test/e2e/reboot.go @@ -165,7 +165,7 @@ func printStatusAndLogsForNotReadyPods(c *client.Client, ns string, podNames []s prefix = "Retrieving log for the last terminated container" } if err != nil { - Logf("%s %s, err: %v:\n%s\n", prefix, id, log) + Logf("%s %s, err: %v:\n%s\n", prefix, id, err, log) } else { Logf("%s %s:\n%s\n", prefix, id, log) } diff --git a/test/e2e/util.go b/test/e2e/util.go index 1b7ca9482dd3a..3039902d575b0 100644 --- a/test/e2e/util.go +++ b/test/e2e/util.go @@ -1011,7 +1011,7 @@ func waitForPodTerminatedInNamespace(c *client.Client, podName, reason, namespac if pod.Status.Reason == reason { return true, nil } else { - return true, fmt.Errorf("Expected pod %n/%n to be terminated with reason %v, got reason: ", namespace, podName, reason, pod.Status.Reason) + return true, fmt.Errorf("Expected pod %v in namespace %v to be terminated with reason %v, got reason: %v", podName, namespace, reason, pod.Status.Reason) } } diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/e2e_node/e2e_node_suite_test.go index f5a9a5e6af54e..3e14fedadfd4a 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/e2e_node/e2e_node_suite_test.go @@ -57,7 +57,7 @@ var _ = BeforeSuite(func() { if *nodeName == "" { output, err := exec.Command("hostname").CombinedOutput() if err != nil { - glog.Fatal("Could not get node name from hostname %v. Output:\n%s", err, output) + glog.Fatalf("Could not get node name from hostname %v. Output:\n%s", err, output) } *nodeName = strings.TrimSpace(fmt.Sprintf("%s", output)) } diff --git a/test/e2e_node/e2e_service.go b/test/e2e_node/e2e_service.go index 9749d738a7504..f30285a70063e 100644 --- a/test/e2e_node/e2e_service.go +++ b/test/e2e_node/e2e_service.go @@ -155,7 +155,7 @@ func (es *e2eService) startServer(cmd *healthCheckCommand) error { go func() { err := cmd.Run() if err != nil { - cmdErrorChan <- fmt.Errorf("%s Exited with status %v. Output:\n%s", cmd, err, *cmd.OutputBuffer) + cmdErrorChan <- fmt.Errorf("%s Exited with status %v. Output:\n%v", cmd, err, *cmd.OutputBuffer) } close(cmdErrorChan) }() diff --git a/test/images/netexec/netexec.go b/test/images/netexec/netexec.go index fc58ec12b2071..5c68a8d6351b2 100644 --- a/test/images/netexec/netexec.go +++ b/test/images/netexec/netexec.go @@ -374,11 +374,11 @@ func startUDPServer(udpPort int) { if len(parts) == 2 { resp = parts[1] } - log.Println("Echoing %q") + log.Printf("Echoing %v\n", resp) _, err = serverConn.WriteToUDP([]byte(resp), clientAddress) assertNoError(err) } else if len(receivedText) > 0 { - log.Println("Unknown udp command received. ", receivedText) + log.Printf("Unknown udp command received: %v\n", receivedText) } } }