Merge pull request #23660 from goltermann/vetclean

Automatic merge from submit-queue

Additional go vet fixes

Mostly:
- pass lock by value
- bad syntax for struct tag value
- example functions not formatted properly
This commit is contained in:
k8s-merge-robot
2016-04-12 06:22:16 -07:00
33 changed files with 136 additions and 118 deletions

View File

@@ -18,7 +18,6 @@ package e2e
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
@@ -90,13 +89,13 @@ func runK8petstore(restServers int, loadGenerators int, c *client.Client, ns str
// Run the k8petstore app, and log / fail if it returns any errors.
// This should return quickly, assuming containers are downloaded.
if err = cmd.Start(); err != nil {
log.Fatal(err)
Failf("%v", err)
}
// Make sure there are no command errors.
if err = cmd.Wait(); err != nil {
if exiterr, ok := err.(*exec.ExitError); ok {
if status, ok := exiterr.Sys().(syscall.WaitStatus); ok {
log.Printf("Exit Status: %d", status.ExitStatus())
Logf("Exit Status: %d", status.ExitStatus())
}
}
}

View File

@@ -67,7 +67,7 @@ type LogsSizeVerifier struct {
client *client.Client
stopChannel chan bool
// data stores LogSizeData groupped per IP and log_path
data LogsSizeData
data *LogsSizeData
masterAddress string
nodeAddresses []string
wg sync.WaitGroup
@@ -117,13 +117,13 @@ type WorkItem struct {
backoffMultiplier int
}
func prepareData(masterAddress string, nodeAddresses []string) LogsSizeData {
func prepareData(masterAddress string, nodeAddresses []string) *LogsSizeData {
data := make(LogSizeDataTimeseries)
ips := append(nodeAddresses, masterAddress)
for _, ip := range ips {
data[ip] = make(map[string][]TimestampedSize)
}
return LogsSizeData{
return &LogsSizeData{
data: data,
lock: sync.Mutex{},
}
@@ -164,7 +164,7 @@ func NewLogsVerifier(c *client.Client, stopChannel chan bool) *LogsSizeVerifier
for i := 0; i < workersNo; i++ {
workers[i] = &LogSizeGatherer{
stopChannel: stopChannel,
data: &verifier.data,
data: verifier.data,
wg: &verifier.wg,
workChannel: workChannel,
}

View File

@@ -309,23 +309,23 @@ func nowStamp() string {
return time.Now().Format(time.StampMilli)
}
func logf(level string, format string, args ...interface{}) {
func log(level string, format string, args ...interface{}) {
fmt.Fprintf(GinkgoWriter, nowStamp()+": "+level+": "+format+"\n", args...)
}
func Logf(format string, args ...interface{}) {
logf("INFO", format, args...)
log("INFO", format, args...)
}
func Failf(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
logf("FAIL", msg)
log("INFO", msg)
Fail(nowStamp()+": "+msg, 1)
}
func Skipf(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
logf("SKIP", msg)
log("INFO", msg)
Skip(nowStamp() + ": " + msg)
}

View File

@@ -47,11 +47,11 @@ type ResourceConsumerHandler struct {
metricsLock sync.Mutex
}
func NewResourceConsumerHandler() ResourceConsumerHandler {
return ResourceConsumerHandler{metrics: map[string]float64{}}
func NewResourceConsumerHandler() *ResourceConsumerHandler {
return &ResourceConsumerHandler{metrics: map[string]float64{}}
}
func (handler ResourceConsumerHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (handler *ResourceConsumerHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// handle exposing metrics in Prometheus format (both GET & POST)
if req.URL.Path == metricsAddress {
handler.handleMetrics(w)
@@ -89,7 +89,7 @@ func (handler ResourceConsumerHandler) ServeHTTP(w http.ResponseWriter, req *htt
http.Error(w, unknownFunction, http.StatusNotFound)
}
func (handler ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter, query url.Values) {
func (handler *ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter, query url.Values) {
// geting string data for consumeCPU
durationSecString := query.Get(durationSecQuery)
millicoresString := query.Get(millicoresQuery)
@@ -112,7 +112,7 @@ func (handler ResourceConsumerHandler) handleConsumeCPU(w http.ResponseWriter, q
fmt.Fprintln(w, durationSec, durationSecQuery)
}
func (handler ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter, query url.Values) {
func (handler *ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter, query url.Values) {
// geting string data for consumeMem
durationSecString := query.Get(durationSecQuery)
megabytesString := query.Get(megabytesQuery)
@@ -135,13 +135,13 @@ func (handler ResourceConsumerHandler) handleConsumeMem(w http.ResponseWriter, q
fmt.Fprintln(w, durationSec, durationSecQuery)
}
func (handler ResourceConsumerHandler) handleGetCurrentStatus(w http.ResponseWriter) {
func (handler *ResourceConsumerHandler) handleGetCurrentStatus(w http.ResponseWriter) {
GetCurrentStatus()
fmt.Fprintln(w, "Warning: not implemented!")
fmt.Fprint(w, getCurrentStatusAddress[1:])
}
func (handler ResourceConsumerHandler) handleMetrics(w http.ResponseWriter) {
func (handler *ResourceConsumerHandler) handleMetrics(w http.ResponseWriter) {
handler.metricsLock.Lock()
defer handler.metricsLock.Unlock()
for k, v := range handler.metrics {
@@ -151,7 +151,7 @@ func (handler ResourceConsumerHandler) handleMetrics(w http.ResponseWriter) {
}
}
func (handler ResourceConsumerHandler) bumpMetric(metric string, delta float64, duration time.Duration) {
func (handler *ResourceConsumerHandler) bumpMetric(metric string, delta float64, duration time.Duration) {
handler.metricsLock.Lock()
if _, ok := handler.metrics[metric]; ok {
handler.metrics[metric] += delta
@@ -167,7 +167,7 @@ func (handler ResourceConsumerHandler) bumpMetric(metric string, delta float64,
handler.metricsLock.Unlock()
}
func (handler ResourceConsumerHandler) handleBumpMetric(w http.ResponseWriter, query url.Values) {
func (handler *ResourceConsumerHandler) handleBumpMetric(w http.ResponseWriter, query url.Values) {
// geting string data for handleBumpMetric
metric := query.Get(metricNameQuery)
deltaString := query.Get(deltaQuery)