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
cbbb3f7a
Commit
cbbb3f7a
authored
Nov 20, 2015
by
jiangyaoguo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return response StatusCode when http probe fail
parent
315b9000
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
3 deletions
+7
-3
http.go
pkg/probe/http/http.go
+2
-1
http_test.go
pkg/probe/http/http_test.go
+5
-2
No files found.
pkg/probe/http/http.go
View file @
cbbb3f7a
...
@@ -18,6 +18,7 @@ package http
...
@@ -18,6 +18,7 @@ package http
import
(
import
(
"crypto/tls"
"crypto/tls"
"fmt"
"io/ioutil"
"io/ioutil"
"net/http"
"net/http"
"net/url"
"net/url"
...
@@ -72,5 +73,5 @@ func DoHTTPProbe(url *url.URL, client HTTPGetInterface) (probe.Result, string, e
...
@@ -72,5 +73,5 @@ func DoHTTPProbe(url *url.URL, client HTTPGetInterface) (probe.Result, string, e
return
probe
.
Success
,
body
,
nil
return
probe
.
Success
,
body
,
nil
}
}
glog
.
V
(
4
)
.
Infof
(
"Probe failed for %s, Response: %v"
,
url
.
String
(),
*
res
)
glog
.
V
(
4
)
.
Infof
(
"Probe failed for %s, Response: %v"
,
url
.
String
(),
*
res
)
return
probe
.
Failure
,
body
,
nil
return
probe
.
Failure
,
fmt
.
Sprintf
(
"HTTP probe failed with statuscode: %d"
,
res
.
StatusCode
)
,
nil
}
}
pkg/probe/http/http_test.go
View file @
cbbb3f7a
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
http
package
http
import
(
import
(
"fmt"
"net"
"net"
"net/http"
"net/http"
"net/http/httptest"
"net/http/httptest"
...
@@ -29,6 +30,8 @@ import (
...
@@ -29,6 +30,8 @@ import (
"k8s.io/kubernetes/pkg/probe"
"k8s.io/kubernetes/pkg/probe"
)
)
const
FailureCode
int
=
-
1
func
containsAny
(
s
string
,
substrs
[]
string
)
bool
{
func
containsAny
(
s
string
,
substrs
[]
string
)
bool
{
for
_
,
substr
:=
range
substrs
{
for
_
,
substr
:=
range
substrs
{
if
strings
.
Contains
(
s
,
substr
)
{
if
strings
.
Contains
(
s
,
substr
)
{
...
@@ -61,9 +64,9 @@ func TestHTTPProbeChecker(t *testing.T) {
...
@@ -61,9 +64,9 @@ func TestHTTPProbeChecker(t *testing.T) {
[]
string
{
"ok body"
},
[]
string
{
"ok body"
},
},
},
{
{
handleReq
(
-
1
,
"fail body"
),
handleReq
(
FailureCode
,
"fail body"
),
probe
.
Failure
,
probe
.
Failure
,
[]
string
{
"fail body"
},
[]
string
{
fmt
.
Sprintf
(
"HTTP probe failed with statuscode: %d"
,
FailureCode
)
},
},
},
{
{
func
(
w
http
.
ResponseWriter
)
{
func
(
w
http
.
ResponseWriter
)
{
...
...
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