mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
fix: add node pool attribute to interpretable values in task env (#24052)
This commit is contained in:
committed by
GitHub
parent
389545bcf5
commit
338487c159
3
.changelog/24052.txt
Normal file
3
.changelog/24052.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
task: adds node.pool attribute to interpretable values in task env
|
||||||
|
```
|
||||||
@@ -142,6 +142,7 @@ const (
|
|||||||
nodeRegionKey = "node.region"
|
nodeRegionKey = "node.region"
|
||||||
nodeNameKey = "node.unique.name"
|
nodeNameKey = "node.unique.name"
|
||||||
nodeClassKey = "node.class"
|
nodeClassKey = "node.class"
|
||||||
|
nodePoolKey = "node.pool"
|
||||||
|
|
||||||
// Prefixes used for lookups.
|
// Prefixes used for lookups.
|
||||||
nodeAttributePrefix = "attr."
|
nodeAttributePrefix = "attr."
|
||||||
@@ -855,6 +856,7 @@ func (b *Builder) setNode(n *structs.Node) *Builder {
|
|||||||
b.nodeAttrs[nodeNameKey] = n.Name
|
b.nodeAttrs[nodeNameKey] = n.Name
|
||||||
b.nodeAttrs[nodeClassKey] = n.NodeClass
|
b.nodeAttrs[nodeClassKey] = n.NodeClass
|
||||||
b.nodeAttrs[nodeDcKey] = n.Datacenter
|
b.nodeAttrs[nodeDcKey] = n.Datacenter
|
||||||
|
b.nodeAttrs[nodePoolKey] = n.NodePool
|
||||||
b.datacenter = n.Datacenter
|
b.datacenter = n.Datacenter
|
||||||
b.cgroupParent = n.CgroupParent
|
b.cgroupParent = n.CgroupParent
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ const (
|
|||||||
attrVal = "amd64"
|
attrVal = "amd64"
|
||||||
nodeName = "test node"
|
nodeName = "test node"
|
||||||
nodeClass = "test class"
|
nodeClass = "test class"
|
||||||
|
nodePool = "test pool"
|
||||||
|
|
||||||
// Environment variable values that tests can rely on
|
// Environment variable values that tests can rely on
|
||||||
envOneKey = "NOMAD_IP"
|
envOneKey = "NOMAD_IP"
|
||||||
@@ -56,6 +57,7 @@ func testEnvBuilder() *Builder {
|
|||||||
}
|
}
|
||||||
n.Name = nodeName
|
n.Name = nodeName
|
||||||
n.NodeClass = nodeClass
|
n.NodeClass = nodeClass
|
||||||
|
n.NodePool = nodePool
|
||||||
|
|
||||||
task := mock.Job().TaskGroups[0].Tasks[0]
|
task := mock.Job().TaskGroups[0].Tasks[0]
|
||||||
task.Env = map[string]string{
|
task.Env = map[string]string{
|
||||||
@@ -108,8 +110,8 @@ func TestEnvironment_ParseAndReplace_Attr(t *testing.T) {
|
|||||||
func TestEnvironment_ParseAndReplace_Node(t *testing.T) {
|
func TestEnvironment_ParseAndReplace_Node(t *testing.T) {
|
||||||
ci.Parallel(t)
|
ci.Parallel(t)
|
||||||
|
|
||||||
input := []string{fmt.Sprintf("${%v}", nodeNameKey), fmt.Sprintf("${%v}", nodeClassKey)}
|
input := []string{fmt.Sprintf("${%v}", nodeNameKey), fmt.Sprintf("${%v}", nodeClassKey), fmt.Sprintf("${%v}", nodePoolKey)}
|
||||||
exp := []string{nodeName, nodeClass}
|
exp := []string{nodeName, nodeClass, nodePool}
|
||||||
env := testEnvBuilder()
|
env := testEnvBuilder()
|
||||||
act := env.Build().ParseAndReplace(input)
|
act := env.Build().ParseAndReplace(input)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user