-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1839 from hashicorp/f-signal-constraints
Signal creates an auto-constraints
- Loading branch information
Showing
24 changed files
with
623 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package fingerprint | ||
|
||
import ( | ||
"log" | ||
"strings" | ||
|
||
"github.com/hashicorp/consul-template/signals" | ||
"github.com/hashicorp/nomad/client/config" | ||
"github.com/hashicorp/nomad/nomad/structs" | ||
) | ||
|
||
// SignalFingerprint is used to fingerprint the available signals | ||
type SignalFingerprint struct { | ||
StaticFingerprinter | ||
logger *log.Logger | ||
} | ||
|
||
// NewSignalFingerprint is used to create a Signal fingerprint | ||
func NewSignalFingerprint(logger *log.Logger) Fingerprint { | ||
f := &SignalFingerprint{logger: logger} | ||
return f | ||
} | ||
|
||
func (f *SignalFingerprint) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) { | ||
// Build the list of available signals | ||
sigs := make([]string, 0, len(signals.SignalLookup)) | ||
for signal := range signals.SignalLookup { | ||
sigs = append(sigs, signal) | ||
} | ||
|
||
node.Attributes["os.signals"] = strings.Join(sigs, ",") | ||
return true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package fingerprint | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/nomad/nomad/structs" | ||
) | ||
|
||
func TestSignalFingerprint(t *testing.T) { | ||
fp := NewSignalFingerprint(testLogger()) | ||
node := &structs.Node{ | ||
Attributes: make(map[string]string), | ||
} | ||
|
||
assertFingerprintOK(t, fp, node) | ||
assertNodeAttributeContains(t, node, "os.signals") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
job "foo" { | ||
constraint { | ||
attribute = "$meta.data" | ||
set_contains = "foo,bar,baz" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.