Skip to content

Commit a684822

Browse files
committed
Handling error returned by request.Request.ParseForm()
1 parent 5668dbd commit a684822

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/kubelet/server/stats/handler.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
cadvisorapi "github.com/google/cadvisor/info/v1"
2929
"k8s.io/klog"
3030

31-
"k8s.io/api/core/v1"
31+
v1 "k8s.io/api/core/v1"
3232
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3333
"k8s.io/apimachinery/pkg/types"
3434
statsapi "k8s.io/kubernetes/pkg/kubelet/apis/stats/v1alpha1"
@@ -215,13 +215,17 @@ func (h *handler) handleStats(request *restful.Request, response *restful.Respon
215215
// If "only_cpu_and_memory" GET param is true then only cpu and memory is returned in response.
216216
func (h *handler) handleSummary(request *restful.Request, response *restful.Response) {
217217
onlyCPUAndMemory := false
218-
request.Request.ParseForm()
218+
var err error
219+
err = request.Request.ParseForm()
220+
if err != nil {
221+
handleError(response, "/stats/summary", err)
222+
return
223+
}
219224
if onlyCluAndMemoryParam, found := request.Request.Form["only_cpu_and_memory"]; found &&
220225
len(onlyCluAndMemoryParam) == 1 && onlyCluAndMemoryParam[0] == "true" {
221226
onlyCPUAndMemory = true
222227
}
223228
var summary *statsapi.Summary
224-
var err error
225229
if onlyCPUAndMemory {
226230
summary, err = h.summaryProvider.GetCPUAndMemoryStats()
227231
} else {

0 commit comments

Comments
 (0)