-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add env vars for dc, region #2507
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Add a line in CHANGELOG.md (either in this PR or directly to master after merging)
Nice @qkate ! |
nomad/structs/structs.go
Outdated
@@ -708,6 +708,9 @@ type Node struct { | |||
// Datacenter for this node | |||
Datacenter string | |||
|
|||
// Region for this node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey lets actually remove this. It is better to keep this normalized as we will not have a field string stored in memory for every node that is know by virtue of the region you are talking to.
client/driver/driver.go
Outdated
@@ -278,6 +278,8 @@ func GetTaskEnv(taskDir *allocdir.TaskDir, node *structs.Node, | |||
env := env.NewTaskEnvironment(node). | |||
SetTaskMeta(alloc.Job.CombinedTaskMeta(alloc.TaskGroup, task.Name)). | |||
SetJobName(alloc.Job.Name). | |||
SetDatacenterName(node.Datacenter). | |||
SetRegionName(node.Region). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conf.Region
@@ -61,6 +61,14 @@ environment variables. | |||
<td>The job's name</td> | |||
</tr> | |||
<tr> | |||
<td>`NOMAD_DC`</td> | |||
<td>The datacenter in which the job is running.</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic, but these aren't sentences, so we should not have a period at the end 😄
@sethvargo -- roger that, I removed the periods! |
client/driver/env/env.go
Outdated
@@ -227,6 +242,7 @@ func (t *TaskEnvironment) Build() *TaskEnvironment { | |||
// Set up the node values. | |||
t.NodeValues[nodeIdKey] = t.Node.ID | |||
t.NodeValues[nodeDcKey] = t.Node.Datacenter | |||
t.NodeValues[nodeRegionKey] = t.Node.Region |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dadgar I'm guessing I should remove this line as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change it to `t.NodeValues[nodeRegionKey] = t.Region
command/agent/agent.go
Outdated
@@ -275,6 +275,7 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) { | |||
// Setup the node | |||
conf.Node = new(structs.Node) | |||
conf.Node.Datacenter = a.config.Datacenter | |||
conf.Node.Region = a.config.Region |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dadgar And should I remove this too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
@@ -61,6 +61,14 @@ environment variables. | |||
<td>The job's name</td> | |||
</tr> | |||
<tr> | |||
<td>`NOMAD_DC`</td> | |||
<td>The datacenter in which the job is running</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
job -> allocation
</tr> | ||
<tr> | ||
<td>`NOMAD_REGION`</td> | ||
<td>The region in which the job is running</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ouple functions to be consistent with the ordering of the rest of that section.
…on didn't previously exist in the Node struct.
…ammatical niceties.
@wilkmaia that is a somewhat flaky test so given all else passed and they are unrelated I think it is a red herring! But thanks for noticing! |
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Closes #2183