mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #48313 from timstclair/lint
Automatic merge from submit-queue (batch tested with PRs 48317, 48313, 48351, 48357, 48115) Cleanup lint errors in the pkg/kubelet/server/... directory Cleanup some issues that were found while experimenting with https://github.com/alecthomas/gometalinter on the `pkg/kubelet/server/...` directories.
This commit is contained in:
commit
21038e362c
@ -158,7 +158,6 @@ type websocketStreamPair struct {
|
||||
// request over a websocket connection
|
||||
type websocketStreamHandler struct {
|
||||
conn *wsstream.Conn
|
||||
ports []int32
|
||||
streamPairs []*websocketStreamPair
|
||||
pod string
|
||||
uid types.UID
|
||||
|
@ -423,7 +423,7 @@ func handleResizeEvents(stream io.Reader, channel chan<- remotecommand.TerminalS
|
||||
}
|
||||
}
|
||||
|
||||
func v1WriteStatusFunc(stream io.WriteCloser) func(status *apierrors.StatusError) error {
|
||||
func v1WriteStatusFunc(stream io.Writer) func(status *apierrors.StatusError) error {
|
||||
return func(status *apierrors.StatusError) error {
|
||||
if status.Status().Status == metav1.StatusSuccess {
|
||||
return nil // send error messages
|
||||
@ -435,7 +435,7 @@ func v1WriteStatusFunc(stream io.WriteCloser) func(status *apierrors.StatusError
|
||||
|
||||
// v4WriteStatusFunc returns a WriteStatusFunc that marshals a given api Status
|
||||
// as json in the error channel.
|
||||
func v4WriteStatusFunc(stream io.WriteCloser) func(status *apierrors.StatusError) error {
|
||||
func v4WriteStatusFunc(stream io.Writer) func(status *apierrors.StatusError) error {
|
||||
return func(status *apierrors.StatusError) error {
|
||||
bs, err := json.Marshal(status.Status())
|
||||
if err != nil {
|
||||
|
@ -267,8 +267,7 @@ func (s *Server) InstallDefaultHandlers() {
|
||||
healthz.PingHealthz,
|
||||
healthz.NamedCheck("syncloop", s.syncLoopHealthCheck),
|
||||
)
|
||||
var ws *restful.WebService
|
||||
ws = new(restful.WebService)
|
||||
ws := new(restful.WebService)
|
||||
ws.
|
||||
Path("/pods").
|
||||
Produces(restful.MIME_JSON)
|
||||
@ -296,9 +295,8 @@ const pprofBasePath = "/debug/pprof/"
|
||||
// InstallDebuggingHandlers registers the HTTP request patterns that serve logs or run commands/containers
|
||||
func (s *Server) InstallDebuggingHandlers(criHandler http.Handler) {
|
||||
glog.Infof("Adding debug handlers to kubelet server.")
|
||||
var ws *restful.WebService
|
||||
|
||||
ws = new(restful.WebService)
|
||||
ws := new(restful.WebService)
|
||||
ws.
|
||||
Path("/run")
|
||||
ws.Route(ws.POST("/{podNamespace}/{podID}/{containerName}").
|
||||
@ -429,7 +427,7 @@ func (s *Server) syncLoopHealthCheck(req *http.Request) error {
|
||||
}
|
||||
enterLoopTime := s.host.LatestLoopEntryTime()
|
||||
if !enterLoopTime.IsZero() && time.Now().After(enterLoopTime.Add(duration)) {
|
||||
return fmt.Errorf("Sync Loop took longer than expected.")
|
||||
return fmt.Errorf("sync Loop took longer than expected")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -248,21 +248,6 @@ func newServerTest() *serverTestFramework {
|
||||
return fw
|
||||
}
|
||||
|
||||
// encodeJSON returns obj marshalled as a JSON string, panicing on any errors
|
||||
func encodeJSON(obj interface{}) string {
|
||||
data, err := json.Marshal(obj)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return string(data)
|
||||
}
|
||||
|
||||
func readResp(resp *http.Response) (string, error) {
|
||||
defer resp.Body.Close()
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
return string(body), err
|
||||
}
|
||||
|
||||
// A helper function to return the correct pod name.
|
||||
func getPodName(name, namespace string) string {
|
||||
if namespace == "" {
|
||||
|
@ -172,7 +172,7 @@ func TestServeWSPortForward(t *testing.T) {
|
||||
}
|
||||
|
||||
if test.containerData != "" {
|
||||
channel, data, err = wsRead(ws)
|
||||
_, data, err = wsRead(ws)
|
||||
if err != nil {
|
||||
t.Fatalf("%d: unexpected error reading container data: %v", i, err)
|
||||
}
|
||||
|
@ -376,13 +376,6 @@ func checkMemoryStats(t *testing.T, label string, seed int, info v2.ContainerInf
|
||||
}
|
||||
}
|
||||
|
||||
func checkFsStats(t *testing.T, capacity uint64, Available uint64, inodes uint64, inodesFree uint64, fs *kubestats.FsStats) {
|
||||
assert.EqualValues(t, capacity, *fs.CapacityBytes)
|
||||
assert.EqualValues(t, Available, *fs.AvailableBytes)
|
||||
assert.EqualValues(t, inodesFree, *fs.InodesFree)
|
||||
assert.EqualValues(t, inodes, *fs.Inodes)
|
||||
}
|
||||
|
||||
func TestCustomMetrics(t *testing.T) {
|
||||
spec := []v1.MetricSpec{
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user