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
@@ -142,6 +142,7 @@ const (
|
||||
nodeRegionKey = "node.region"
|
||||
nodeNameKey = "node.unique.name"
|
||||
nodeClassKey = "node.class"
|
||||
nodePoolKey = "node.pool"
|
||||
|
||||
// Prefixes used for lookups.
|
||||
nodeAttributePrefix = "attr."
|
||||
@@ -855,6 +856,7 @@ func (b *Builder) setNode(n *structs.Node) *Builder {
|
||||
b.nodeAttrs[nodeNameKey] = n.Name
|
||||
b.nodeAttrs[nodeClassKey] = n.NodeClass
|
||||
b.nodeAttrs[nodeDcKey] = n.Datacenter
|
||||
b.nodeAttrs[nodePoolKey] = n.NodePool
|
||||
b.datacenter = n.Datacenter
|
||||
b.cgroupParent = n.CgroupParent
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ const (
|
||||
attrVal = "amd64"
|
||||
nodeName = "test node"
|
||||
nodeClass = "test class"
|
||||
nodePool = "test pool"
|
||||
|
||||
// Environment variable values that tests can rely on
|
||||
envOneKey = "NOMAD_IP"
|
||||
@@ -56,6 +57,7 @@ func testEnvBuilder() *Builder {
|
||||
}
|
||||
n.Name = nodeName
|
||||
n.NodeClass = nodeClass
|
||||
n.NodePool = nodePool
|
||||
|
||||
task := mock.Job().TaskGroups[0].Tasks[0]
|
||||
task.Env = map[string]string{
|
||||
@@ -108,8 +110,8 @@ func TestEnvironment_ParseAndReplace_Attr(t *testing.T) {
|
||||
func TestEnvironment_ParseAndReplace_Node(t *testing.T) {
|
||||
ci.Parallel(t)
|
||||
|
||||
input := []string{fmt.Sprintf("${%v}", nodeNameKey), fmt.Sprintf("${%v}", nodeClassKey)}
|
||||
exp := []string{nodeName, nodeClass}
|
||||
input := []string{fmt.Sprintf("${%v}", nodeNameKey), fmt.Sprintf("${%v}", nodeClassKey), fmt.Sprintf("${%v}", nodePoolKey)}
|
||||
exp := []string{nodeName, nodeClass, nodePool}
|
||||
env := testEnvBuilder()
|
||||
act := env.Build().ParseAndReplace(input)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user