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
b971c3e2
Commit
b971c3e2
authored
Sep 12, 2018
by
Jon Friesen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix golint for pkg/probe
This change adds comments to exported things and renames the tcp, http, and exec probe interfaces to just be Prober within their namespace. Issue #68026
parent
426ef9d3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
21 deletions
+31
-21
.golint_failures
hack/.golint_failures
+0
-4
prober.go
pkg/kubelet/prober/prober.go
+4
-4
exec.go
pkg/probe/exec/exec.go
+8
-4
http.go
pkg/probe/http/http.go
+9
-6
probe.go
pkg/probe/probe.go
+4
-0
tcp.go
pkg/probe/tcp/tcp.go
+5
-2
validator.go
pkg/registry/core/componentstatus/validator.go
+1
-1
No files found.
hack/.golint_failures
View file @
b971c3e2
...
@@ -250,10 +250,6 @@ pkg/master/tunneler
...
@@ -250,10 +250,6 @@ pkg/master/tunneler
pkg/printers
pkg/printers
pkg/printers/internalversion
pkg/printers/internalversion
pkg/printers/storage
pkg/printers/storage
pkg/probe
pkg/probe/exec
pkg/probe/http
pkg/probe/tcp
pkg/proxy
pkg/proxy
pkg/proxy/apis/config
pkg/proxy/apis/config
pkg/proxy/apis/config/v1alpha1
pkg/proxy/apis/config/v1alpha1
...
...
pkg/kubelet/prober/prober.go
View file @
b971c3e2
...
@@ -46,13 +46,13 @@ const maxProbeRetries = 3
...
@@ -46,13 +46,13 @@ const maxProbeRetries = 3
// Prober helps to check the liveness/readiness of a container.
// Prober helps to check the liveness/readiness of a container.
type
prober
struct
{
type
prober
struct
{
exec
execprobe
.
Exec
Prober
exec
execprobe
.
Prober
// probe types needs different httprobe instances so they don't
// probe types needs different httprobe instances so they don't
// share a connection pool which can cause collsions to the
// share a connection pool which can cause collsions to the
// same host:port and transient failures. See #49740.
// same host:port and transient failures. See #49740.
readinessHttp
httprobe
.
HTTP
Prober
readinessHttp
httprobe
.
Prober
livenessHttp
httprobe
.
HTTP
Prober
livenessHttp
httprobe
.
Prober
tcp
tcprobe
.
TCP
Prober
tcp
tcprobe
.
Prober
runner
kubecontainer
.
ContainerCommandRunner
runner
kubecontainer
.
ContainerCommandRunner
refManager
*
kubecontainer
.
RefManager
refManager
*
kubecontainer
.
RefManager
...
...
pkg/probe/exec/exec.go
View file @
b971c3e2
...
@@ -23,16 +23,21 @@ import (
...
@@ -23,16 +23,21 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
)
)
func
New
()
ExecProber
{
// New creates a Prober.
func
New
()
Prober
{
return
execProber
{}
return
execProber
{}
}
}
type
ExecProber
interface
{
// Prober is an interface defining the Probe object for container readiness/liveness checks.
type
Prober
interface
{
Probe
(
e
exec
.
Cmd
)
(
probe
.
Result
,
string
,
error
)
Probe
(
e
exec
.
Cmd
)
(
probe
.
Result
,
string
,
error
)
}
}
type
execProber
struct
{}
type
execProber
struct
{}
// Probe executes a command to check the liveness/readiness of container
// from executing a command. Returns the Result status, command output, and
// errors if any.
func
(
pr
execProber
)
Probe
(
e
exec
.
Cmd
)
(
probe
.
Result
,
string
,
error
)
{
func
(
pr
execProber
)
Probe
(
e
exec
.
Cmd
)
(
probe
.
Result
,
string
,
error
)
{
data
,
err
:=
e
.
CombinedOutput
()
data
,
err
:=
e
.
CombinedOutput
()
glog
.
V
(
4
)
.
Infof
(
"Exec probe response: %q"
,
string
(
data
))
glog
.
V
(
4
)
.
Infof
(
"Exec probe response: %q"
,
string
(
data
))
...
@@ -41,9 +46,8 @@ func (pr execProber) Probe(e exec.Cmd) (probe.Result, string, error) {
...
@@ -41,9 +46,8 @@ func (pr execProber) Probe(e exec.Cmd) (probe.Result, string, error) {
if
ok
{
if
ok
{
if
exit
.
ExitStatus
()
==
0
{
if
exit
.
ExitStatus
()
==
0
{
return
probe
.
Success
,
string
(
data
),
nil
return
probe
.
Success
,
string
(
data
),
nil
}
else
{
return
probe
.
Failure
,
string
(
data
),
nil
}
}
return
probe
.
Failure
,
string
(
data
),
nil
}
}
return
probe
.
Unknown
,
""
,
err
return
probe
.
Unknown
,
""
,
err
}
}
...
...
pkg/probe/http/http.go
View file @
b971c3e2
...
@@ -31,18 +31,20 @@ import (
...
@@ -31,18 +31,20 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
)
)
func
New
()
HTTPProber
{
// New creates Prober that will skip TLS verification while probing.
func
New
()
Prober
{
tlsConfig
:=
&
tls
.
Config
{
InsecureSkipVerify
:
true
}
tlsConfig
:=
&
tls
.
Config
{
InsecureSkipVerify
:
true
}
return
NewWithTLSConfig
(
tlsConfig
)
return
NewWithTLSConfig
(
tlsConfig
)
}
}
// NewWithTLSConfig takes tls config as parameter.
// NewWithTLSConfig takes tls config as parameter.
func
NewWithTLSConfig
(
config
*
tls
.
Config
)
HTTP
Prober
{
func
NewWithTLSConfig
(
config
*
tls
.
Config
)
Prober
{
transport
:=
utilnet
.
SetTransportDefaults
(
&
http
.
Transport
{
TLSClientConfig
:
config
,
DisableKeepAlives
:
true
})
transport
:=
utilnet
.
SetTransportDefaults
(
&
http
.
Transport
{
TLSClientConfig
:
config
,
DisableKeepAlives
:
true
})
return
httpProber
{
transport
}
return
httpProber
{
transport
}
}
}
type
HTTPProber
interface
{
// Prober is an interface that defines the Probe function for doing HTTP readiness/liveness checks.
type
Prober
interface
{
Probe
(
url
*
url
.
URL
,
headers
http
.
Header
,
timeout
time
.
Duration
)
(
probe
.
Result
,
string
,
error
)
Probe
(
url
*
url
.
URL
,
headers
http
.
Header
,
timeout
time
.
Duration
)
(
probe
.
Result
,
string
,
error
)
}
}
...
@@ -50,12 +52,13 @@ type httpProber struct {
...
@@ -50,12 +52,13 @@ type httpProber struct {
transport
*
http
.
Transport
transport
*
http
.
Transport
}
}
// Probe returns a ProbeRunner capable of running an
http
check.
// Probe returns a ProbeRunner capable of running an
HTTP
check.
func
(
pr
httpProber
)
Probe
(
url
*
url
.
URL
,
headers
http
.
Header
,
timeout
time
.
Duration
)
(
probe
.
Result
,
string
,
error
)
{
func
(
pr
httpProber
)
Probe
(
url
*
url
.
URL
,
headers
http
.
Header
,
timeout
time
.
Duration
)
(
probe
.
Result
,
string
,
error
)
{
return
DoHTTPProbe
(
url
,
headers
,
&
http
.
Client
{
Timeout
:
timeout
,
Transport
:
pr
.
transport
})
return
DoHTTPProbe
(
url
,
headers
,
&
http
.
Client
{
Timeout
:
timeout
,
Transport
:
pr
.
transport
})
}
}
type
HTTPGetInterface
interface
{
// GetHTTPInterface is an interface for making HTTP requests, that returns a response and error.
type
GetHTTPInterface
interface
{
Do
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
Do
(
req
*
http
.
Request
)
(
*
http
.
Response
,
error
)
}
}
...
@@ -63,7 +66,7 @@ type HTTPGetInterface interface {
...
@@ -63,7 +66,7 @@ type HTTPGetInterface interface {
// If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Success.
// If the HTTP response code is successful (i.e. 400 > code >= 200), it returns Success.
// If the HTTP response code is unsuccessful or HTTP communication fails, it returns Failure.
// If the HTTP response code is unsuccessful or HTTP communication fails, it returns Failure.
// This is exported because some other packages may want to do direct HTTP probes.
// This is exported because some other packages may want to do direct HTTP probes.
func
DoHTTPProbe
(
url
*
url
.
URL
,
headers
http
.
Header
,
client
HTTPGet
Interface
)
(
probe
.
Result
,
string
,
error
)
{
func
DoHTTPProbe
(
url
*
url
.
URL
,
headers
http
.
Header
,
client
GetHTTP
Interface
)
(
probe
.
Result
,
string
,
error
)
{
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
.
String
(),
nil
)
req
,
err
:=
http
.
NewRequest
(
"GET"
,
url
.
String
(),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
// Convert errors into failures to catch timeouts.
// Convert errors into failures to catch timeouts.
...
...
pkg/probe/probe.go
View file @
b971c3e2
...
@@ -16,10 +16,14 @@ limitations under the License.
...
@@ -16,10 +16,14 @@ limitations under the License.
package
probe
package
probe
// Result is a string used to handle the results for probing container readiness/livenss
type
Result
string
type
Result
string
const
(
const
(
// Success Result
Success
Result
=
"success"
Success
Result
=
"success"
// Failure Result
Failure
Result
=
"failure"
Failure
Result
=
"failure"
// Unknown Result
Unknown
Result
=
"unknown"
Unknown
Result
=
"unknown"
)
)
pkg/probe/tcp/tcp.go
View file @
b971c3e2
...
@@ -26,16 +26,19 @@ import (
...
@@ -26,16 +26,19 @@ import (
"github.com/golang/glog"
"github.com/golang/glog"
)
)
func
New
()
TCPProber
{
// New creates Prober.
func
New
()
Prober
{
return
tcpProber
{}
return
tcpProber
{}
}
}
type
TCPProber
interface
{
// Prober is an interface that defines the Probe function for doing TCP readiness/liveness checks.
type
Prober
interface
{
Probe
(
host
string
,
port
int
,
timeout
time
.
Duration
)
(
probe
.
Result
,
string
,
error
)
Probe
(
host
string
,
port
int
,
timeout
time
.
Duration
)
(
probe
.
Result
,
string
,
error
)
}
}
type
tcpProber
struct
{}
type
tcpProber
struct
{}
// Probe returns a ProbeRunner capable of running an TCP check.
func
(
pr
tcpProber
)
Probe
(
host
string
,
port
int
,
timeout
time
.
Duration
)
(
probe
.
Result
,
string
,
error
)
{
func
(
pr
tcpProber
)
Probe
(
host
string
,
port
int
,
timeout
time
.
Duration
)
(
probe
.
Result
,
string
,
error
)
{
return
DoTCPProbe
(
net
.
JoinHostPort
(
host
,
strconv
.
Itoa
(
port
)),
timeout
)
return
DoTCPProbe
(
net
.
JoinHostPort
(
host
,
strconv
.
Itoa
(
port
)),
timeout
)
}
}
...
...
pkg/registry/core/componentstatus/validator.go
View file @
b971c3e2
...
@@ -45,7 +45,7 @@ type Server struct {
...
@@ -45,7 +45,7 @@ type Server struct {
EnableHTTPS
bool
EnableHTTPS
bool
TLSConfig
*
tls
.
Config
TLSConfig
*
tls
.
Config
Validate
ValidatorFn
Validate
ValidatorFn
Prober
httpprober
.
HTTP
Prober
Prober
httpprober
.
Prober
Once
sync
.
Once
Once
sync
.
Once
}
}
...
...
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