Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
82dff5fb
Commit
82dff5fb
authored
Jun 30, 2017
by
sakeven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HTTPExtender: shoud close resp.Body even when StatusCode not ok
Signed-off-by:
sakeven
<
jc5930@sina.cn
>
parent
06413863
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
12 deletions
+4
-12
extender.go
plugin/pkg/scheduler/core/extender.go
+4
-12
No files found.
plugin/pkg/scheduler/core/extender.go
View file @
82dff5fb
...
@@ -20,8 +20,8 @@ import (
...
@@ -20,8 +20,8 @@ import (
"bytes"
"bytes"
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io/ioutil"
"net/http"
"net/http"
"strings"
"time"
"time"
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
...
@@ -229,7 +229,7 @@ func (h *HTTPExtender) send(action string, args interface{}, result interface{})
...
@@ -229,7 +229,7 @@ func (h *HTTPExtender) send(action string, args interface{}, result interface{})
return
err
return
err
}
}
url
:=
h
.
extenderURL
+
"/"
+
action
url
:=
strings
.
TrimRight
(
h
.
extenderURL
,
"/"
)
+
"/"
+
action
req
,
err
:=
http
.
NewRequest
(
"POST"
,
url
,
bytes
.
NewReader
(
out
))
req
,
err
:=
http
.
NewRequest
(
"POST"
,
url
,
bytes
.
NewReader
(
out
))
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -242,19 +242,11 @@ func (h *HTTPExtender) send(action string, args interface{}, result interface{})
...
@@ -242,19 +242,11 @@ func (h *HTTPExtender) send(action string, args interface{}, result interface{})
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
defer
resp
.
Body
.
Close
()
if
resp
.
StatusCode
!=
http
.
StatusOK
{
if
resp
.
StatusCode
!=
http
.
StatusOK
{
return
fmt
.
Errorf
(
"Failed %v with extender at URL %v, code %v"
,
action
,
h
.
extenderURL
,
resp
.
StatusCode
)
return
fmt
.
Errorf
(
"Failed %v with extender at URL %v, code %v"
,
action
,
h
.
extenderURL
,
resp
.
StatusCode
)
}
}
defer
resp
.
Body
.
Close
()
return
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
result
)
body
,
err
:=
ioutil
.
ReadAll
(
resp
.
Body
)
if
err
!=
nil
{
return
err
}
if
err
:=
json
.
Unmarshal
(
body
,
result
);
err
!=
nil
{
return
err
}
return
nil
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment