Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
516b3d56
Commit
516b3d56
authored
7 years ago
by
Chelsea Holland Komlo
Browse files
Options
Download
Email Patches
Plain Diff
fix up codereview feedback
parent
05782713
Branches unavailable
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
client/driver/docker.go
+3
-3
client/driver/docker.go
client/fingerprint_manager.go
+10
-3
client/fingerprint_manager.go
nomad/structs/node.go
+1
-2
nomad/structs/node.go
scheduler/feasible.go
+4
-4
scheduler/feasible.go
with
18 additions
and
12 deletions
+18
-12
client/driver/docker.go
+
3
-
3
View file @
516b3d56
...
...
@@ -551,7 +551,7 @@ func (d *DockerDriver) Fingerprint(req *cstructs.FingerprintRequest, resp *cstru
return
nil
}
// HealthChck implements the interface for the HealthCheck interface. This
// HealthCh
e
ck implements the interface for the HealthCheck interface. This
// performs a health check on the docker driver, asserting whether the docker
// driver is responsive to a `docker ps` command.
func
(
d
*
DockerDriver
)
HealthCheck
(
req
*
cstructs
.
HealthCheckRequest
,
resp
*
cstructs
.
HealthCheckResponse
)
error
{
...
...
@@ -562,14 +562,14 @@ func (d *DockerDriver) HealthCheck(req *cstructs.HealthCheckRequest, resp *cstru
client
,
_
,
err
:=
d
.
dockerClients
()
if
err
!=
nil
{
d
.
logger
.
Printf
(
"[WARN] driver.docker:
docker d
rive
r is available but is unresponsive to `docker ps`"
)
d
.
logger
.
Printf
(
"[WARN] driver.docker:
failed to ret
ri
e
ve
Docker client in the process of a docker health check: %v"
,
err
)
resp
.
AddDriverInfo
(
"docker"
,
unhealthy
)
return
err
}
_
,
err
=
client
.
ListContainers
(
docker
.
ListContainersOptions
{
All
:
false
})
if
err
!=
nil
{
d
.
logger
.
Printf
(
"[WARN] driver.docker:
docker driver is available but is unresponsive to `docker ps`"
)
d
.
logger
.
Printf
(
"[WARN] driver.docker:
failed to list Docker containers in the process of a docker health check: %v"
,
err
)
resp
.
AddDriverInfo
(
"docker"
,
unhealthy
)
return
err
}
...
...
This diff is collapsed.
Click to expand it.
client/fingerprint_manager.go
+
10
-
3
View file @
516b3d56
...
...
@@ -2,6 +2,7 @@ package client
import
(
"log"
"strings"
"sync"
"time"
...
...
@@ -24,7 +25,7 @@ type FingerprintManager struct {
// associated node
updateNodeAttributes
func
(
*
cstructs
.
FingerprintResponse
)
*
structs
.
Node
//
U
pdateHealthCheck is a callback to the client to update the state of the
//
u
pdateHealthCheck is a callback to the client to update the state of the
// node for resources that require a health check
updateHealthCheck
func
(
*
cstructs
.
HealthCheckResponse
)
*
structs
.
Node
logger
*
log
.
Logger
...
...
@@ -76,7 +77,7 @@ func (fm *FingerprintManager) runHealthCheck(hc fingerprint.HealthCheck, period
case
<-
time
.
After
(
period
)
:
err
:=
fm
.
healthCheck
(
name
,
hc
)
if
err
!=
nil
{
fm
.
logger
.
Printf
(
"[DEBUG] client.fingerprint_manager: health checking for %v failed: %
+
v"
,
name
,
err
)
fm
.
logger
.
Printf
(
"[DEBUG] client.fingerprint_manager: health checking for %v failed: %v"
,
name
,
err
)
continue
}
...
...
@@ -151,8 +152,14 @@ func (fm *FingerprintManager) fingerprintDriver(name string, f fingerprint.Finge
// support this. Doing this so that we can enable this iteratively and also
// in a backwards compatible way, where node attributes for drivers will
// eventually be phased out.
strippedAttributes
:=
make
(
map
[
string
]
string
,
0
)
for
k
,
v
:=
range
response
.
Attributes
{
copy
:=
k
strings
.
Replace
(
copy
,
"driver."
,
""
,
1
)
strippedAttributes
[
k
]
=
v
}
di
:=
&
structs
.
DriverInfo
{
Attributes
:
response
.
Attributes
,
Attributes
:
stripped
Attributes
,
Detected
:
response
.
Detected
,
}
response
.
AddDriver
(
name
,
di
)
...
...
This diff is collapsed.
Click to expand it.
nomad/structs/node.go
+
1
-
2
View file @
516b3d56
package
structs
import
(
"strings"
"time"
)
...
...
@@ -42,7 +41,7 @@ func (di *DriverInfo) HealthCheckEquals(other *DriverInfo) bool {
return
false
}
if
strings
.
Compare
(
di
.
HealthDescription
,
other
.
HealthDescription
)
!=
0
{
if
di
.
HealthDescription
==
other
.
HealthDescription
{
return
false
}
...
...
This diff is collapsed.
Click to expand it.
scheduler/feasible.go
+
4
-
4
View file @
516b3d56
...
...
@@ -130,10 +130,10 @@ func (c *DriverChecker) hasDrivers(option *structs.Node) bool {
for
driver
:=
range
c
.
drivers
{
driverStr
:=
fmt
.
Sprintf
(
"driver.%s"
,
driver
)
//
TODO this is a compatibility mechanism- a
s of Nomad 0.8, nodes have a
//
DriverInfo that
corresponds with every driver. As a Nomad server might
//
be on a later
version than a Nomad client, we need to check for
//
compatibility here
to verify the client supports this.
//
COMPAT: Remove in 0.X: A
s of Nomad 0.8, nodes have a
DriverInfo that
// corresponds with every driver. As a Nomad server might
be on a later
// version than a Nomad client, we need to check for
compatibility here
// to verify the client supports this.
if
option
.
Drivers
!=
nil
{
driverInfo
:=
option
.
Drivers
[
driver
]
if
driverInfo
==
nil
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help