structs: filter NomadTokenID from job diff (#8773)

Multiregion deployments use the `NomadTokenID` to allow the deploymentwatcher
to send RPCs between regions with the original submitter's ACL token. This ID
should be filtered from diffs so that it doesn't cause a difference for
purposes of job plans.
This commit is contained in:
Tim Gross 2020-08-28 13:40:51 -04:00 committed by GitHub
parent 97c7f2acea
commit 35b1b3bed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -61,7 +61,7 @@ func (j *Job) Diff(other *Job, contextual bool) (*JobDiff, error) {
diff := &JobDiff{Type: DiffTypeNone}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
filter := []string{"ID", "Status", "StatusDescription", "Version", "Stable", "CreateIndex",
"ModifyIndex", "JobModifyIndex", "Update", "SubmitTime"}
"ModifyIndex", "JobModifyIndex", "Update", "SubmitTime", "NomadTokenID"}
if j == nil && other == nil {
return diff, nil

View File

@ -1185,6 +1185,7 @@ func TestJobDiff(t *testing.T) {
{
// Multiregion: region added
Old: &Job{
NomadTokenID: "abcdef",
Multiregion: &Multiregion{
Strategy: &MultiregionStrategy{
MaxParallel: 1,
@ -1202,6 +1203,7 @@ func TestJobDiff(t *testing.T) {
},
New: &Job{
NomadTokenID: "12345",
Multiregion: &Multiregion{
Strategy: &MultiregionStrategy{
MaxParallel: 2,