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
87201fa5
Commit
87201fa5
authored
8 years ago
by
Alex Dadgar
Browse files
Options
Download
Email Patches
Plain Diff
Run environmental fingerprinters after host fingerprinters and do an override
parent
93cd6d51
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/fingerprint/env_aws.go
+2
-3
client/fingerprint/env_aws.go
client/fingerprint/fingerprint.go
+37
-21
client/fingerprint/fingerprint.go
with
39 additions
and
24 deletions
+39
-24
client/fingerprint/env_aws.go
+
2
-
3
View file @
87201fa5
...
@@ -160,12 +160,11 @@ func (f *EnvAWSFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
...
@@ -160,12 +160,11 @@ func (f *EnvAWSFingerprint) Fingerprint(cfg *config.Config, node *structs.Node)
newNetwork
.
MBits
=
throughput
newNetwork
.
MBits
=
throughput
}
}
// populate Node Network Resources
if
node
.
Resources
==
nil
{
if
node
.
Resources
==
nil
{
node
.
Resources
=
&
structs
.
Resources
{}
node
.
Resources
=
&
structs
.
Resources
{}
}
}
node
.
Resources
.
Networks
=
append
(
node
.
Resources
.
Networks
,
newNetwork
)
node
.
Resources
.
Networks
=
[]
*
structs
.
NetworkResource
{
newNetwork
}
// populate Node Network Resources
// populate Links
// populate Links
node
.
Links
[
"aws.ec2"
]
=
fmt
.
Sprintf
(
"%s.%s"
,
node
.
Links
[
"aws.ec2"
]
=
fmt
.
Sprintf
(
"%s.%s"
,
...
...
This diff is collapsed.
Click to expand it.
client/fingerprint/fingerprint.go
+
37
-
21
View file @
87201fa5
...
@@ -16,36 +16,49 @@ const (
...
@@ -16,36 +16,49 @@ const (
)
)
func
init
()
{
func
init
()
{
builtinFingerprintMap
[
"arch"
]
=
NewArchFingerprint
builtinFingerprintMap
[
"consul"
]
=
NewConsulFingerprint
builtinFingerprintMap
[
"cpu"
]
=
NewCPUFingerprint
builtinFingerprintMap
[
"env_aws"
]
=
NewEnvAWSFingerprint
builtinFingerprintMap
[
"env_gce"
]
=
NewEnvGCEFingerprint
builtinFingerprintMap
[
"host"
]
=
NewHostFingerprint
builtinFingerprintMap
[
"memory"
]
=
NewMemoryFingerprint
builtinFingerprintMap
[
"network"
]
=
NewNetworkFingerprint
builtinFingerprintMap
[
"nomad"
]
=
NewNomadFingerprint
builtinFingerprintMap
[
"signal"
]
=
NewSignalFingerprint
builtinFingerprintMap
[
"storage"
]
=
NewStorageFingerprint
builtinFingerprintMap
[
"vault"
]
=
NewVaultFingerprint
// Initialize the list of available fingerprinters per platform. Each
// Initialize the list of available fingerprinters per platform. Each
// platform defines its own list of available fingerprinters.
// platform defines its own list of available fingerprinters.
initPlatformFingerprints
(
builtin
Fingerprint
Map
)
initPlatformFingerprints
(
host
Fingerprint
ers
)
}
}
// builtinFingerprintMap contains the built in registered fingerprints which are
var
(
// available for a given platform.
// hostFingerprinters contains the host fingerprints which are available for a
var
builtinFingerprintMap
=
make
(
map
[
string
]
Factory
,
16
)
// given platform.
hostFingerprinters
=
map
[
string
]
Factory
{
"arch"
:
NewArchFingerprint
,
"consul"
:
NewConsulFingerprint
,
"cpu"
:
NewCPUFingerprint
,
"host"
:
NewHostFingerprint
,
"memory"
:
NewMemoryFingerprint
,
"network"
:
NewNetworkFingerprint
,
"nomad"
:
NewNomadFingerprint
,
"signal"
:
NewSignalFingerprint
,
"storage"
:
NewStorageFingerprint
,
"vault"
:
NewVaultFingerprint
,
}
// envFingerprinters contains the fingerprints that are environment specific.
// This should run after the host fingerprinters as they may override specific
// node resources with more detailed information.
envFingerprinters
=
map
[
string
]
Factory
{
"env_aws"
:
NewEnvAWSFingerprint
,
"env_gce"
:
NewEnvGCEFingerprint
,
}
)
// BuiltinFingerprints is a slice containing the key names of all registered
// BuiltinFingerprints is a slice containing the key names of all registered
// fingerprints available, to provided an ordered iteration
// fingerprints available. The order of this slice should be preserved when
// fingerprinting.
func
BuiltinFingerprints
()
[]
string
{
func
BuiltinFingerprints
()
[]
string
{
fingerprints
:=
make
([]
string
,
0
,
len
(
builtin
Fingerprint
Map
))
fingerprints
:=
make
([]
string
,
0
,
len
(
host
Fingerprint
ers
))
for
k
:=
range
builtin
Fingerprint
Map
{
for
k
:=
range
host
Fingerprint
ers
{
fingerprints
=
append
(
fingerprints
,
k
)
fingerprints
=
append
(
fingerprints
,
k
)
}
}
sort
.
Strings
(
fingerprints
)
sort
.
Strings
(
fingerprints
)
for
k
:=
range
envFingerprinters
{
fingerprints
=
append
(
fingerprints
,
k
)
}
return
fingerprints
return
fingerprints
}
}
...
@@ -53,9 +66,12 @@ func BuiltinFingerprints() []string {
...
@@ -53,9 +66,12 @@ func BuiltinFingerprints() []string {
// given the name and a logger
// given the name and a logger
func
NewFingerprint
(
name
string
,
logger
*
log
.
Logger
)
(
Fingerprint
,
error
)
{
func
NewFingerprint
(
name
string
,
logger
*
log
.
Logger
)
(
Fingerprint
,
error
)
{
// Lookup the factory function
// Lookup the factory function
factory
,
ok
:=
builtin
Fingerprint
Map
[
name
]
factory
,
ok
:=
host
Fingerprint
ers
[
name
]
if
!
ok
{
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unknown fingerprint '%s'"
,
name
)
factory
,
ok
=
envFingerprinters
[
name
]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"unknown fingerprint '%s'"
,
name
)
}
}
}
// Instantiate the fingerprint
// Instantiate the fingerprint
...
...
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