mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
client: Move fingerprint structs to pkg
This removes a cyclical dependency when importing client/structs from dependencies of the plugin_loader, specifically, drivers. Due to client/config also depending on the plugin_loader. It also better reflects the ownership of fingerprint structs, as they are fairly internal to the fingerprint manager.
This commit is contained in:
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
consulApi "github.com/hashicorp/nomad/client/consul"
|
||||
"github.com/hashicorp/nomad/client/devicemanager"
|
||||
"github.com/hashicorp/nomad/client/fingerprint"
|
||||
"github.com/hashicorp/nomad/client/servers"
|
||||
"github.com/hashicorp/nomad/client/state"
|
||||
"github.com/hashicorp/nomad/client/stats"
|
||||
@@ -1084,7 +1085,7 @@ func (c *Client) setupNode() error {
|
||||
|
||||
// updateNodeFromFingerprint updates the node with the result of
|
||||
// fingerprinting the node from the diff that was created
|
||||
func (c *Client) updateNodeFromFingerprint(response *cstructs.FingerprintResponse) *structs.Node {
|
||||
func (c *Client) updateNodeFromFingerprint(response *fingerprint.FingerprintResponse) *structs.Node {
|
||||
c.configLock.Lock()
|
||||
defer c.configLock.Unlock()
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
memdb "github.com/hashicorp/go-memdb"
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
consulApi "github.com/hashicorp/nomad/client/consul"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/client/fingerprint"
|
||||
"github.com/hashicorp/nomad/command/agent/consul"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/helper/uuid"
|
||||
@@ -1007,13 +1007,13 @@ func TestClient_UpdateNodeFromDevicesAccumulates(t *testing.T) {
|
||||
client, cleanup := TestClient(t, func(c *config.Config) {})
|
||||
defer cleanup()
|
||||
|
||||
client.updateNodeFromFingerprint(&cstructs.FingerprintResponse{
|
||||
client.updateNodeFromFingerprint(&fingerprint.FingerprintResponse{
|
||||
NodeResources: &structs.NodeResources{
|
||||
Cpu: structs.NodeCpuResources{CpuShares: 123},
|
||||
},
|
||||
})
|
||||
|
||||
client.updateNodeFromFingerprint(&cstructs.FingerprintResponse{
|
||||
client.updateNodeFromFingerprint(&fingerprint.FingerprintResponse{
|
||||
NodeResources: &structs.NodeResources{
|
||||
Memory: structs.NodeMemoryResources{MemoryMB: 1024},
|
||||
},
|
||||
@@ -1047,7 +1047,7 @@ func TestClient_UpdateNodeFromDevicesAccumulates(t *testing.T) {
|
||||
|
||||
// overrides of values
|
||||
|
||||
client.updateNodeFromFingerprint(&cstructs.FingerprintResponse{
|
||||
client.updateNodeFromFingerprint(&fingerprint.FingerprintResponse{
|
||||
NodeResources: &structs.NodeResources{
|
||||
Memory: structs.NodeMemoryResources{MemoryMB: 2048},
|
||||
},
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"runtime"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
)
|
||||
|
||||
// ArchFingerprint is used to fingerprint the architecture
|
||||
@@ -19,7 +18,7 @@ func NewArchFingerprint(logger log.Logger) Fingerprint {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *ArchFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *ArchFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
resp.AddAttribute("cpu.arch", runtime.GOARCH)
|
||||
resp.Detected = true
|
||||
return nil
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -15,8 +14,8 @@ func TestArchFingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -46,7 +45,7 @@ func NewCGroupFingerprint(logger log.Logger) Fingerprint {
|
||||
|
||||
// clearCGroupAttributes clears any node attributes related to cgroups that might
|
||||
// have been set in a previous fingerprint run.
|
||||
func (f *CGroupFingerprint) clearCGroupAttributes(r *cstructs.FingerprintResponse) {
|
||||
func (f *CGroupFingerprint) clearCGroupAttributes(r *FingerprintResponse) {
|
||||
r.RemoveAttribute("unique.cgroup.mountpoint")
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
|
||||
package fingerprint
|
||||
|
||||
import cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
|
||||
// FindCgroupMountpointDir is used to find the cgroup mount point on a Linux
|
||||
// system. Here it is a no-op implemtation
|
||||
func FindCgroupMountpointDir() (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func (f *CGroupFingerprint) Fingerprint(*cstructs.FingerprintRequest, *cstructs.FingerprintResponse) error {
|
||||
func (f *CGroupFingerprint) Fingerprint(*FingerprintRequest, *FingerprintResponse) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ package fingerprint
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||
)
|
||||
|
||||
@@ -31,7 +30,7 @@ func FindCgroupMountpointDir() (string, error) {
|
||||
}
|
||||
|
||||
// Fingerprint tries to find a valid cgroup mount point
|
||||
func (f *CGroupFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *CGroupFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
mount, err := f.mountPointDetector.MountPoint()
|
||||
if err != nil {
|
||||
f.clearCGroupAttributes(resp)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -52,8 +51,8 @@ func TestCGroupFingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err == nil {
|
||||
t.Fatalf("expected an error")
|
||||
@@ -75,8 +74,8 @@ func TestCGroupFingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error, %s", err)
|
||||
@@ -97,8 +96,8 @@ func TestCGroupFingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error, %s", err)
|
||||
@@ -118,8 +117,8 @@ func TestCGroupFingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error, %s", err)
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
consul "github.com/hashicorp/consul/api"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -27,7 +26,7 @@ func NewConsulFingerprint(logger log.Logger) Fingerprint {
|
||||
return &ConsulFingerprint{logger: logger.Named("consul"), lastState: consulUnavailable}
|
||||
}
|
||||
|
||||
func (f *ConsulFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *ConsulFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
// Only create the client once to avoid creating too many connections to
|
||||
// Consul.
|
||||
if f.client == nil {
|
||||
@@ -103,7 +102,7 @@ func (f *ConsulFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *
|
||||
|
||||
// clearConsulAttributes removes consul attributes and links from the passed
|
||||
// Node.
|
||||
func (f *ConsulFingerprint) clearConsulAttributes(r *cstructs.FingerprintResponse) {
|
||||
func (f *ConsulFingerprint) clearConsulAttributes(r *FingerprintResponse) {
|
||||
r.RemoveAttribute("consul.server")
|
||||
r.RemoveAttribute("consul.version")
|
||||
r.RemoveAttribute("consul.revision")
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -29,8 +28,8 @@ func TestConsulFingerprint(t *testing.T) {
|
||||
conf := config.DefaultConfig()
|
||||
conf.ConsulConfig.Addr = strings.TrimPrefix(ts.URL, "http://")
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: conf, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: conf, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := fp.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to fingerprint: %s", err)
|
||||
@@ -185,8 +184,8 @@ func TestConsulFingerprint_UnexpectedResponse(t *testing.T) {
|
||||
conf := config.DefaultConfig()
|
||||
conf.ConsulConfig.Addr = strings.TrimPrefix(ts.URL, "http://")
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: conf, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: conf, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := fp.Fingerprint(request, &response)
|
||||
assert.Nil(err)
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/stats"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -21,7 +20,7 @@ func NewCPUFingerprint(logger log.Logger) Fingerprint {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *CPUFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *CPUFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
cfg := req.Config
|
||||
setResourcesCPU := func(totalCompute int) {
|
||||
// COMPAT(0.10): Remove in 0.10
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -15,8 +14,8 @@ func TestCPUFingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -66,8 +65,8 @@ func TestCPUFingerprint_OverrideCompute(t *testing.T) {
|
||||
var originalCPU int
|
||||
|
||||
{
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -89,8 +88,8 @@ func TestCPUFingerprint_OverrideCompute(t *testing.T) {
|
||||
cfg.CpuCompute = originalCPU + 123
|
||||
|
||||
// Make sure the Fingerprinter applies the override to the node resources
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
|
||||
"github.com/hashicorp/go-cleanhttp"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
@@ -64,7 +63,7 @@ func NewEnvAWSFingerprint(logger log.Logger) Fingerprint {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *EnvAWSFingerprint) Fingerprint(request *cstructs.FingerprintRequest, response *cstructs.FingerprintResponse) error {
|
||||
func (f *EnvAWSFingerprint) Fingerprint(request *FingerprintRequest, response *FingerprintResponse) error {
|
||||
cfg := request.Config
|
||||
|
||||
// Check if we should tighten the timeout
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -21,8 +20,8 @@ func TestEnvAWSFingerprint_nonAws(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -55,8 +54,8 @@ func TestEnvAWSFingerprint_aws(t *testing.T) {
|
||||
defer ts.Close()
|
||||
os.Setenv("AWS_ENV_URL", ts.URL+"/latest/meta-data/")
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -173,8 +172,8 @@ func TestNetworkFingerprint_AWS(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -223,8 +222,8 @@ func TestNetworkFingerprint_AWS_network(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -266,8 +265,8 @@ func TestNetworkFingerprint_AWS_network(t *testing.T) {
|
||||
NetworkSpeed: 10,
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -303,8 +302,8 @@ func TestNetworkFingerprint_notAWS(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
|
||||
"github.com/hashicorp/go-cleanhttp"
|
||||
"github.com/hashicorp/nomad/helper/useragent"
|
||||
@@ -137,7 +136,7 @@ func checkError(err error, logger log.Logger, desc string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (f *EnvGCEFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *EnvGCEFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
cfg := req.Config
|
||||
|
||||
// Check if we should tighten the timeout
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -22,8 +21,8 @@ func TestGCEFingerprint_nonGCE(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -93,8 +92,8 @@ func testFingerprint_GCE(t *testing.T, withExternalIp bool) {
|
||||
os.Setenv("GCE_ENV_URL", ts.URL+"/computeMetadata/v1/instance/")
|
||||
f := NewEnvGCEFingerprint(testlog.HCLogger(t))
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
||||
@@ -107,7 +107,7 @@ type HealthCheck interface {
|
||||
type Fingerprint interface {
|
||||
// Fingerprint is used to update properties of the Node,
|
||||
// and returns a diff of updated node attributes and a potential error.
|
||||
Fingerprint(*cstructs.FingerprintRequest, *cstructs.FingerprintResponse) error
|
||||
Fingerprint(*FingerprintRequest, *FingerprintResponse) error
|
||||
|
||||
// Periodic is a mechanism for the fingerprinter to indicate that it should
|
||||
// be run periodically. The return value is a boolean indicating if it
|
||||
|
||||
@@ -6,13 +6,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
func assertFingerprintOK(t *testing.T, fp Fingerprint, node *structs.Node) *cstructs.FingerprintResponse {
|
||||
request := &cstructs.FingerprintRequest{Config: new(config.Config), Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
func assertFingerprintOK(t *testing.T, fp Fingerprint, node *structs.Node) *FingerprintResponse {
|
||||
request := &FingerprintRequest{Config: new(config.Config), Node: node}
|
||||
var response FingerprintResponse
|
||||
err := fp.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to fingerprint: %s", err)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"runtime"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/shirou/gopsutil/host"
|
||||
)
|
||||
|
||||
@@ -20,7 +19,7 @@ func NewHostFingerprint(logger log.Logger) Fingerprint {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *HostFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *HostFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
hostInfo, err := host.Info()
|
||||
if err != nil {
|
||||
f.logger.Warn("error retrieving host information", "error", err)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -15,8 +14,8 @@ func TestHostFingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/shirou/gopsutil/mem"
|
||||
)
|
||||
@@ -25,7 +24,7 @@ func NewMemoryFingerprint(logger log.Logger) Fingerprint {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *MemoryFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *MemoryFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
var totalMemory int
|
||||
cfg := req.Config
|
||||
if cfg.MemoryMB != 0 {
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
|
||||
@@ -17,8 +16,8 @@ func TestMemoryFingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -47,8 +46,8 @@ func TestMemoryFingerprint_Override(t *testing.T) {
|
||||
}
|
||||
|
||||
memoryMB := 15000
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{MemoryMB: memoryMB}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: &config.Config{MemoryMB: memoryMB}, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
sockaddr "github.com/hashicorp/go-sockaddr"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
@@ -61,7 +60,7 @@ func NewNetworkFingerprint(logger log.Logger) Fingerprint {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *NetworkFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *NetworkFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
cfg := req.Config
|
||||
|
||||
// Find the named interface
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
@@ -191,8 +190,8 @@ func TestNetworkFingerprint_basic(t *testing.T) {
|
||||
}
|
||||
cfg := &config.Config{NetworkSpeed: 101}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -242,8 +241,8 @@ func TestNetworkFingerprint_default_device_absent(t *testing.T) {
|
||||
}
|
||||
cfg := &config.Config{NetworkSpeed: 100, NetworkInterface: "eth0"}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err == nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -265,8 +264,8 @@ func TestNetworkFingerPrint_default_device(t *testing.T) {
|
||||
}
|
||||
cfg := &config.Config{NetworkSpeed: 100, NetworkInterface: "lo"}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -316,8 +315,8 @@ func TestNetworkFingerPrint_LinkLocal_Allowed(t *testing.T) {
|
||||
}
|
||||
cfg := &config.Config{NetworkSpeed: 100, NetworkInterface: "eth3"}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -363,8 +362,8 @@ func TestNetworkFingerPrint_LinkLocal_Allowed_MixedIntf(t *testing.T) {
|
||||
}
|
||||
cfg := &config.Config{NetworkSpeed: 100, NetworkInterface: "eth4"}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -423,8 +422,8 @@ func TestNetworkFingerPrint_LinkLocal_Disallowed(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: cfg, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: cfg, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
||||
@@ -2,7 +2,6 @@ package fingerprint
|
||||
|
||||
import (
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
)
|
||||
|
||||
// NomadFingerprint is used to fingerprint the Nomad version
|
||||
@@ -17,7 +16,7 @@ func NewNomadFingerprint(logger log.Logger) Fingerprint {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *NomadFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *NomadFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
resp.AddAttribute("nomad.advertise.address", req.Node.HTTPAddr)
|
||||
resp.AddAttribute("nomad.version", req.Config.Version.VersionNumber())
|
||||
resp.AddAttribute("nomad.revision", req.Config.Version.Revision)
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/hashicorp/nomad/version"
|
||||
@@ -27,8 +26,8 @@ func TestNomadFingerprint(t *testing.T) {
|
||||
HTTPAddr: h,
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: c, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: c, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := f.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
|
||||
"github.com/hashicorp/consul-template/signals"
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
)
|
||||
|
||||
// SignalFingerprint is used to fingerprint the available signals
|
||||
@@ -20,7 +19,7 @@ func NewSignalFingerprint(logger log.Logger) Fingerprint {
|
||||
return f
|
||||
}
|
||||
|
||||
func (f *SignalFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *SignalFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
// Build the list of available signals
|
||||
sigs := make([]string, 0, len(signals.SignalLookup))
|
||||
for signal := range signals.SignalLookup {
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"strconv"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
@@ -24,7 +23,7 @@ func NewStorageFingerprint(logger log.Logger) Fingerprint {
|
||||
return fp
|
||||
}
|
||||
|
||||
func (f *StorageFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *StorageFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
cfg := req.Config
|
||||
|
||||
// Guard against unset AllocDir
|
||||
|
||||
69
client/fingerprint/structs.go
Normal file
69
client/fingerprint/structs.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package fingerprint
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
)
|
||||
|
||||
// FingerprintRequest is a request which a fingerprinter accepts to fingerprint
|
||||
// the node
|
||||
type FingerprintRequest struct {
|
||||
Config *config.Config
|
||||
Node *structs.Node
|
||||
}
|
||||
|
||||
// FingerprintResponse is the response which a fingerprinter annotates with the
|
||||
// results of the fingerprint method
|
||||
type FingerprintResponse struct {
|
||||
Attributes map[string]string
|
||||
Links map[string]string
|
||||
Resources *structs.Resources // COMPAT(0.10): Remove in 0.10
|
||||
NodeResources *structs.NodeResources
|
||||
|
||||
// Detected is a boolean indicating whether the fingerprinter detected
|
||||
// if the resource was available
|
||||
Detected bool
|
||||
}
|
||||
|
||||
// AddAttribute adds the name and value for a node attribute to the fingerprint
|
||||
// response
|
||||
func (f *FingerprintResponse) AddAttribute(name, value string) {
|
||||
// initialize Attributes if it has not been already
|
||||
if f.Attributes == nil {
|
||||
f.Attributes = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
f.Attributes[name] = value
|
||||
}
|
||||
|
||||
// RemoveAttribute sets the given attribute to empty, which will later remove
|
||||
// it entirely from the node
|
||||
func (f *FingerprintResponse) RemoveAttribute(name string) {
|
||||
// initialize Attributes if it has not been already
|
||||
if f.Attributes == nil {
|
||||
f.Attributes = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
f.Attributes[name] = ""
|
||||
}
|
||||
|
||||
// AddLink adds a link entry to the fingerprint response
|
||||
func (f *FingerprintResponse) AddLink(name, value string) {
|
||||
// initialize Links if it has not been already
|
||||
if f.Links == nil {
|
||||
f.Links = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
f.Links[name] = value
|
||||
}
|
||||
|
||||
// RemoveLink removes a link entry from the fingerprint response. This will
|
||||
// later remove it entirely from the node
|
||||
func (f *FingerprintResponse) RemoveLink(name string) {
|
||||
// initialize Links if it has not been already
|
||||
if f.Links == nil {
|
||||
f.Links = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
f.Links[name] = ""
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"time"
|
||||
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
vapi "github.com/hashicorp/vault/api"
|
||||
)
|
||||
|
||||
@@ -28,7 +27,7 @@ func NewVaultFingerprint(logger log.Logger) Fingerprint {
|
||||
return &VaultFingerprint{logger: logger.Named("vault"), lastState: vaultUnavailable}
|
||||
}
|
||||
|
||||
func (f *VaultFingerprint) Fingerprint(req *cstructs.FingerprintRequest, resp *cstructs.FingerprintResponse) error {
|
||||
func (f *VaultFingerprint) Fingerprint(req *FingerprintRequest, resp *FingerprintResponse) error {
|
||||
config := req.Config
|
||||
|
||||
if config.VaultConfig == nil || !config.VaultConfig.IsEnabled() {
|
||||
@@ -82,7 +81,7 @@ func (f *VaultFingerprint) Periodic() (bool, time.Duration) {
|
||||
return true, 15 * time.Second
|
||||
}
|
||||
|
||||
func (f *VaultFingerprint) clearVaultAttributes(r *cstructs.FingerprintResponse) {
|
||||
func (f *VaultFingerprint) clearVaultAttributes(r *FingerprintResponse) {
|
||||
r.RemoveAttribute("vault.accessible")
|
||||
r.RemoveAttribute("vault.version")
|
||||
r.RemoveAttribute("vault.cluster_id")
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/helper/testlog"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/hashicorp/nomad/testutil"
|
||||
@@ -22,8 +21,8 @@ func TestVaultFingerprint(t *testing.T) {
|
||||
conf := config.DefaultConfig()
|
||||
conf.VaultConfig = tv.Config
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: conf, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &FingerprintRequest{Config: conf, Node: node}
|
||||
var response FingerprintResponse
|
||||
err := fp.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to fingerprint: %s", err)
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
log "github.com/hashicorp/go-hclog"
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
"github.com/hashicorp/nomad/client/fingerprint"
|
||||
cstructs "github.com/hashicorp/nomad/client/structs"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/hashicorp/nomad/plugins/base"
|
||||
"github.com/hashicorp/nomad/plugins/drivers"
|
||||
@@ -38,7 +37,7 @@ type FingerprintManager struct {
|
||||
|
||||
// updateNodeAttributes is a callback to the client to update the state of its
|
||||
// associated node
|
||||
updateNodeAttributes func(*cstructs.FingerprintResponse) *structs.Node
|
||||
updateNodeAttributes func(*fingerprint.FingerprintResponse) *structs.Node
|
||||
|
||||
// updateNodeFromDriver is a callback to the client to update the state of a
|
||||
// specific driver for the node
|
||||
@@ -53,7 +52,7 @@ func NewFingerprintManager(
|
||||
getConfig func() *config.Config,
|
||||
node *structs.Node,
|
||||
shutdownCh chan struct{},
|
||||
updateNodeAttributes func(*cstructs.FingerprintResponse) *structs.Node,
|
||||
updateNodeAttributes func(*fingerprint.FingerprintResponse) *structs.Node,
|
||||
updateNodeFromDriver func(string, *structs.DriverInfo) *structs.Node,
|
||||
logger log.Logger) *FingerprintManager {
|
||||
|
||||
@@ -250,10 +249,10 @@ func (fm *FingerprintManager) runFingerprint(f fingerprint.Fingerprint, period t
|
||||
// is meant to be run continuously, a process is launched to perform this
|
||||
// fingerprint on an ongoing basis in the background.
|
||||
func (fm *FingerprintManager) fingerprint(name string, f fingerprint.Fingerprint) (bool, error) {
|
||||
var response cstructs.FingerprintResponse
|
||||
var response fingerprint.FingerprintResponse
|
||||
|
||||
fm.nodeLock.Lock()
|
||||
request := &cstructs.FingerprintRequest{Config: fm.getConfig(), Node: fm.node}
|
||||
request := &fingerprint.FingerprintRequest{Config: fm.getConfig(), Node: fm.node}
|
||||
err := f.Fingerprint(request, &response)
|
||||
fm.nodeLock.Unlock()
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/nomad/client/config"
|
||||
"github.com/hashicorp/nomad/client/stats"
|
||||
"github.com/hashicorp/nomad/nomad/structs"
|
||||
"github.com/hashicorp/nomad/plugins/device"
|
||||
@@ -348,69 +347,6 @@ func (d *DriverNetwork) Hash() []byte {
|
||||
return h.Sum(nil)
|
||||
}
|
||||
|
||||
// FingerprintRequest is a request which a fingerprinter accepts to fingerprint
|
||||
// the node
|
||||
type FingerprintRequest struct {
|
||||
Config *config.Config
|
||||
Node *structs.Node
|
||||
}
|
||||
|
||||
// FingerprintResponse is the response which a fingerprinter annotates with the
|
||||
// results of the fingerprint method
|
||||
type FingerprintResponse struct {
|
||||
Attributes map[string]string
|
||||
Links map[string]string
|
||||
Resources *structs.Resources // COMPAT(0.10): Remove in 0.10
|
||||
NodeResources *structs.NodeResources
|
||||
|
||||
// Detected is a boolean indicating whether the fingerprinter detected
|
||||
// if the resource was available
|
||||
Detected bool
|
||||
}
|
||||
|
||||
// AddAttribute adds the name and value for a node attribute to the fingerprint
|
||||
// response
|
||||
func (f *FingerprintResponse) AddAttribute(name, value string) {
|
||||
// initialize Attributes if it has not been already
|
||||
if f.Attributes == nil {
|
||||
f.Attributes = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
f.Attributes[name] = value
|
||||
}
|
||||
|
||||
// RemoveAttribute sets the given attribute to empty, which will later remove
|
||||
// it entirely from the node
|
||||
func (f *FingerprintResponse) RemoveAttribute(name string) {
|
||||
// initialize Attributes if it has not been already
|
||||
if f.Attributes == nil {
|
||||
f.Attributes = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
f.Attributes[name] = ""
|
||||
}
|
||||
|
||||
// AddLink adds a link entry to the fingerprint response
|
||||
func (f *FingerprintResponse) AddLink(name, value string) {
|
||||
// initialize Links if it has not been already
|
||||
if f.Links == nil {
|
||||
f.Links = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
f.Links[name] = value
|
||||
}
|
||||
|
||||
// RemoveLink removes a link entry from the fingerprint response. This will
|
||||
// later remove it entirely from the node
|
||||
func (f *FingerprintResponse) RemoveLink(name string) {
|
||||
// initialize Links if it has not been already
|
||||
if f.Links == nil {
|
||||
f.Links = make(map[string]string, 0)
|
||||
}
|
||||
|
||||
f.Links[name] = ""
|
||||
}
|
||||
|
||||
// HealthCheckRequest is the request type for a type that fulfils the Health
|
||||
// Check interface
|
||||
type HealthCheckRequest struct{}
|
||||
|
||||
@@ -196,8 +196,8 @@ func TestDockerDriver_Fingerprint(t *testing.T) {
|
||||
Attributes: make(map[string]string),
|
||||
}
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &fingerprint.FingerprintRequest{Config: &config.Config{}, Node: node}
|
||||
var response fingerprint.FingerprintResponse
|
||||
err := d.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
@@ -249,8 +249,8 @@ func TestDockerDriver_Fingerprint_Bridge(t *testing.T) {
|
||||
conf.Node = mock.Node()
|
||||
dd := NewDockerDriver(NewDriverContext("", "", "", "", conf, conf.Node, testlog.Logger(t), nil))
|
||||
|
||||
request := &cstructs.FingerprintRequest{Config: conf, Node: conf.Node}
|
||||
var response cstructs.FingerprintResponse
|
||||
request := &fingerprint.FingerprintRequest{Config: conf, Node: conf.Node}
|
||||
var response fingerprint.FingerprintResponse
|
||||
|
||||
err = dd.Fingerprint(request, &response)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user