2016-05-11 05:23:34 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
"time"
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
|
2020-04-05 21:30:25 +00:00
|
|
|
"github.com/hashicorp/nomad/helper"
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2016-05-11 05:23:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestJobDiff(t *testing.T) {
|
|
|
|
cases := []struct {
|
2016-05-11 18:10:09 +00:00
|
|
|
Old, New *Job
|
|
|
|
Expected *JobDiff
|
|
|
|
Error bool
|
|
|
|
Contextual bool
|
2016-05-11 05:23:34 +00:00
|
|
|
}{
|
|
|
|
{
|
|
|
|
Old: nil,
|
|
|
|
New: nil,
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Different IDs
|
|
|
|
Old: &Job{
|
|
|
|
ID: "foo",
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
ID: "bar",
|
|
|
|
},
|
|
|
|
Error: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Primitive only that is the same
|
|
|
|
Old: &Job{
|
|
|
|
Region: "foo",
|
|
|
|
ID: "foo",
|
|
|
|
Name: "foo",
|
|
|
|
Type: "batch",
|
|
|
|
Priority: 10,
|
|
|
|
AllAtOnce: true,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Region: "foo",
|
|
|
|
ID: "foo",
|
|
|
|
Name: "foo",
|
|
|
|
Type: "batch",
|
|
|
|
Priority: 10,
|
|
|
|
AllAtOnce: true,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
ID: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Primitive only that is has diffs
|
|
|
|
Old: &Job{
|
|
|
|
Region: "foo",
|
|
|
|
ID: "foo",
|
|
|
|
Name: "foo",
|
|
|
|
Type: "batch",
|
|
|
|
Priority: 10,
|
|
|
|
AllAtOnce: true,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Region: "bar",
|
|
|
|
ID: "foo",
|
|
|
|
Name: "bar",
|
|
|
|
Type: "system",
|
|
|
|
Priority: 100,
|
|
|
|
AllAtOnce: false,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
ID: "foo",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "AllAtOnce",
|
|
|
|
Old: "true",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Meta[foo]",
|
|
|
|
Old: "bar",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Priority",
|
|
|
|
Old: "10",
|
|
|
|
New: "100",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Region",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "batch",
|
|
|
|
New: "system",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Primitive only deleted job
|
|
|
|
Old: &Job{
|
|
|
|
Region: "foo",
|
|
|
|
ID: "foo",
|
|
|
|
Name: "foo",
|
|
|
|
Type: "batch",
|
|
|
|
Priority: 10,
|
|
|
|
AllAtOnce: true,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: nil,
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
ID: "foo",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "AllAtOnce",
|
|
|
|
Old: "true",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-06-11 17:06:49 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Dispatched",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Meta[foo]",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Priority",
|
|
|
|
Old: "10",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Region",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-04-16 23:54:02 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Stop",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "batch",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
2016-05-13 18:53:11 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Primitive only added job
|
|
|
|
Old: nil,
|
|
|
|
New: &Job{
|
|
|
|
Region: "foo",
|
|
|
|
ID: "foo",
|
|
|
|
Name: "foo",
|
|
|
|
Type: "batch",
|
|
|
|
Priority: 10,
|
|
|
|
AllAtOnce: true,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
ID: "foo",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "AllAtOnce",
|
|
|
|
Old: "",
|
|
|
|
New: "true",
|
|
|
|
},
|
2018-06-11 17:06:49 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Dispatched",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-05-13 18:53:11 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Meta[foo]",
|
|
|
|
Old: "",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Priority",
|
|
|
|
Old: "",
|
|
|
|
New: "10",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Region",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2017-04-16 23:54:02 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Stop",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-05-13 18:53:11 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "",
|
|
|
|
New: "batch",
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Map diff
|
|
|
|
Old: &Job{
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "foo",
|
|
|
|
"bar": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Meta: map[string]string{
|
|
|
|
"bar": "bar",
|
|
|
|
"baz": "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Meta[baz]",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Meta[foo]",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Datacenter diff both added and removed
|
|
|
|
Old: &Job{
|
|
|
|
Datacenters: []string{"foo", "bar"},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Datacenters: []string{"baz", "bar"},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Datacenter diff just added
|
|
|
|
Old: &Job{
|
|
|
|
Datacenters: []string{"foo", "bar"},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Datacenters: []string{"foo", "bar", "baz"},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Datacenter diff just deleted
|
|
|
|
Old: &Job{
|
|
|
|
Datacenters: []string{"foo", "bar"},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Datacenters: []string{"foo"},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-09-21 20:49:34 +00:00
|
|
|
{
|
2017-03-21 18:42:10 +00:00
|
|
|
// Datacenter contextual no change
|
2016-09-21 20:49:34 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Job{
|
|
|
|
Datacenters: []string{"foo", "bar"},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Datacenters: []string{"foo", "bar"},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
},
|
|
|
|
},
|
2017-03-21 18:42:10 +00:00
|
|
|
{
|
|
|
|
// Datacenter contextual
|
|
|
|
Contextual: true,
|
|
|
|
Old: &Job{
|
|
|
|
Datacenters: []string{"foo", "bar"},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Datacenters: []string{"foo", "bar", "baz"},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "bar",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
// Periodic added
|
|
|
|
Old: &Job{},
|
|
|
|
New: &Job{
|
|
|
|
Periodic: &PeriodicConfig{
|
|
|
|
Enabled: false,
|
|
|
|
Spec: "*/15 * * * * *",
|
|
|
|
SpecType: "foo",
|
|
|
|
ProhibitOverlap: false,
|
2017-02-15 23:23:29 +00:00
|
|
|
TimeZone: "Europe/Minsk",
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Periodic",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Enabled",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ProhibitOverlap",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Spec",
|
|
|
|
Old: "",
|
|
|
|
New: "*/15 * * * * *",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "SpecType",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2017-02-15 23:23:29 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "TimeZone",
|
|
|
|
Old: "",
|
|
|
|
New: "Europe/Minsk",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Periodic deleted
|
|
|
|
Old: &Job{
|
|
|
|
Periodic: &PeriodicConfig{
|
|
|
|
Enabled: false,
|
|
|
|
Spec: "*/15 * * * * *",
|
|
|
|
SpecType: "foo",
|
|
|
|
ProhibitOverlap: false,
|
2017-02-15 23:23:29 +00:00
|
|
|
TimeZone: "Europe/Minsk",
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Periodic",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Enabled",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ProhibitOverlap",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Spec",
|
|
|
|
Old: "*/15 * * * * *",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "SpecType",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-02-15 23:23:29 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "TimeZone",
|
|
|
|
Old: "Europe/Minsk",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
// Periodic edited
|
|
|
|
Old: &Job{
|
|
|
|
Periodic: &PeriodicConfig{
|
|
|
|
Enabled: false,
|
|
|
|
Spec: "*/15 * * * * *",
|
|
|
|
SpecType: "foo",
|
|
|
|
ProhibitOverlap: false,
|
2017-02-15 23:23:29 +00:00
|
|
|
TimeZone: "Europe/Minsk",
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Periodic: &PeriodicConfig{
|
|
|
|
Enabled: true,
|
|
|
|
Spec: "* * * * * *",
|
|
|
|
SpecType: "cron",
|
|
|
|
ProhibitOverlap: true,
|
2017-02-15 23:23:29 +00:00
|
|
|
TimeZone: "America/Los_Angeles",
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Periodic",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Enabled",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ProhibitOverlap",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Spec",
|
|
|
|
Old: "*/15 * * * * *",
|
|
|
|
New: "* * * * * *",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "SpecType",
|
|
|
|
Old: "foo",
|
|
|
|
New: "cron",
|
|
|
|
},
|
2017-02-15 23:23:29 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "TimeZone",
|
|
|
|
Old: "Europe/Minsk",
|
|
|
|
New: "America/Los_Angeles",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
{
|
|
|
|
// Periodic edited with context
|
|
|
|
Contextual: true,
|
|
|
|
Old: &Job{
|
|
|
|
Periodic: &PeriodicConfig{
|
|
|
|
Enabled: false,
|
|
|
|
Spec: "*/15 * * * * *",
|
|
|
|
SpecType: "foo",
|
|
|
|
ProhibitOverlap: false,
|
2017-02-15 23:23:29 +00:00
|
|
|
TimeZone: "Europe/Minsk",
|
2016-05-11 18:10:09 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Periodic: &PeriodicConfig{
|
|
|
|
Enabled: true,
|
|
|
|
Spec: "* * * * * *",
|
|
|
|
SpecType: "foo",
|
|
|
|
ProhibitOverlap: false,
|
2017-02-15 23:23:29 +00:00
|
|
|
TimeZone: "Europe/Minsk",
|
2016-05-11 18:10:09 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Periodic",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Enabled",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "ProhibitOverlap",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Spec",
|
|
|
|
Old: "*/15 * * * * *",
|
|
|
|
New: "* * * * * *",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "SpecType",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2017-02-15 23:23:29 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "TimeZone",
|
|
|
|
Old: "Europe/Minsk",
|
|
|
|
New: "Europe/Minsk",
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
// Constraints edited
|
|
|
|
Old: &Job{
|
|
|
|
Constraints: []*Constraint{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "bar",
|
|
|
|
RTarget: "bar",
|
|
|
|
Operand: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Constraints: []*Constraint{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "baz",
|
|
|
|
RTarget: "baz",
|
|
|
|
Operand: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Constraint",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Constraint",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-07-18 19:23:29 +00:00
|
|
|
{
|
|
|
|
// Affinities edited
|
|
|
|
Old: &Job{
|
|
|
|
Affinities: []*Affinity{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
Weight: 20,
|
|
|
|
str: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "bar",
|
|
|
|
RTarget: "bar",
|
|
|
|
Operand: "bar",
|
|
|
|
Weight: 20,
|
|
|
|
str: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
Affinities: []*Affinity{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
Weight: 20,
|
|
|
|
str: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "baz",
|
|
|
|
RTarget: "baz",
|
|
|
|
Operand: "baz",
|
|
|
|
Weight: 20,
|
|
|
|
str: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Affinity",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Weight",
|
|
|
|
Old: "",
|
|
|
|
New: "20",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Affinity",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Weight",
|
|
|
|
Old: "20",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
// Task groups edited
|
|
|
|
Old: &Job{
|
|
|
|
TaskGroups: []*TaskGroup{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Count: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
Count: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
|
|
|
TaskGroups: []*TaskGroup{
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Count: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bam",
|
|
|
|
Count: 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
TaskGroups: []*TaskGroupDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "bam",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "",
|
|
|
|
New: "1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "baz",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "foo",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "1",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-12-15 23:40:18 +00:00
|
|
|
{
|
2017-01-20 18:33:52 +00:00
|
|
|
// Parameterized Job added
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: &Job{},
|
|
|
|
New: &Job{
|
2017-01-20 18:33:52 +00:00
|
|
|
ParameterizedJob: &ParameterizedJobConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
Payload: DispatchPayloadRequired,
|
|
|
|
MetaOptional: []string{"foo"},
|
|
|
|
MetaRequired: []string{"bar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2017-01-20 18:33:52 +00:00
|
|
|
Name: "ParameterizedJob",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Payload",
|
|
|
|
Old: "",
|
|
|
|
New: DispatchPayloadRequired,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-01-20 18:33:52 +00:00
|
|
|
// Parameterized Job deleted
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: &Job{
|
2017-01-20 18:33:52 +00:00
|
|
|
ParameterizedJob: &ParameterizedJobConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
Payload: DispatchPayloadRequired,
|
|
|
|
MetaOptional: []string{"foo"},
|
|
|
|
MetaRequired: []string{"bar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2017-01-21 01:04:52 +00:00
|
|
|
Name: "ParameterizedJob",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Payload",
|
|
|
|
Old: DispatchPayloadRequired,
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-01-20 18:33:52 +00:00
|
|
|
// Parameterized Job edited
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: &Job{
|
2017-01-20 18:33:52 +00:00
|
|
|
ParameterizedJob: &ParameterizedJobConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
Payload: DispatchPayloadRequired,
|
|
|
|
MetaOptional: []string{"foo"},
|
|
|
|
MetaRequired: []string{"bar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
2017-01-20 18:33:52 +00:00
|
|
|
ParameterizedJob: &ParameterizedJobConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
Payload: DispatchPayloadOptional,
|
|
|
|
MetaOptional: []string{"bam"},
|
|
|
|
MetaRequired: []string{"bang"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2017-01-20 18:33:52 +00:00
|
|
|
Name: "ParameterizedJob",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Payload",
|
|
|
|
Old: DispatchPayloadRequired,
|
|
|
|
New: DispatchPayloadOptional,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "",
|
|
|
|
New: "bang",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-01-20 18:33:52 +00:00
|
|
|
// Parameterized Job edited with context
|
2016-12-15 23:40:18 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Job{
|
2017-01-20 18:33:52 +00:00
|
|
|
ParameterizedJob: &ParameterizedJobConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
Payload: DispatchPayloadRequired,
|
|
|
|
MetaOptional: []string{"foo"},
|
|
|
|
MetaRequired: []string{"bar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Job{
|
2017-01-20 18:33:52 +00:00
|
|
|
ParameterizedJob: &ParameterizedJobConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
Payload: DispatchPayloadOptional,
|
|
|
|
MetaOptional: []string{"foo"},
|
|
|
|
MetaRequired: []string{"bar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2017-01-20 18:33:52 +00:00
|
|
|
Name: "ParameterizedJob",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Payload",
|
|
|
|
Old: DispatchPayloadRequired,
|
|
|
|
New: DispatchPayloadOptional,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaOptional",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
2017-01-26 05:20:50 +00:00
|
|
|
Name: "MetaRequired",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: "bar",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-06-09 17:56:58 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// Multiregion: region added
|
|
|
|
Old: &Job{
|
2020-08-28 17:40:51 +00:00
|
|
|
NomadTokenID: "abcdef",
|
2020-06-09 17:56:58 +00:00
|
|
|
Multiregion: &Multiregion{
|
|
|
|
Strategy: &MultiregionStrategy{
|
|
|
|
MaxParallel: 1,
|
2020-06-16 19:17:53 +00:00
|
|
|
OnFailure: "fail_all",
|
2020-06-09 17:56:58 +00:00
|
|
|
},
|
|
|
|
Regions: []*MultiregionRegion{
|
|
|
|
{
|
|
|
|
Name: "west",
|
|
|
|
Count: 1,
|
|
|
|
Datacenters: []string{"west-1"},
|
|
|
|
Meta: map[string]string{"region_code": "W"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
New: &Job{
|
2020-08-28 17:40:51 +00:00
|
|
|
NomadTokenID: "12345",
|
2020-06-09 17:56:58 +00:00
|
|
|
Multiregion: &Multiregion{
|
|
|
|
Strategy: &MultiregionStrategy{
|
|
|
|
MaxParallel: 2,
|
2020-06-16 19:17:53 +00:00
|
|
|
OnFailure: "fail_all",
|
2020-06-09 17:56:58 +00:00
|
|
|
},
|
|
|
|
Regions: []*MultiregionRegion{
|
|
|
|
{
|
|
|
|
Name: "west",
|
2020-07-08 14:10:50 +00:00
|
|
|
Count: 3,
|
|
|
|
Datacenters: []string{"west-2"},
|
2020-06-09 17:56:58 +00:00
|
|
|
Meta: map[string]string{"region_code": "W"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "east",
|
|
|
|
Count: 2,
|
|
|
|
Datacenters: []string{"east-1", "east-2"},
|
|
|
|
Meta: map[string]string{"region_code": "E"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &JobDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Multiregion",
|
|
|
|
Objects: []*ObjectDiff{
|
2020-07-08 14:10:50 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Region",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "1",
|
|
|
|
New: "3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "",
|
|
|
|
New: "west-2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "west-1",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-06-09 17:56:58 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Region",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Meta[region_code]",
|
|
|
|
Old: "",
|
|
|
|
New: "E",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "east",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "",
|
|
|
|
New: "east-1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenters",
|
|
|
|
Old: "",
|
|
|
|
New: "east-2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Strategy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MaxParallel",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i, c := range cases {
|
2016-05-11 18:10:09 +00:00
|
|
|
actual, err := c.Old.Diff(c.New, c.Contextual)
|
2016-05-11 05:23:34 +00:00
|
|
|
if c.Error && err == nil {
|
2016-08-17 10:15:59 +00:00
|
|
|
t.Fatalf("case %d: expected errored", i+1)
|
2016-05-11 05:23:34 +00:00
|
|
|
} else if err != nil {
|
|
|
|
if !c.Error {
|
|
|
|
t.Fatalf("case %d: errored %#v", i+1, err)
|
|
|
|
} else {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(actual, c.Expected) {
|
|
|
|
t.Fatalf("case %d: got:\n%#v\n want:\n%#v\n",
|
|
|
|
i+1, actual, c.Expected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTaskGroupDiff(t *testing.T) {
|
|
|
|
cases := []struct {
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase string
|
2016-05-11 18:10:09 +00:00
|
|
|
Old, New *TaskGroup
|
|
|
|
Expected *TaskGroupDiff
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
ExpErr bool
|
2016-05-11 18:10:09 +00:00
|
|
|
Contextual bool
|
2016-05-11 05:23:34 +00:00
|
|
|
}{
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Empty",
|
|
|
|
Old: nil,
|
|
|
|
New: nil,
|
2016-05-11 05:23:34 +00:00
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Primitive only that has different names",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 10,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Name: "bar",
|
|
|
|
Count: 10,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
ExpErr: true,
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Primitive only that is the same",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 10,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 10,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Primitive only that has diffs",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 10,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 100,
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "foo",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "10",
|
|
|
|
New: "100",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Meta[foo]",
|
|
|
|
Old: "bar",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Map diff",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "foo",
|
|
|
|
"bar": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Meta: map[string]string{
|
|
|
|
"bar": "bar",
|
|
|
|
"baz": "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Meta[baz]",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Meta[foo]",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Constraints edited",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Constraints: []*Constraint{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "bar",
|
|
|
|
RTarget: "bar",
|
|
|
|
Operand: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Constraints: []*Constraint{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "baz",
|
|
|
|
RTarget: "baz",
|
|
|
|
Operand: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Constraint",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Constraint",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-07-16 13:30:58 +00:00
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Affinities edited",
|
2018-07-16 13:30:58 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Affinities: []*Affinity{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
Weight: 20,
|
|
|
|
str: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "bar",
|
|
|
|
RTarget: "bar",
|
|
|
|
Operand: "bar",
|
|
|
|
Weight: 20,
|
|
|
|
str: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Affinities: []*Affinity{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
Weight: 20,
|
|
|
|
str: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "baz",
|
|
|
|
RTarget: "baz",
|
|
|
|
Operand: "baz",
|
|
|
|
Weight: 20,
|
|
|
|
str: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Affinity",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Weight",
|
|
|
|
Old: "",
|
|
|
|
New: "20",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Affinity",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Weight",
|
|
|
|
Old: "20",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-03-16 18:22:21 +00:00
|
|
|
{
|
|
|
|
TestCase: "Consul added",
|
|
|
|
Old: &TaskGroup{},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Consul: &Consul{
|
|
|
|
Namespace: "team1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Consul",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Namespace",
|
|
|
|
Old: "",
|
|
|
|
New: "team1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TestCase: "Consul deleted",
|
|
|
|
Old: &TaskGroup{
|
|
|
|
Consul: &Consul{
|
|
|
|
Namespace: "team1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Consul",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Namespace",
|
|
|
|
Old: "team1",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TestCase: "Consul updated",
|
|
|
|
Old: &TaskGroup{
|
|
|
|
Consul: &Consul{
|
|
|
|
Namespace: "team1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Consul: &Consul{
|
|
|
|
Namespace: "team2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Consul",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Namespace",
|
|
|
|
Old: "team1",
|
|
|
|
New: "team2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "RestartPolicy added",
|
|
|
|
Old: &TaskGroup{},
|
2016-05-11 05:23:34 +00:00
|
|
|
New: &TaskGroup{
|
|
|
|
RestartPolicy: &RestartPolicy{
|
|
|
|
Attempts: 1,
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Delay: 1 * time.Second,
|
|
|
|
Mode: "fail",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "RestartPolicy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Attempts",
|
|
|
|
Old: "",
|
|
|
|
New: "1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Delay",
|
|
|
|
Old: "",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Mode",
|
|
|
|
Old: "",
|
|
|
|
New: "fail",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "RestartPolicy deleted",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
RestartPolicy: &RestartPolicy{
|
|
|
|
Attempts: 1,
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Delay: 1 * time.Second,
|
|
|
|
Mode: "fail",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "RestartPolicy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Attempts",
|
|
|
|
Old: "1",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Delay",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Mode",
|
|
|
|
Old: "fail",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "RestartPolicy edited",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
RestartPolicy: &RestartPolicy{
|
|
|
|
Attempts: 1,
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Delay: 1 * time.Second,
|
|
|
|
Mode: "fail",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
RestartPolicy: &RestartPolicy{
|
|
|
|
Attempts: 2,
|
|
|
|
Interval: 2 * time.Second,
|
|
|
|
Delay: 2 * time.Second,
|
|
|
|
Mode: "delay",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "RestartPolicy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Attempts",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Delay",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Mode",
|
|
|
|
Old: "fail",
|
|
|
|
New: "delay",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "RestartPolicy edited with context",
|
2016-05-11 18:10:09 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &TaskGroup{
|
|
|
|
RestartPolicy: &RestartPolicy{
|
|
|
|
Attempts: 1,
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Delay: 1 * time.Second,
|
|
|
|
Mode: "fail",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
RestartPolicy: &RestartPolicy{
|
|
|
|
Attempts: 2,
|
|
|
|
Interval: 2 * time.Second,
|
|
|
|
Delay: 1 * time.Second,
|
|
|
|
Mode: "fail",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "RestartPolicy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Attempts",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Delay",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Mode",
|
|
|
|
Old: "fail",
|
|
|
|
New: "fail",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "ReschedulePolicy added",
|
|
|
|
Old: &TaskGroup{},
|
2018-01-17 17:05:22 +00:00
|
|
|
New: &TaskGroup{
|
|
|
|
ReschedulePolicy: &ReschedulePolicy{
|
2018-02-22 23:43:07 +00:00
|
|
|
Attempts: 1,
|
|
|
|
Interval: 15 * time.Second,
|
|
|
|
Delay: 5 * time.Second,
|
2018-03-13 15:06:26 +00:00
|
|
|
MaxDelay: 20 * time.Second,
|
2018-02-22 23:43:07 +00:00
|
|
|
DelayFunction: "exponential",
|
|
|
|
Unlimited: false,
|
2018-01-17 17:05:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ReschedulePolicy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Attempts",
|
|
|
|
Old: "",
|
|
|
|
New: "1",
|
|
|
|
},
|
2018-02-22 23:43:07 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Delay",
|
|
|
|
Old: "",
|
|
|
|
New: "5000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "DelayFunction",
|
|
|
|
Old: "",
|
|
|
|
New: "exponential",
|
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "",
|
|
|
|
New: "15000000000",
|
|
|
|
},
|
2018-03-13 15:06:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MaxDelay",
|
|
|
|
Old: "",
|
|
|
|
New: "20000000000",
|
|
|
|
},
|
2018-02-22 23:43:07 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Unlimited",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "ReschedulePolicy deleted",
|
2018-01-17 17:05:22 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
ReschedulePolicy: &ReschedulePolicy{
|
2018-02-22 23:43:07 +00:00
|
|
|
Attempts: 1,
|
|
|
|
Interval: 15 * time.Second,
|
|
|
|
Delay: 5 * time.Second,
|
2018-03-13 15:06:26 +00:00
|
|
|
MaxDelay: 20 * time.Second,
|
2018-02-22 23:43:07 +00:00
|
|
|
DelayFunction: "exponential",
|
|
|
|
Unlimited: false,
|
2018-01-17 17:05:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ReschedulePolicy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Attempts",
|
|
|
|
Old: "1",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-02-22 23:43:07 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Delay",
|
|
|
|
Old: "5000000000",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "DelayFunction",
|
|
|
|
Old: "exponential",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "15000000000",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-03-13 15:06:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "MaxDelay",
|
|
|
|
Old: "20000000000",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-02-22 23:43:07 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Unlimited",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "ReschedulePolicy edited",
|
2018-01-17 17:05:22 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
ReschedulePolicy: &ReschedulePolicy{
|
2018-02-22 23:43:07 +00:00
|
|
|
Attempts: 1,
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
DelayFunction: "exponential",
|
|
|
|
Delay: 20 * time.Second,
|
2018-03-13 15:06:26 +00:00
|
|
|
MaxDelay: 1 * time.Minute,
|
2018-02-22 23:43:07 +00:00
|
|
|
Unlimited: false,
|
2018-01-17 17:05:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
ReschedulePolicy: &ReschedulePolicy{
|
2018-02-22 23:43:07 +00:00
|
|
|
Attempts: 2,
|
|
|
|
Interval: 2 * time.Second,
|
2018-03-26 19:45:09 +00:00
|
|
|
DelayFunction: "constant",
|
2018-02-22 23:43:07 +00:00
|
|
|
Delay: 30 * time.Second,
|
2018-03-13 15:06:26 +00:00
|
|
|
MaxDelay: 1 * time.Minute,
|
2018-02-22 23:43:07 +00:00
|
|
|
Unlimited: true,
|
2018-01-17 17:05:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ReschedulePolicy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Attempts",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
2018-02-22 23:43:07 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Delay",
|
|
|
|
Old: "20000000000",
|
|
|
|
New: "30000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "DelayFunction",
|
|
|
|
Old: "exponential",
|
2018-03-26 19:45:09 +00:00
|
|
|
New: "constant",
|
2018-02-22 23:43:07 +00:00
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
2018-02-22 23:43:07 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Unlimited",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
TestCase: "ReschedulePolicy edited with context",
|
2018-01-17 17:05:22 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &TaskGroup{
|
|
|
|
ReschedulePolicy: &ReschedulePolicy{
|
|
|
|
Attempts: 1,
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
ReschedulePolicy: &ReschedulePolicy{
|
|
|
|
Attempts: 1,
|
|
|
|
Interval: 2 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ReschedulePolicy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Attempts",
|
|
|
|
Old: "1",
|
|
|
|
New: "1",
|
|
|
|
},
|
2018-02-22 23:43:07 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Delay",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "DelayFunction",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
2018-03-13 15:06:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "MaxDelay",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
2018-02-22 23:43:07 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Unlimited",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
2018-01-17 17:05:22 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Update strategy deleted",
|
2017-05-09 00:44:26 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Update: &UpdateStrategy{
|
|
|
|
AutoRevert: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Update",
|
|
|
|
Fields: []*FieldDiff{
|
2019-05-09 13:42:18 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "AutoPromote",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "AutoRevert",
|
|
|
|
Old: "true",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Canary",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "HealthyDeadline",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "MaxParallel",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "MinHealthyTime",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-03-23 17:56:00 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ProgressDeadline",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Update strategy added",
|
|
|
|
Old: &TaskGroup{},
|
2017-05-09 00:44:26 +00:00
|
|
|
New: &TaskGroup{
|
|
|
|
Update: &UpdateStrategy{
|
|
|
|
AutoRevert: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Update",
|
|
|
|
Fields: []*FieldDiff{
|
2019-05-09 13:42:18 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "AutoPromote",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "AutoRevert",
|
|
|
|
Old: "",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Canary",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "HealthyDeadline",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MaxParallel",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MinHealthyTime",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
2018-03-23 17:56:00 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ProgressDeadline",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Update strategy edited",
|
2017-05-09 00:44:26 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Update: &UpdateStrategy{
|
2018-03-23 17:56:00 +00:00
|
|
|
MaxParallel: 5,
|
|
|
|
HealthCheck: "foo",
|
|
|
|
MinHealthyTime: 1 * time.Second,
|
|
|
|
HealthyDeadline: 30 * time.Second,
|
|
|
|
ProgressDeadline: 29 * time.Second,
|
|
|
|
AutoRevert: true,
|
2019-05-09 13:42:18 +00:00
|
|
|
AutoPromote: true,
|
2018-03-23 17:56:00 +00:00
|
|
|
Canary: 2,
|
2017-05-09 00:44:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Update: &UpdateStrategy{
|
2018-03-23 17:56:00 +00:00
|
|
|
MaxParallel: 7,
|
|
|
|
HealthCheck: "bar",
|
|
|
|
MinHealthyTime: 2 * time.Second,
|
|
|
|
HealthyDeadline: 31 * time.Second,
|
|
|
|
ProgressDeadline: 32 * time.Second,
|
|
|
|
AutoRevert: false,
|
2019-05-09 13:42:18 +00:00
|
|
|
AutoPromote: false,
|
2018-03-23 17:56:00 +00:00
|
|
|
Canary: 1,
|
2017-05-09 00:44:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Update",
|
|
|
|
Fields: []*FieldDiff{
|
2019-05-09 13:42:18 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "AutoPromote",
|
|
|
|
Old: "true",
|
|
|
|
New: "false",
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "AutoRevert",
|
|
|
|
Old: "true",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Canary",
|
|
|
|
Old: "2",
|
|
|
|
New: "1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "HealthCheck",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "HealthyDeadline",
|
|
|
|
Old: "30000000000",
|
|
|
|
New: "31000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MaxParallel",
|
|
|
|
Old: "5",
|
|
|
|
New: "7",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MinHealthyTime",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
2018-03-23 17:56:00 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ProgressDeadline",
|
|
|
|
Old: "29000000000",
|
|
|
|
New: "32000000000",
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Update strategy edited with context",
|
2017-05-09 00:44:26 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &TaskGroup{
|
|
|
|
Update: &UpdateStrategy{
|
2018-03-23 17:56:00 +00:00
|
|
|
MaxParallel: 5,
|
|
|
|
HealthCheck: "foo",
|
|
|
|
MinHealthyTime: 1 * time.Second,
|
|
|
|
HealthyDeadline: 30 * time.Second,
|
|
|
|
ProgressDeadline: 30 * time.Second,
|
|
|
|
AutoRevert: true,
|
2019-05-09 13:42:18 +00:00
|
|
|
AutoPromote: true,
|
2018-03-23 17:56:00 +00:00
|
|
|
Canary: 2,
|
2017-05-09 00:44:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Update: &UpdateStrategy{
|
2018-03-23 17:56:00 +00:00
|
|
|
MaxParallel: 7,
|
|
|
|
HealthCheck: "foo",
|
|
|
|
MinHealthyTime: 1 * time.Second,
|
|
|
|
HealthyDeadline: 30 * time.Second,
|
|
|
|
ProgressDeadline: 30 * time.Second,
|
|
|
|
AutoRevert: true,
|
2019-05-09 13:42:18 +00:00
|
|
|
AutoPromote: true,
|
2018-03-23 17:56:00 +00:00
|
|
|
Canary: 2,
|
2017-05-09 00:44:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Update",
|
|
|
|
Fields: []*FieldDiff{
|
2019-05-09 13:42:18 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "AutoPromote",
|
|
|
|
Old: "true",
|
|
|
|
New: "true",
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "AutoRevert",
|
|
|
|
Old: "true",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Canary",
|
|
|
|
Old: "2",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "HealthCheck",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "HealthyDeadline",
|
|
|
|
Old: "30000000000",
|
|
|
|
New: "30000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MaxParallel",
|
|
|
|
Old: "5",
|
|
|
|
New: "7",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "MinHealthyTime",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
2018-03-23 17:56:00 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "ProgressDeadline",
|
|
|
|
Old: "30000000000",
|
|
|
|
New: "30000000000",
|
|
|
|
},
|
2017-05-09 00:44:26 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-08-27 03:38:50 +00:00
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "EphemeralDisk added",
|
|
|
|
Old: &TaskGroup{},
|
2016-08-27 03:38:50 +00:00
|
|
|
New: &TaskGroup{
|
2016-09-14 22:43:42 +00:00
|
|
|
EphemeralDisk: &EphemeralDisk{
|
2016-10-06 21:14:59 +00:00
|
|
|
Migrate: true,
|
|
|
|
Sticky: true,
|
|
|
|
SizeMB: 100,
|
2016-08-27 03:38:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2016-09-14 22:43:42 +00:00
|
|
|
Name: "EphemeralDisk",
|
2016-08-27 03:38:50 +00:00
|
|
|
Fields: []*FieldDiff{
|
2016-10-06 21:14:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Migrate",
|
|
|
|
Old: "",
|
|
|
|
New: "true",
|
|
|
|
},
|
2016-08-27 03:38:50 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2016-09-14 22:43:42 +00:00
|
|
|
Name: "SizeMB",
|
2016-08-27 03:38:50 +00:00
|
|
|
Old: "",
|
|
|
|
New: "100",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Sticky",
|
|
|
|
Old: "",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "EphemeralDisk deleted",
|
2016-08-27 03:38:50 +00:00
|
|
|
Old: &TaskGroup{
|
2016-09-14 22:43:42 +00:00
|
|
|
EphemeralDisk: &EphemeralDisk{
|
2016-10-06 21:14:59 +00:00
|
|
|
Migrate: true,
|
|
|
|
Sticky: true,
|
|
|
|
SizeMB: 100,
|
2016-08-27 03:38:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2016-09-14 22:43:42 +00:00
|
|
|
Name: "EphemeralDisk",
|
2016-08-27 03:38:50 +00:00
|
|
|
Fields: []*FieldDiff{
|
2016-10-06 21:14:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Migrate",
|
|
|
|
Old: "true",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-08-27 03:38:50 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2016-09-14 22:43:42 +00:00
|
|
|
Name: "SizeMB",
|
2016-08-27 03:38:50 +00:00
|
|
|
Old: "100",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Sticky",
|
|
|
|
Old: "true",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "EphemeralDisk edited",
|
2016-08-27 03:38:50 +00:00
|
|
|
Old: &TaskGroup{
|
2016-09-14 22:43:42 +00:00
|
|
|
EphemeralDisk: &EphemeralDisk{
|
2016-10-06 21:14:59 +00:00
|
|
|
Migrate: true,
|
|
|
|
Sticky: true,
|
|
|
|
SizeMB: 150,
|
2016-08-27 03:38:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
2016-09-14 22:43:42 +00:00
|
|
|
EphemeralDisk: &EphemeralDisk{
|
2016-10-06 21:14:59 +00:00
|
|
|
Migrate: false,
|
|
|
|
Sticky: false,
|
|
|
|
SizeMB: 90,
|
2016-08-27 03:38:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2016-09-14 22:43:42 +00:00
|
|
|
Name: "EphemeralDisk",
|
2016-08-27 03:38:50 +00:00
|
|
|
Fields: []*FieldDiff{
|
2016-10-06 21:14:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Migrate",
|
|
|
|
Old: "true",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-08-27 03:38:50 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2016-09-14 22:43:42 +00:00
|
|
|
Name: "SizeMB",
|
2016-08-27 03:38:50 +00:00
|
|
|
Old: "150",
|
|
|
|
New: "90",
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Sticky",
|
|
|
|
Old: "true",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "EphemeralDisk edited with context",
|
2016-08-27 03:38:50 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &TaskGroup{
|
2016-09-14 22:43:42 +00:00
|
|
|
EphemeralDisk: &EphemeralDisk{
|
2016-10-06 21:14:59 +00:00
|
|
|
Migrate: false,
|
|
|
|
Sticky: false,
|
|
|
|
SizeMB: 100,
|
2016-08-27 03:38:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
2016-09-14 22:43:42 +00:00
|
|
|
EphemeralDisk: &EphemeralDisk{
|
2016-10-06 21:14:59 +00:00
|
|
|
Migrate: true,
|
|
|
|
Sticky: true,
|
|
|
|
SizeMB: 90,
|
2016-08-27 03:38:50 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2016-09-14 22:43:42 +00:00
|
|
|
Name: "EphemeralDisk",
|
2016-08-27 03:38:50 +00:00
|
|
|
Fields: []*FieldDiff{
|
2016-10-06 21:14:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Migrate",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
2016-08-27 03:38:50 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2016-09-14 22:43:42 +00:00
|
|
|
Name: "SizeMB",
|
2016-08-27 03:38:50 +00:00
|
|
|
Old: "100",
|
|
|
|
New: "90",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Sticky",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "TaskGroup Services edited",
|
2019-08-19 19:43:06 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &TaskGroup{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
Name: "foo",
|
2021-03-16 18:22:21 +00:00
|
|
|
Namespace: "team1",
|
2020-06-22 17:55:59 +00:00
|
|
|
TaskName: "task1",
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
EnableTagOverride: false,
|
2019-08-19 19:43:06 +00:00
|
|
|
Checks: []*ServiceCheck{
|
|
|
|
{
|
2020-08-08 01:22:06 +00:00
|
|
|
Name: "foo",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
2021-03-25 01:36:35 +00:00
|
|
|
Method: "POST",
|
|
|
|
Body: "{\"key\": \"value\"}",
|
2020-08-08 01:22:06 +00:00
|
|
|
Expose: true,
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
SuccessBeforePassing: 3,
|
|
|
|
FailuresBeforeCritical: 4,
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Connect: &ConsulConnect{
|
2020-06-22 17:55:59 +00:00
|
|
|
Native: false,
|
2019-08-19 19:43:06 +00:00
|
|
|
SidecarTask: &SidecarTask{
|
|
|
|
Name: "sidecar",
|
|
|
|
Driver: "docker",
|
|
|
|
Env: map[string]string{
|
|
|
|
"FOO": "BAR",
|
|
|
|
},
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": "baz",
|
|
|
|
},
|
|
|
|
},
|
2020-07-28 20:12:08 +00:00
|
|
|
Gateway: &ConsulGateway{
|
|
|
|
Proxy: &ConsulGatewayProxy{
|
|
|
|
ConnectTimeout: helper.TimeToPtr(1 * time.Second),
|
|
|
|
EnvoyGatewayBindTaggedAddresses: false,
|
|
|
|
EnvoyGatewayBindAddresses: map[string]*ConsulGatewayBindAddress{
|
|
|
|
"service1": {
|
|
|
|
Address: "10.0.0.1",
|
|
|
|
Port: 2001,
|
|
|
|
},
|
|
|
|
},
|
2020-12-15 20:38:33 +00:00
|
|
|
EnvoyDNSDiscoveryType: "STRICT_DNS",
|
2020-07-28 20:12:08 +00:00
|
|
|
EnvoyGatewayNoDefaultBind: false,
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 1,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Ingress: &ConsulIngressConfigEntry{
|
|
|
|
TLS: &ConsulGatewayTLSConfig{
|
|
|
|
Enabled: false,
|
|
|
|
},
|
|
|
|
Listeners: []*ConsulIngressListener{{
|
|
|
|
Port: 3001,
|
|
|
|
Protocol: "tcp",
|
|
|
|
Services: []*ConsulIngressService{{
|
|
|
|
Name: "listener1",
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
},
|
2020-12-15 20:38:33 +00:00
|
|
|
Terminating: &ConsulTerminatingConfigEntry{
|
|
|
|
Services: []*ConsulLinkedService{{
|
|
|
|
Name: "linked1",
|
|
|
|
CAFile: "ca1.pem",
|
|
|
|
CertFile: "cert1.pem",
|
|
|
|
KeyFile: "key1.pem",
|
|
|
|
SNI: "linked1.consul",
|
|
|
|
}},
|
|
|
|
},
|
2021-04-12 19:10:10 +00:00
|
|
|
Mesh: &ConsulMeshConfigEntry{
|
|
|
|
// nothing
|
|
|
|
},
|
2020-07-28 20:12:08 +00:00
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
New: &TaskGroup{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
Name: "foo",
|
2021-03-16 18:22:21 +00:00
|
|
|
Namespace: "team1",
|
2020-06-22 17:55:59 +00:00
|
|
|
TaskName: "task2",
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
EnableTagOverride: true,
|
2019-08-19 19:43:06 +00:00
|
|
|
Checks: []*ServiceCheck{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Type: "tcp",
|
|
|
|
Command: "bar",
|
|
|
|
Path: "bar",
|
|
|
|
Protocol: "tcp",
|
connect: enable automatic expose paths for individual group service checks
Part of #6120
Building on the support for enabling connect proxy paths in #7323, this change
adds the ability to configure the 'service.check.expose' flag on group-level
service check definitions for services that are connect-enabled. This is a slight
deviation from the "magic" that Consul provides. With Consul, the 'expose' flag
exists on the connect.proxy stanza, which will then auto-generate expose paths
for every HTTP and gRPC service check associated with that connect-enabled
service.
A first attempt at providing similar magic for Nomad's Consul Connect integration
followed that pattern exactly, as seen in #7396. However, on reviewing the PR
we realized having the `expose` flag on the proxy stanza inseperably ties together
the automatic path generation with every HTTP/gRPC defined on the service. This
makes sense in Consul's context, because a service definition is reasonably
associated with a single "task". With Nomad's group level service definitions
however, there is a reasonable expectation that a service definition is more
abstractly representative of multiple services within the task group. In this
case, one would want to define checks of that service which concretely make HTTP
or gRPC requests to different underlying tasks. Such a model is not possible
with the course `proxy.expose` flag.
Instead, we now have the flag made available within the check definitions themselves.
By making the expose feature resolute to each check, it is possible to have
some HTTP/gRPC checks which make use of the envoy exposed paths, as well as
some HTTP/gRPC checks which make use of some orthongonal port-mapping to do
checks on some other task (or even some other bound port of the same task)
within the task group.
Given this example,
group "server-group" {
network {
mode = "bridge"
port "forchecks" {
to = -1
}
}
service {
name = "myserver"
port = 2000
connect {
sidecar_service {
}
}
check {
name = "mycheck-myserver"
type = "http"
port = "forchecks"
interval = "3s"
timeout = "2s"
method = "GET"
path = "/classic/responder/health"
expose = true
}
}
}
Nomad will automatically inject (via job endpoint mutator) the
extrapolated expose path configuration, i.e.
expose {
path {
path = "/classic/responder/health"
protocol = "http"
local_path_port = 2000
listener_port = "forchecks"
}
}
Documentation is coming in #7440 (needs updating, doing next)
Modifications to the `countdash` examples in https://github.com/hashicorp/demo-consul-101/pull/6
which will make the examples in the documentation actually runnable.
Will add some e2e tests based on the above when it becomes available.
2020-03-25 01:49:55 +00:00
|
|
|
Expose: false,
|
2019-08-19 19:43:06 +00:00
|
|
|
Interval: 2 * time.Second,
|
|
|
|
Timeout: 2 * time.Second,
|
|
|
|
Header: map[string][]string{
|
|
|
|
"Foo": {"baz"},
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
SuccessBeforePassing: 5,
|
|
|
|
FailuresBeforeCritical: 6,
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Connect: &ConsulConnect{
|
2020-06-22 17:55:59 +00:00
|
|
|
Native: true,
|
2019-08-19 19:43:06 +00:00
|
|
|
SidecarService: &ConsulSidecarService{
|
|
|
|
Port: "http",
|
|
|
|
Proxy: &ConsulProxy{
|
2019-09-23 18:30:48 +00:00
|
|
|
LocalServiceAddress: "127.0.0.1",
|
|
|
|
LocalServicePort: 8080,
|
2019-08-19 19:43:06 +00:00
|
|
|
Upstreams: []ConsulUpstream{
|
|
|
|
{
|
2021-02-23 15:49:18 +00:00
|
|
|
DestinationName: "foo",
|
|
|
|
LocalBindPort: 8000,
|
|
|
|
Datacenter: "dc2",
|
|
|
|
LocalBindAddress: "127.0.0.2",
|
2021-04-12 19:10:10 +00:00
|
|
|
MeshGateway: &ConsulMeshGateway{
|
|
|
|
Mode: "remote",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": "qux",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-07-28 20:12:08 +00:00
|
|
|
Gateway: &ConsulGateway{
|
|
|
|
Proxy: &ConsulGatewayProxy{
|
|
|
|
ConnectTimeout: helper.TimeToPtr(2 * time.Second),
|
|
|
|
EnvoyGatewayBindTaggedAddresses: true,
|
|
|
|
EnvoyGatewayBindAddresses: map[string]*ConsulGatewayBindAddress{
|
|
|
|
"service1": {
|
|
|
|
Address: "10.0.0.2",
|
|
|
|
Port: 2002,
|
|
|
|
},
|
|
|
|
},
|
2020-12-15 20:38:33 +00:00
|
|
|
EnvoyDNSDiscoveryType: "LOGICAL_DNS",
|
2020-07-28 20:12:08 +00:00
|
|
|
EnvoyGatewayNoDefaultBind: true,
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Ingress: &ConsulIngressConfigEntry{
|
|
|
|
TLS: &ConsulGatewayTLSConfig{
|
|
|
|
Enabled: true,
|
|
|
|
},
|
|
|
|
Listeners: []*ConsulIngressListener{{
|
|
|
|
Port: 3002,
|
|
|
|
Protocol: "http",
|
|
|
|
Services: []*ConsulIngressService{{
|
|
|
|
Name: "listener2",
|
|
|
|
Hosts: []string{"127.0.0.1", "127.0.0.1:3002"},
|
|
|
|
}},
|
|
|
|
}},
|
|
|
|
},
|
2020-12-15 20:38:33 +00:00
|
|
|
Terminating: &ConsulTerminatingConfigEntry{
|
|
|
|
Services: []*ConsulLinkedService{{
|
|
|
|
Name: "linked2",
|
|
|
|
CAFile: "ca2.pem",
|
|
|
|
CertFile: "cert2.pem",
|
|
|
|
KeyFile: "key2.pem",
|
|
|
|
SNI: "linked2.consul",
|
|
|
|
}},
|
|
|
|
},
|
2021-04-12 19:10:10 +00:00
|
|
|
Mesh: &ConsulMeshConfigEntry{
|
|
|
|
// nothing
|
|
|
|
},
|
2020-07-28 20:12:08 +00:00
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "AddressMode",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "EnableTagOverride",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2021-03-16 18:22:21 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Namespace",
|
|
|
|
Old: "team1",
|
|
|
|
New: "team1",
|
|
|
|
},
|
2021-01-22 19:45:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "OnUpdate",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "PortLabel",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2020-06-22 17:55:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "TaskName",
|
|
|
|
Old: "task1",
|
|
|
|
New: "task2",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Check",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "AddressMode",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2021-03-25 01:51:13 +00:00
|
|
|
{
|
2021-03-25 01:36:35 +00:00
|
|
|
Type: DiffTypeDeleted,
|
2021-03-25 01:51:13 +00:00
|
|
|
Name: "Body",
|
2021-03-25 01:36:35 +00:00
|
|
|
Old: "{\"key\": \"value\"}",
|
2021-03-25 01:51:13 +00:00
|
|
|
New: "",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Command",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
connect: enable automatic expose paths for individual group service checks
Part of #6120
Building on the support for enabling connect proxy paths in #7323, this change
adds the ability to configure the 'service.check.expose' flag on group-level
service check definitions for services that are connect-enabled. This is a slight
deviation from the "magic" that Consul provides. With Consul, the 'expose' flag
exists on the connect.proxy stanza, which will then auto-generate expose paths
for every HTTP and gRPC service check associated with that connect-enabled
service.
A first attempt at providing similar magic for Nomad's Consul Connect integration
followed that pattern exactly, as seen in #7396. However, on reviewing the PR
we realized having the `expose` flag on the proxy stanza inseperably ties together
the automatic path generation with every HTTP/gRPC defined on the service. This
makes sense in Consul's context, because a service definition is reasonably
associated with a single "task". With Nomad's group level service definitions
however, there is a reasonable expectation that a service definition is more
abstractly representative of multiple services within the task group. In this
case, one would want to define checks of that service which concretely make HTTP
or gRPC requests to different underlying tasks. Such a model is not possible
with the course `proxy.expose` flag.
Instead, we now have the flag made available within the check definitions themselves.
By making the expose feature resolute to each check, it is possible to have
some HTTP/gRPC checks which make use of the envoy exposed paths, as well as
some HTTP/gRPC checks which make use of some orthongonal port-mapping to do
checks on some other task (or even some other bound port of the same task)
within the task group.
Given this example,
group "server-group" {
network {
mode = "bridge"
port "forchecks" {
to = -1
}
}
service {
name = "myserver"
port = 2000
connect {
sidecar_service {
}
}
check {
name = "mycheck-myserver"
type = "http"
port = "forchecks"
interval = "3s"
timeout = "2s"
method = "GET"
path = "/classic/responder/health"
expose = true
}
}
}
Nomad will automatically inject (via job endpoint mutator) the
extrapolated expose path configuration, i.e.
expose {
path {
path = "/classic/responder/health"
protocol = "http"
local_path_port = 2000
listener_port = "forchecks"
}
}
Documentation is coming in #7440 (needs updating, doing next)
Modifications to the `countdash` examples in https://github.com/hashicorp/demo-consul-101/pull/6
which will make the examples in the documentation actually runnable.
Will add some e2e tests based on the above when it becomes available.
2020-03-25 01:49:55 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Expose",
|
|
|
|
Old: "true",
|
|
|
|
New: "false",
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "FailuresBeforeCritical",
|
|
|
|
Old: "4",
|
|
|
|
New: "6",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "GRPCService",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "GRPCUseTLS",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "InitialStatus",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
|
|
|
{
|
2021-03-25 01:36:35 +00:00
|
|
|
Type: DiffTypeDeleted,
|
2019-08-19 19:43:06 +00:00
|
|
|
Name: "Method",
|
2021-03-25 01:36:35 +00:00
|
|
|
Old: "POST",
|
2019-08-19 19:43:06 +00:00
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2021-01-22 19:45:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "OnUpdate",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Path",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "PortLabel",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Protocol",
|
|
|
|
Old: "http",
|
|
|
|
New: "tcp",
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "SuccessBeforePassing",
|
|
|
|
Old: "3",
|
|
|
|
New: "5",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "TLSSkipVerify",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "TaskName",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Timeout",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "http",
|
|
|
|
New: "tcp",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Header",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Foo[0]",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ConsulConnect",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
2020-06-22 17:55:59 +00:00
|
|
|
Type: DiffTypeEdited,
|
2019-08-19 19:43:06 +00:00
|
|
|
Name: "Native",
|
2020-06-22 17:55:59 +00:00
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "SidecarService",
|
|
|
|
Fields: []*FieldDiff{
|
2021-05-07 16:10:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "DisableDefaultTCPCheck",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Port",
|
|
|
|
Old: "",
|
|
|
|
New: "http",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ConsulProxy",
|
2019-09-23 18:30:48 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LocalServiceAddress",
|
|
|
|
Old: "",
|
|
|
|
New: "127.0.0.1",
|
|
|
|
}, {
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LocalServicePort",
|
|
|
|
Old: "",
|
|
|
|
New: "8080",
|
|
|
|
},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ConsulUpstreams",
|
|
|
|
Fields: []*FieldDiff{
|
2020-11-30 15:57:29 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Datacenter",
|
|
|
|
Old: "",
|
|
|
|
New: "dc2",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "DestinationName",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2021-02-23 15:49:18 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LocalBindAddress",
|
|
|
|
Old: "",
|
|
|
|
New: "127.0.0.2",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LocalBindPort",
|
|
|
|
Old: "",
|
|
|
|
New: "8000",
|
|
|
|
},
|
|
|
|
},
|
2021-04-12 19:10:10 +00:00
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MeshGateway",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Mode",
|
|
|
|
Old: "",
|
|
|
|
New: "remote",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Config",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "foo",
|
|
|
|
Old: "",
|
|
|
|
New: "qux",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "SidecarTask",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Driver",
|
|
|
|
Old: "docker",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Env[FOO]",
|
|
|
|
Old: "BAR",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "sidecar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Config",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "foo",
|
|
|
|
Old: "baz",
|
|
|
|
New: "",
|
|
|
|
},
|
2020-07-28 20:12:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Gateway",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Proxy",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ConnectTimeout",
|
|
|
|
Old: "1s",
|
|
|
|
New: "2s",
|
|
|
|
},
|
2020-12-15 20:38:33 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "EnvoyDNSDiscoveryType",
|
|
|
|
Old: "STRICT_DNS",
|
|
|
|
New: "LOGICAL_DNS",
|
|
|
|
},
|
2020-07-28 20:12:08 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "EnvoyGatewayBindTaggedAddresses",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "EnvoyGatewayNoDefaultBind",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "EnvoyGatewayBindAddresses",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "service1",
|
|
|
|
Old: "10.0.0.1:2001",
|
|
|
|
New: "10.0.0.2:2002",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Config",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "foo",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Ingress",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "TLS",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Enabled",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Listener",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Port",
|
|
|
|
Old: "",
|
|
|
|
New: "3002",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Protocol",
|
|
|
|
Old: "",
|
|
|
|
New: "http",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ConsulIngressService",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "listener2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Hosts",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Hosts",
|
|
|
|
Old: "",
|
|
|
|
New: "127.0.0.1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Hosts",
|
|
|
|
Old: "",
|
|
|
|
New: "127.0.0.1:3002",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Listener",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Port",
|
|
|
|
Old: "3001",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Protocol",
|
|
|
|
Old: "tcp",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ConsulIngressService",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "listener1",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
2020-12-15 20:38:33 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Terminating",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "CAFile",
|
|
|
|
Old: "",
|
|
|
|
New: "ca2.pem",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "CertFile",
|
|
|
|
Old: "",
|
|
|
|
New: "cert2.pem",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "KeyFile",
|
|
|
|
Old: "",
|
|
|
|
New: "key2.pem",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "linked2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "SNI",
|
|
|
|
Old: "",
|
|
|
|
New: "linked2.consul",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "CAFile",
|
|
|
|
Old: "ca1.pem",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "CertFile",
|
|
|
|
Old: "cert1.pem",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "KeyFile",
|
|
|
|
Old: "key1.pem",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "linked1",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "SNI",
|
|
|
|
Old: "linked1.consul",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "TaskGroup Networks edited",
|
2019-08-19 19:43:06 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &TaskGroup{
|
|
|
|
Networks: Networks{
|
|
|
|
{
|
|
|
|
Device: "foo",
|
|
|
|
CIDR: "foo",
|
|
|
|
IP: "foo",
|
|
|
|
MBits: 100,
|
|
|
|
ReservedPorts: []Port{
|
|
|
|
{
|
|
|
|
Label: "foo",
|
|
|
|
Value: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Networks: Networks{
|
|
|
|
{
|
|
|
|
Device: "bar",
|
|
|
|
CIDR: "bar",
|
|
|
|
IP: "bar",
|
|
|
|
MBits: 200,
|
|
|
|
DynamicPorts: []Port{
|
|
|
|
{
|
2020-06-19 17:53:31 +00:00
|
|
|
Label: "bar",
|
|
|
|
To: 8081,
|
|
|
|
HostNetwork: "public",
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
2020-04-28 03:11:06 +00:00
|
|
|
DNS: &DNSConfig{
|
|
|
|
Servers: []string{"1.1.1.1"},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Network",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MBits",
|
|
|
|
Old: "",
|
|
|
|
New: "200",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Mode",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Dynamic Port",
|
|
|
|
Fields: []*FieldDiff{
|
2020-06-19 17:53:31 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "HostNetwork",
|
|
|
|
Old: "",
|
|
|
|
New: "public",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Label",
|
|
|
|
Old: "",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "To",
|
|
|
|
Old: "",
|
|
|
|
New: "8081",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-04-28 03:11:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "DNS",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Servers",
|
|
|
|
Old: "",
|
|
|
|
New: "1.1.1.1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Network",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "MBits",
|
|
|
|
Old: "100",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Mode",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Static Port",
|
|
|
|
Fields: []*FieldDiff{
|
2020-06-19 17:53:31 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "HostNetwork",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Label",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "To",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Value",
|
|
|
|
Old: "80",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
TestCase: "Tasks edited",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &TaskGroup{
|
|
|
|
Tasks: []*Task{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Driver: "docker",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Driver: "docker",
|
|
|
|
},
|
|
|
|
{
|
2017-08-17 00:54:11 +00:00
|
|
|
Name: "baz",
|
|
|
|
ShutdownDelay: 1 * time.Second,
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Tasks: []*Task{
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Driver: "docker",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bam",
|
|
|
|
Driver: "docker",
|
|
|
|
},
|
2017-08-17 21:05:51 +00:00
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
ShutdownDelay: 2 * time.Second,
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Tasks: []*TaskDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "bam",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Driver",
|
|
|
|
Old: "",
|
|
|
|
New: "docker",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "KillTimeout",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
2017-02-13 22:31:22 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Leader",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2017-08-17 21:05:51 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ShutdownDelay",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "baz",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2017-08-17 21:05:51 +00:00
|
|
|
Name: "ShutdownDelay",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "foo",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Driver",
|
|
|
|
Old: "docker",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "KillTimeout",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-02-13 22:31:22 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Leader",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-08-17 21:05:51 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ShutdownDelay",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-04-05 21:30:25 +00:00
|
|
|
{
|
|
|
|
TestCase: "TaskGroup shutdown_delay edited",
|
|
|
|
Old: &TaskGroup{
|
|
|
|
ShutdownDelay: helper.TimeToPtr(30 * time.Second),
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
ShutdownDelay: helper.TimeToPtr(5 * time.Second),
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ShutdownDelay",
|
|
|
|
Old: "30000000000",
|
|
|
|
New: "5000000000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2020-04-06 15:53:46 +00:00
|
|
|
{
|
|
|
|
TestCase: "TaskGroup shutdown_delay removed",
|
|
|
|
Old: &TaskGroup{
|
|
|
|
ShutdownDelay: helper.TimeToPtr(30 * time.Second),
|
|
|
|
},
|
|
|
|
New: &TaskGroup{},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ShutdownDelay",
|
|
|
|
Old: "30000000000",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
TestCase: "TaskGroup shutdown_delay added",
|
|
|
|
Old: &TaskGroup{},
|
|
|
|
New: &TaskGroup{
|
|
|
|
ShutdownDelay: helper.TimeToPtr(30 * time.Second),
|
|
|
|
},
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ShutdownDelay",
|
|
|
|
Old: "",
|
|
|
|
New: "30000000000",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:49:15 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
TestCase: "TaskGroup volumes added",
|
|
|
|
Old: &TaskGroup{},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Volumes: map[string]*VolumeRequest{
|
2021-03-16 18:22:21 +00:00
|
|
|
"foo": {
|
2021-02-04 19:49:15 +00:00
|
|
|
Name: "foo",
|
|
|
|
Type: "host",
|
|
|
|
Source: "foo-src",
|
|
|
|
ReadOnly: true,
|
2021-03-18 19:35:11 +00:00
|
|
|
PerAlloc: true,
|
2021-02-04 19:49:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Volume",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2021-03-18 19:35:11 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "PerAlloc",
|
|
|
|
Old: "",
|
|
|
|
New: "true",
|
|
|
|
},
|
2021-02-04 19:49:15 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ReadOnly",
|
|
|
|
Old: "",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Source",
|
|
|
|
Old: "",
|
|
|
|
New: "foo-src",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "",
|
|
|
|
New: "host",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
TestCase: "TaskGroup volumes edited",
|
|
|
|
Old: &TaskGroup{
|
|
|
|
Volumes: map[string]*VolumeRequest{
|
2021-03-16 18:22:21 +00:00
|
|
|
"foo": {
|
2021-02-04 19:49:15 +00:00
|
|
|
Name: "foo",
|
|
|
|
Type: "csi",
|
|
|
|
Source: "foo-src1",
|
|
|
|
ReadOnly: false,
|
|
|
|
MountOptions: &CSIMountOptions{
|
|
|
|
FSType: "ext4",
|
|
|
|
MountFlags: []string{"relatime", "rw"},
|
|
|
|
},
|
|
|
|
},
|
2021-03-16 18:22:21 +00:00
|
|
|
"bar": {
|
2021-02-04 19:49:15 +00:00
|
|
|
Name: "bar",
|
|
|
|
Type: "host",
|
|
|
|
Source: "bar-src",
|
|
|
|
ReadOnly: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &TaskGroup{
|
|
|
|
Volumes: map[string]*VolumeRequest{
|
2021-03-16 18:22:21 +00:00
|
|
|
"foo": {
|
2021-02-04 19:49:15 +00:00
|
|
|
Name: "foo",
|
|
|
|
Type: "csi",
|
|
|
|
Source: "foo-src2",
|
|
|
|
ReadOnly: true,
|
|
|
|
MountOptions: &CSIMountOptions{
|
|
|
|
FSType: "ext4",
|
|
|
|
MountFlags: []string{"relatime", "rw", "nosuid"},
|
|
|
|
},
|
|
|
|
},
|
2021-03-16 18:22:21 +00:00
|
|
|
"bar": { // untouched
|
2021-02-04 19:49:15 +00:00
|
|
|
Name: "bar",
|
|
|
|
Type: "host",
|
|
|
|
Source: "bar-src",
|
|
|
|
ReadOnly: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
Expected: &TaskGroupDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Volume",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ReadOnly",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Source",
|
|
|
|
Old: "foo-src1",
|
|
|
|
New: "foo-src2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MountOptions",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MountFlags",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MountFlags",
|
|
|
|
Old: "",
|
|
|
|
New: "nosuid",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i, c := range cases {
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
require.NotEmpty(t, c.TestCase, "case #%d needs a name", i+1)
|
2016-05-11 05:23:34 +00:00
|
|
|
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
t.Run(c.TestCase, func(t *testing.T) {
|
|
|
|
result, err := c.Old.Diff(c.New, c.Contextual)
|
|
|
|
switch c.ExpErr {
|
|
|
|
case true:
|
|
|
|
require.Error(t, err, "case %q expected error", c.TestCase)
|
|
|
|
case false:
|
|
|
|
require.NoError(t, err, "case %q expected no error", c.TestCase)
|
2021-05-07 16:10:26 +00:00
|
|
|
require.Equal(t, c.Expected, result)
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
}
|
|
|
|
})
|
2016-05-11 05:23:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTaskDiff(t *testing.T) {
|
|
|
|
cases := []struct {
|
2017-04-19 18:37:57 +00:00
|
|
|
Name string
|
2016-05-11 18:10:09 +00:00
|
|
|
Old, New *Task
|
|
|
|
Expected *TaskDiff
|
|
|
|
Error bool
|
|
|
|
Contextual bool
|
2016-05-11 05:23:34 +00:00
|
|
|
}{
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Empty",
|
|
|
|
Old: nil,
|
|
|
|
New: nil,
|
2016-05-11 05:23:34 +00:00
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Primitive only that has different names",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Name: "foo",
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Name: "bar",
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Error: true,
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Primitive only that is the same",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Name: "foo",
|
|
|
|
Driver: "exec",
|
|
|
|
User: "foo",
|
|
|
|
Env: map[string]string{
|
|
|
|
"FOO": "bar",
|
|
|
|
},
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
KillTimeout: 1 * time.Second,
|
2017-02-11 00:57:47 +00:00
|
|
|
Leader: true,
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Name: "foo",
|
|
|
|
Driver: "exec",
|
|
|
|
User: "foo",
|
|
|
|
Env: map[string]string{
|
|
|
|
"FOO": "bar",
|
|
|
|
},
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
KillTimeout: 1 * time.Second,
|
2017-02-11 00:57:47 +00:00
|
|
|
Leader: true,
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Primitive only that has diffs",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Name: "foo",
|
|
|
|
Driver: "exec",
|
|
|
|
User: "foo",
|
|
|
|
Env: map[string]string{
|
|
|
|
"FOO": "bar",
|
|
|
|
},
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
KillTimeout: 1 * time.Second,
|
2017-02-11 00:57:47 +00:00
|
|
|
Leader: true,
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Name: "foo",
|
|
|
|
Driver: "docker",
|
|
|
|
User: "bar",
|
|
|
|
Env: map[string]string{
|
|
|
|
"FOO": "baz",
|
|
|
|
},
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "baz",
|
|
|
|
},
|
|
|
|
KillTimeout: 2 * time.Second,
|
2017-02-11 00:57:47 +00:00
|
|
|
Leader: false,
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "foo",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Driver",
|
|
|
|
Old: "exec",
|
|
|
|
New: "docker",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Env[FOO]",
|
|
|
|
Old: "bar",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "KillTimeout",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "2000000000",
|
|
|
|
},
|
2017-02-11 00:57:47 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Leader",
|
|
|
|
Old: "true",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Meta[foo]",
|
|
|
|
Old: "bar",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "User",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Map diff",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Meta: map[string]string{
|
|
|
|
"foo": "foo",
|
|
|
|
"bar": "bar",
|
|
|
|
},
|
|
|
|
Env: map[string]string{
|
|
|
|
"foo": "foo",
|
|
|
|
"bar": "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Meta: map[string]string{
|
|
|
|
"bar": "bar",
|
|
|
|
"baz": "baz",
|
|
|
|
},
|
|
|
|
Env: map[string]string{
|
|
|
|
"bar": "bar",
|
|
|
|
"baz": "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Env[baz]",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Env[foo]",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Meta[baz]",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Meta[foo]",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Constraints edited",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Constraints: []*Constraint{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "bar",
|
|
|
|
RTarget: "bar",
|
|
|
|
Operand: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Constraints: []*Constraint{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "baz",
|
|
|
|
RTarget: "baz",
|
|
|
|
Operand: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Constraint",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Constraint",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-07-18 19:23:29 +00:00
|
|
|
{
|
|
|
|
Name: "Affinities edited",
|
|
|
|
Old: &Task{
|
|
|
|
Affinities: []*Affinity{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
Weight: 20,
|
|
|
|
str: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "bar",
|
|
|
|
RTarget: "bar",
|
|
|
|
Operand: "bar",
|
|
|
|
Weight: 20,
|
|
|
|
str: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Affinities: []*Affinity{
|
|
|
|
{
|
|
|
|
LTarget: "foo",
|
|
|
|
RTarget: "foo",
|
|
|
|
Operand: "foo",
|
|
|
|
Weight: 20,
|
|
|
|
str: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
LTarget: "baz",
|
|
|
|
RTarget: "baz",
|
|
|
|
Operand: "baz",
|
|
|
|
Weight: 20,
|
|
|
|
str: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Affinity",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Weight",
|
|
|
|
Old: "",
|
|
|
|
New: "20",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Affinity",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "LTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Operand",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "RTarget",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Weight",
|
|
|
|
Old: "20",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "LogConfig added",
|
|
|
|
Old: &Task{},
|
2016-05-11 05:23:34 +00:00
|
|
|
New: &Task{
|
|
|
|
LogConfig: &LogConfig{
|
|
|
|
MaxFiles: 1,
|
|
|
|
MaxFileSizeMB: 10,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "LogConfig",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MaxFileSizeMB",
|
|
|
|
Old: "",
|
|
|
|
New: "10",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MaxFiles",
|
|
|
|
Old: "",
|
|
|
|
New: "1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "LogConfig deleted",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
LogConfig: &LogConfig{
|
|
|
|
MaxFiles: 1,
|
|
|
|
MaxFileSizeMB: 10,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "LogConfig",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "MaxFileSizeMB",
|
|
|
|
Old: "10",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "MaxFiles",
|
|
|
|
Old: "1",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "LogConfig edited",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
LogConfig: &LogConfig{
|
|
|
|
MaxFiles: 1,
|
|
|
|
MaxFileSizeMB: 10,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
LogConfig: &LogConfig{
|
|
|
|
MaxFiles: 2,
|
|
|
|
MaxFileSizeMB: 20,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "LogConfig",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MaxFileSizeMB",
|
|
|
|
Old: "10",
|
|
|
|
New: "20",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MaxFiles",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "LogConfig edited with context",
|
2016-05-11 18:10:09 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
|
|
|
LogConfig: &LogConfig{
|
|
|
|
MaxFiles: 1,
|
|
|
|
MaxFileSizeMB: 10,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
LogConfig: &LogConfig{
|
|
|
|
MaxFiles: 1,
|
|
|
|
MaxFileSizeMB: 20,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "LogConfig",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MaxFileSizeMB",
|
|
|
|
Old: "10",
|
|
|
|
New: "20",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "MaxFiles",
|
|
|
|
Old: "1",
|
|
|
|
New: "1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Artifacts edited",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Artifacts: []*TaskArtifact{
|
|
|
|
{
|
|
|
|
GetterSource: "foo",
|
|
|
|
GetterOptions: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
RelativeDest: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
GetterSource: "bar",
|
|
|
|
GetterOptions: map[string]string{
|
|
|
|
"bar": "baz",
|
|
|
|
},
|
2020-11-12 16:25:57 +00:00
|
|
|
GetterHeaders: map[string]string{
|
|
|
|
"User": "user1",
|
|
|
|
},
|
2017-07-06 03:44:49 +00:00
|
|
|
GetterMode: "dir",
|
2016-05-11 05:23:34 +00:00
|
|
|
RelativeDest: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Artifacts: []*TaskArtifact{
|
|
|
|
{
|
|
|
|
GetterSource: "foo",
|
|
|
|
GetterOptions: map[string]string{
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
|
|
|
RelativeDest: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
GetterSource: "bam",
|
|
|
|
GetterOptions: map[string]string{
|
|
|
|
"bam": "baz",
|
|
|
|
},
|
2020-11-12 16:25:57 +00:00
|
|
|
GetterHeaders: map[string]string{
|
|
|
|
"User": "user2",
|
|
|
|
"User-Agent": "nomad",
|
|
|
|
},
|
2017-07-06 03:44:49 +00:00
|
|
|
GetterMode: "file",
|
2016-05-11 05:23:34 +00:00
|
|
|
RelativeDest: "bam",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Artifact",
|
|
|
|
Fields: []*FieldDiff{
|
2020-11-12 16:25:57 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "GetterHeaders[User-Agent]",
|
|
|
|
Old: "",
|
|
|
|
New: "nomad",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "GetterHeaders[User]",
|
|
|
|
Old: "",
|
|
|
|
New: "user2",
|
|
|
|
},
|
2017-07-06 03:44:49 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "GetterMode",
|
|
|
|
Old: "",
|
|
|
|
New: "file",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "GetterOptions[bam]",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "GetterSource",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "RelativeDest",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Artifact",
|
|
|
|
Fields: []*FieldDiff{
|
2020-11-12 16:25:57 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "GetterHeaders[User]",
|
|
|
|
Old: "user1",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-07-06 03:44:49 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "GetterMode",
|
|
|
|
Old: "dir",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "GetterOptions[bar]",
|
|
|
|
Old: "baz",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "GetterSource",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "RelativeDest",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Resources edited (no networks)",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 100,
|
|
|
|
DiskMB: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 200,
|
|
|
|
MemoryMB: 200,
|
|
|
|
DiskMB: 200,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Resources",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "CPU",
|
|
|
|
Old: "100",
|
|
|
|
New: "200",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "DiskMB",
|
|
|
|
Old: "100",
|
|
|
|
New: "200",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MemoryMB",
|
|
|
|
Old: "100",
|
|
|
|
New: "200",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Resources edited (no networks) with context",
|
2016-05-11 18:10:09 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 100,
|
|
|
|
DiskMB: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 200,
|
|
|
|
MemoryMB: 100,
|
|
|
|
DiskMB: 200,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Resources",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "CPU",
|
|
|
|
Old: "100",
|
|
|
|
New: "200",
|
|
|
|
},
|
2021-03-19 02:49:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Cores",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "DiskMB",
|
|
|
|
Old: "100",
|
|
|
|
New: "200",
|
|
|
|
},
|
2018-12-12 22:32:22 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "IOPS",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "MemoryMB",
|
|
|
|
Old: "100",
|
|
|
|
New: "100",
|
|
|
|
},
|
2021-03-26 20:01:27 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "MemoryMaxMB",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Resources edited memory_max",
|
|
|
|
Old: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 100,
|
|
|
|
MemoryMaxMB: 200,
|
|
|
|
DiskMB: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 100,
|
|
|
|
MemoryMaxMB: 300,
|
|
|
|
DiskMB: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Resources",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MemoryMaxMB",
|
|
|
|
Old: "200",
|
|
|
|
New: "300",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Resources edited memory_max with context",
|
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 100,
|
|
|
|
MemoryMaxMB: 200,
|
|
|
|
DiskMB: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 100,
|
|
|
|
MemoryMaxMB: 300,
|
|
|
|
DiskMB: 100,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Resources",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "CPU",
|
|
|
|
Old: "100",
|
|
|
|
New: "100",
|
|
|
|
},
|
2021-03-31 12:52:20 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Cores",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
2021-03-26 20:01:27 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "DiskMB",
|
|
|
|
Old: "100",
|
|
|
|
New: "100",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "IOPS",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "MemoryMB",
|
|
|
|
Old: "100",
|
|
|
|
New: "100",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "MemoryMaxMB",
|
|
|
|
Old: "200",
|
|
|
|
New: "300",
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Network Resources edited",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
Networks: []*NetworkResource{
|
|
|
|
{
|
|
|
|
Device: "foo",
|
|
|
|
CIDR: "foo",
|
|
|
|
IP: "foo",
|
|
|
|
MBits: 100,
|
|
|
|
ReservedPorts: []Port{
|
|
|
|
{
|
|
|
|
Label: "foo",
|
|
|
|
Value: 80,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DynamicPorts: []Port{
|
|
|
|
{
|
|
|
|
Label: "bar",
|
2019-04-29 19:39:55 +00:00
|
|
|
To: 8080,
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
Networks: []*NetworkResource{
|
|
|
|
{
|
|
|
|
Device: "bar",
|
|
|
|
CIDR: "bar",
|
|
|
|
IP: "bar",
|
|
|
|
MBits: 200,
|
|
|
|
ReservedPorts: []Port{
|
|
|
|
{
|
|
|
|
Label: "foo",
|
|
|
|
Value: 81,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
DynamicPorts: []Port{
|
|
|
|
{
|
|
|
|
Label: "baz",
|
2019-04-29 19:39:55 +00:00
|
|
|
To: 8081,
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Resources",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Network",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "MBits",
|
|
|
|
Old: "",
|
|
|
|
New: "200",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Static Port",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Label",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2019-04-29 19:39:55 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "To",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Value",
|
|
|
|
Old: "",
|
|
|
|
New: "81",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Dynamic Port",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Label",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
2019-04-29 19:39:55 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "To",
|
|
|
|
Old: "",
|
|
|
|
New: "8081",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Network",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "MBits",
|
|
|
|
Old: "100",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Static Port",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Label",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
2019-04-29 19:39:55 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "To",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Value",
|
|
|
|
Old: "80",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Dynamic Port",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Label",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
2019-04-29 19:39:55 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "To",
|
|
|
|
Old: "8080",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-10-08 23:58:19 +00:00
|
|
|
{
|
|
|
|
Name: "Device Resources edited",
|
|
|
|
Old: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
Devices: []*RequestedDevice{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
Devices: []*RequestedDevice{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Count: 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bam",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Resources",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Device",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "2",
|
|
|
|
New: "3",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Device",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Device",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "2",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "baz",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "Device Resources edited with context",
|
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 100,
|
|
|
|
DiskMB: 100,
|
|
|
|
Devices: []*RequestedDevice{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Resources: &Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 100,
|
|
|
|
DiskMB: 100,
|
|
|
|
Devices: []*RequestedDevice{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Count: 3,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bam",
|
|
|
|
Count: 2,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Resources",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "CPU",
|
|
|
|
Old: "100",
|
|
|
|
New: "100",
|
|
|
|
},
|
2021-03-19 02:49:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Cores",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
2018-10-08 23:58:19 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "DiskMB",
|
|
|
|
Old: "100",
|
|
|
|
New: "100",
|
|
|
|
},
|
2018-12-12 22:32:22 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "IOPS",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
2018-10-08 23:58:19 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "MemoryMB",
|
|
|
|
Old: "100",
|
|
|
|
New: "100",
|
|
|
|
},
|
2021-03-26 20:01:27 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "MemoryMaxMB",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
2018-10-08 23:58:19 +00:00
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Device",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "2",
|
|
|
|
New: "3",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "bar",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Device",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Device",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Count",
|
|
|
|
Old: "2",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "baz",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Config same",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 1,
|
|
|
|
"bar": "bar",
|
|
|
|
"bam": []string{"a", "b"},
|
|
|
|
"baz": map[string]int{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2,
|
|
|
|
},
|
|
|
|
"boom": &Port{
|
|
|
|
Label: "boom_port",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 1,
|
|
|
|
"bar": "bar",
|
|
|
|
"bam": []string{"a", "b"},
|
|
|
|
"baz": map[string]int{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2,
|
|
|
|
},
|
|
|
|
"boom": &Port{
|
|
|
|
Label: "boom_port",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Config edited",
|
2016-05-11 05:23:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 1,
|
|
|
|
"bar": "baz",
|
|
|
|
"bam": []string{"a", "b"},
|
|
|
|
"baz": map[string]int{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2,
|
|
|
|
},
|
|
|
|
"boom": &Port{
|
|
|
|
Label: "boom_port",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 2,
|
|
|
|
"bar": "baz",
|
|
|
|
"bam": []string{"a", "c", "d"},
|
|
|
|
"baz": map[string]int{
|
|
|
|
"b": 3,
|
|
|
|
"c": 4,
|
|
|
|
},
|
|
|
|
"boom": &Port{
|
|
|
|
Label: "boom_port2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Config",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "bam[1]",
|
|
|
|
Old: "b",
|
|
|
|
New: "c",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "bam[2]",
|
|
|
|
Old: "",
|
|
|
|
New: "d",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "baz[a]",
|
|
|
|
Old: "1",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "baz[b]",
|
|
|
|
Old: "2",
|
|
|
|
New: "3",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "baz[c]",
|
|
|
|
Old: "",
|
|
|
|
New: "4",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "boom.Label",
|
|
|
|
Old: "boom_port",
|
|
|
|
New: "boom_port2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "foo",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Config edited with context",
|
2016-05-11 18:10:09 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 1,
|
|
|
|
"bar": "baz",
|
|
|
|
"bam": []string{"a", "b"},
|
|
|
|
"baz": map[string]int{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2,
|
|
|
|
},
|
|
|
|
"boom": &Port{
|
|
|
|
Label: "boom_port",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Config: map[string]interface{}{
|
|
|
|
"foo": 2,
|
|
|
|
"bar": "baz",
|
|
|
|
"bam": []string{"a", "c", "d"},
|
|
|
|
"baz": map[string]int{
|
|
|
|
"a": 1,
|
|
|
|
"b": 2,
|
|
|
|
},
|
|
|
|
"boom": &Port{
|
|
|
|
Label: "boom_port",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Config",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "bam[0]",
|
|
|
|
Old: "a",
|
|
|
|
New: "a",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "bam[1]",
|
|
|
|
Old: "b",
|
|
|
|
New: "c",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "bam[2]",
|
|
|
|
Old: "",
|
|
|
|
New: "d",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "bar",
|
|
|
|
Old: "baz",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "baz[a]",
|
|
|
|
Old: "1",
|
|
|
|
New: "1",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "baz[b]",
|
|
|
|
Old: "2",
|
|
|
|
New: "2",
|
|
|
|
},
|
2020-06-19 17:53:31 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "boom.HostNetwork",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 18:10:09 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "boom.Label",
|
|
|
|
Old: "boom_port",
|
|
|
|
New: "boom_port",
|
|
|
|
},
|
|
|
|
{
|
2019-04-29 19:39:55 +00:00
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "boom.To",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
|
|
|
{
|
2016-05-11 18:10:09 +00:00
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "boom.Value",
|
|
|
|
Old: "0",
|
|
|
|
New: "0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "foo",
|
|
|
|
Old: "1",
|
|
|
|
New: "2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Services edited (no checks)",
|
2016-05-11 22:25:59 +00:00
|
|
|
Old: &Task{
|
2016-06-12 23:36:49 +00:00
|
|
|
Services: []*Service{
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
PortLabel: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
PortLabel: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
PortLabel: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
2016-06-12 23:36:49 +00:00
|
|
|
Services: []*Service{
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
PortLabel: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
PortLabel: "baz2",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bam",
|
|
|
|
PortLabel: "bam",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "PortLabel",
|
|
|
|
Old: "baz",
|
|
|
|
New: "baz2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "EnableTagOverride",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "PortLabel",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "EnableTagOverride",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "PortLabel",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Services edited (no checks) with context",
|
2016-05-11 22:25:59 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
2016-06-12 23:36:49 +00:00
|
|
|
Services: []*Service{
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
PortLabel: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
2016-06-12 23:36:49 +00:00
|
|
|
Services: []*Service{
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
2017-06-20 19:26:52 +00:00
|
|
|
Name: "foo",
|
|
|
|
PortLabel: "bar",
|
|
|
|
AddressMode: "driver",
|
2020-06-22 17:55:59 +00:00
|
|
|
TaskName: "task1",
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
2017-06-20 19:26:52 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "AddressMode",
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
Old: "",
|
2017-06-20 19:26:52 +00:00
|
|
|
New: "driver",
|
|
|
|
},
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "EnableTagOverride",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2021-03-16 18:22:21 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Namespace",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2021-01-22 19:45:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "OnUpdate",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "PortLabel",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
2020-06-22 17:55:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "TaskName",
|
|
|
|
Old: "",
|
|
|
|
New: "task1",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
{
|
|
|
|
Name: "Service EnableTagOverride edited no context",
|
|
|
|
Contextual: false,
|
|
|
|
Old: &Task{
|
|
|
|
Services: []*Service{{
|
|
|
|
EnableTagOverride: false,
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Services: []*Service{{
|
|
|
|
EnableTagOverride: true,
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "EnableTagOverride",
|
|
|
|
Old: "false",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2018-04-19 22:12:23 +00:00
|
|
|
{
|
|
|
|
Name: "Services tags edited (no checks) with context",
|
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
|
|
|
Tags: []string{"foo", "bar"},
|
|
|
|
CanaryTags: []string{"foo", "bar"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
|
|
|
Tags: []string{"bar", "bam"},
|
|
|
|
CanaryTags: []string{"bar", "bam"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "CanaryTags",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "CanaryTags",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "CanaryTags",
|
|
|
|
Old: "bar",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "CanaryTags",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Tags",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Tags",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Tags",
|
|
|
|
Old: "bar",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Tags",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "AddressMode",
|
|
|
|
},
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "EnableTagOverride",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
2018-04-19 22:12:23 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Name",
|
|
|
|
},
|
2021-03-16 18:22:21 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Namespace",
|
|
|
|
},
|
2021-01-22 19:45:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "OnUpdate",
|
|
|
|
},
|
2018-04-19 22:12:23 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "PortLabel",
|
|
|
|
},
|
2020-06-22 17:55:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "TaskName",
|
|
|
|
},
|
2018-04-19 22:12:23 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
Name: "Service with Connect",
|
|
|
|
Old: &Task{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Connect: &ConsulConnect{
|
|
|
|
SidecarService: &ConsulSidecarService{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ConsulConnect",
|
2020-06-22 17:55:59 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Native",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
},
|
2020-05-13 20:15:55 +00:00
|
|
|
Objects: []*ObjectDiff{
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2020-05-13 20:15:55 +00:00
|
|
|
Name: "SidecarService",
|
2021-05-07 16:10:26 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "DisableDefaultTCPCheck",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
},
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
2020-05-13 20:15:55 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
Name: "Service with Connect Native",
|
|
|
|
Old: &Task{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
2020-06-22 17:55:59 +00:00
|
|
|
Name: "foo",
|
|
|
|
TaskName: "task1",
|
2020-05-13 20:15:55 +00:00
|
|
|
Connect: &ConsulConnect{
|
2020-06-22 17:55:59 +00:00
|
|
|
Native: true,
|
2020-05-13 20:15:55 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
2020-06-22 17:55:59 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "TaskName",
|
|
|
|
Old: "",
|
|
|
|
New: "task1",
|
|
|
|
},
|
|
|
|
},
|
2020-05-13 20:15:55 +00:00
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ConsulConnect",
|
|
|
|
Fields: []*FieldDiff{
|
2019-08-19 19:43:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2020-05-13 20:15:55 +00:00
|
|
|
Name: "Native",
|
|
|
|
Old: "",
|
2020-06-22 17:55:59 +00:00
|
|
|
New: "true",
|
2019-08-19 19:43:06 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Service Checks edited",
|
2016-05-11 22:25:59 +00:00
|
|
|
Old: &Task{
|
2016-06-12 23:36:49 +00:00
|
|
|
Services: []*Service{
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Checks: []*ServiceCheck{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
2017-09-29 00:08:43 +00:00
|
|
|
Header: map[string][]string{
|
|
|
|
"Foo": {"bar"},
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
SuccessBeforePassing: 1,
|
|
|
|
FailuresBeforeCritical: 1,
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
{
|
2020-08-08 01:22:06 +00:00
|
|
|
Name: "bar",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
SuccessBeforePassing: 7,
|
|
|
|
FailuresBeforeCritical: 7,
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
2016-06-12 23:36:49 +00:00
|
|
|
Services: []*Service{
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Checks: []*ServiceCheck{
|
|
|
|
{
|
2020-08-08 01:22:06 +00:00
|
|
|
Name: "bar",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
SuccessBeforePassing: 7,
|
|
|
|
FailuresBeforeCritical: 7,
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
Type: "tcp",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
2017-09-29 00:08:43 +00:00
|
|
|
Header: map[string][]string{
|
|
|
|
"Eggs": {"spam"},
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
{
|
2020-08-08 01:22:06 +00:00
|
|
|
Name: "bam",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
SuccessBeforePassing: 2,
|
|
|
|
FailuresBeforeCritical: 2,
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Check",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "http",
|
|
|
|
New: "tcp",
|
|
|
|
},
|
|
|
|
},
|
2017-09-29 00:08:43 +00:00
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Header",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Eggs[0]",
|
|
|
|
Old: "",
|
|
|
|
New: "spam",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Check",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Command",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
connect: enable automatic expose paths for individual group service checks
Part of #6120
Building on the support for enabling connect proxy paths in #7323, this change
adds the ability to configure the 'service.check.expose' flag on group-level
service check definitions for services that are connect-enabled. This is a slight
deviation from the "magic" that Consul provides. With Consul, the 'expose' flag
exists on the connect.proxy stanza, which will then auto-generate expose paths
for every HTTP and gRPC service check associated with that connect-enabled
service.
A first attempt at providing similar magic for Nomad's Consul Connect integration
followed that pattern exactly, as seen in #7396. However, on reviewing the PR
we realized having the `expose` flag on the proxy stanza inseperably ties together
the automatic path generation with every HTTP/gRPC defined on the service. This
makes sense in Consul's context, because a service definition is reasonably
associated with a single "task". With Nomad's group level service definitions
however, there is a reasonable expectation that a service definition is more
abstractly representative of multiple services within the task group. In this
case, one would want to define checks of that service which concretely make HTTP
or gRPC requests to different underlying tasks. Such a model is not possible
with the course `proxy.expose` flag.
Instead, we now have the flag made available within the check definitions themselves.
By making the expose feature resolute to each check, it is possible to have
some HTTP/gRPC checks which make use of the envoy exposed paths, as well as
some HTTP/gRPC checks which make use of some orthongonal port-mapping to do
checks on some other task (or even some other bound port of the same task)
within the task group.
Given this example,
group "server-group" {
network {
mode = "bridge"
port "forchecks" {
to = -1
}
}
service {
name = "myserver"
port = 2000
connect {
sidecar_service {
}
}
check {
name = "mycheck-myserver"
type = "http"
port = "forchecks"
interval = "3s"
timeout = "2s"
method = "GET"
path = "/classic/responder/health"
expose = true
}
}
}
Nomad will automatically inject (via job endpoint mutator) the
extrapolated expose path configuration, i.e.
expose {
path {
path = "/classic/responder/health"
protocol = "http"
local_path_port = 2000
listener_port = "forchecks"
}
}
Documentation is coming in #7440 (needs updating, doing next)
Modifications to the `countdash` examples in https://github.com/hashicorp/demo-consul-101/pull/6
which will make the examples in the documentation actually runnable.
Will add some e2e tests based on the above when it becomes available.
2020-03-25 01:49:55 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Expose",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "FailuresBeforeCritical",
|
|
|
|
Old: "",
|
|
|
|
New: "2",
|
|
|
|
},
|
2018-05-03 23:54:42 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "GRPCUseTLS",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "",
|
|
|
|
New: "bam",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Path",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Protocol",
|
|
|
|
Old: "",
|
|
|
|
New: "http",
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "SuccessBeforePassing",
|
|
|
|
Old: "",
|
|
|
|
New: "2",
|
|
|
|
},
|
2017-04-19 18:37:57 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "TLSSkipVerify",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Timeout",
|
|
|
|
Old: "",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "",
|
|
|
|
New: "http",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Check",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Command",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
connect: enable automatic expose paths for individual group service checks
Part of #6120
Building on the support for enabling connect proxy paths in #7323, this change
adds the ability to configure the 'service.check.expose' flag on group-level
service check definitions for services that are connect-enabled. This is a slight
deviation from the "magic" that Consul provides. With Consul, the 'expose' flag
exists on the connect.proxy stanza, which will then auto-generate expose paths
for every HTTP and gRPC service check associated with that connect-enabled
service.
A first attempt at providing similar magic for Nomad's Consul Connect integration
followed that pattern exactly, as seen in #7396. However, on reviewing the PR
we realized having the `expose` flag on the proxy stanza inseperably ties together
the automatic path generation with every HTTP/gRPC defined on the service. This
makes sense in Consul's context, because a service definition is reasonably
associated with a single "task". With Nomad's group level service definitions
however, there is a reasonable expectation that a service definition is more
abstractly representative of multiple services within the task group. In this
case, one would want to define checks of that service which concretely make HTTP
or gRPC requests to different underlying tasks. Such a model is not possible
with the course `proxy.expose` flag.
Instead, we now have the flag made available within the check definitions themselves.
By making the expose feature resolute to each check, it is possible to have
some HTTP/gRPC checks which make use of the envoy exposed paths, as well as
some HTTP/gRPC checks which make use of some orthongonal port-mapping to do
checks on some other task (or even some other bound port of the same task)
within the task group.
Given this example,
group "server-group" {
network {
mode = "bridge"
port "forchecks" {
to = -1
}
}
service {
name = "myserver"
port = 2000
connect {
sidecar_service {
}
}
check {
name = "mycheck-myserver"
type = "http"
port = "forchecks"
interval = "3s"
timeout = "2s"
method = "GET"
path = "/classic/responder/health"
expose = true
}
}
}
Nomad will automatically inject (via job endpoint mutator) the
extrapolated expose path configuration, i.e.
expose {
path {
path = "/classic/responder/health"
protocol = "http"
local_path_port = 2000
listener_port = "forchecks"
}
}
Documentation is coming in #7440 (needs updating, doing next)
Modifications to the `countdash` examples in https://github.com/hashicorp/demo-consul-101/pull/6
which will make the examples in the documentation actually runnable.
Will add some e2e tests based on the above when it becomes available.
2020-03-25 01:49:55 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Expose",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "FailuresBeforeCritical",
|
|
|
|
Old: "1",
|
|
|
|
New: "",
|
|
|
|
},
|
2018-05-03 23:54:42 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "GRPCUseTLS",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Path",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Protocol",
|
|
|
|
Old: "http",
|
|
|
|
New: "",
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "SuccessBeforePassing",
|
|
|
|
Old: "1",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-04-19 18:37:57 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "TLSSkipVerify",
|
|
|
|
Old: "false",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Timeout",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "http",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
2017-09-29 00:08:43 +00:00
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Header",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Foo[0]",
|
|
|
|
Old: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Service Checks edited with context",
|
2016-05-11 22:25:59 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
2016-06-12 23:36:49 +00:00
|
|
|
Services: []*Service{
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Checks: []*ServiceCheck{
|
|
|
|
{
|
2016-08-17 18:07:11 +00:00
|
|
|
Name: "foo",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
InitialStatus: "critical",
|
2017-08-16 21:41:37 +00:00
|
|
|
Header: map[string][]string{
|
|
|
|
"Foo": {"bar"},
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
SuccessBeforePassing: 4,
|
|
|
|
FailuresBeforeCritical: 5,
|
2021-01-22 19:45:26 +00:00
|
|
|
OnUpdate: "require_healthy",
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
2016-06-12 23:36:49 +00:00
|
|
|
Services: []*Service{
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Checks: []*ServiceCheck{
|
|
|
|
{
|
2016-08-17 18:07:11 +00:00
|
|
|
Name: "foo",
|
|
|
|
Type: "tcp",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
InitialStatus: "passing",
|
2017-08-16 21:41:37 +00:00
|
|
|
Method: "POST",
|
|
|
|
Header: map[string][]string{
|
|
|
|
"Foo": {"bar", "baz"},
|
|
|
|
"Eggs": {"spam"},
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
SuccessBeforePassing: 4,
|
2021-01-22 19:45:26 +00:00
|
|
|
OnUpdate: "ignore_warnings",
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Fields: []*FieldDiff{
|
2017-06-20 19:26:52 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "AddressMode",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
client: enable configuring enable_tag_override for services
Consul provides a feature of Service Definitions where the tags
associated with a service can be modified through the Catalog API,
overriding the value(s) configured in the agent's service configuration.
To enable this feature, the flag enable_tag_override must be configured
in the service definition.
Previously, Nomad did not allow configuring this flag, and thus the default
value of false was used. Now, it is configurable.
Because Nomad itself acts as a state machine around the the service definitions
of the tasks it manages, it's worth describing what happens when this feature
is enabled and why.
Consider the basic case where there is no Nomad, and your service is provided
to consul as a boring JSON file. The ultimate source of truth for the definition
of that service is the file, and is stored in the agent. Later, Consul performs
"anti-entropy" which synchronizes the Catalog (stored only the leaders). Then
with enable_tag_override=true, the tags field is available for "external"
modification through the Catalog API (rather than directly configuring the
service definition file, or using the Agent API). The important observation
is that if the service definition ever changes (i.e. the file is changed &
config reloaded OR the Agent API is used to modify the service), those
"external" tag values are thrown away, and the new service definition is
once again the source of truth.
In the Nomad case, Nomad itself is the source of truth over the Agent in
the same way the JSON file was the source of truth in the example above.
That means any time Nomad sets a new service definition, any externally
configured tags are going to be replaced. When does this happen? Only on
major lifecycle events, for example when a task is modified because of an
updated job spec from the 'nomad job run <existing>' command. Otherwise,
Nomad's periodic re-sync's with Consul will now no longer try to restore
the externally modified tag values (as long as enable_tag_override=true).
Fixes #2057
2020-02-07 21:22:19 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "EnableTagOverride",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2021-03-16 18:22:21 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Namespace",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2021-01-22 19:45:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "OnUpdate",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "PortLabel",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2020-06-22 17:55:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "TaskName",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Check",
|
|
|
|
Fields: []*FieldDiff{
|
2017-12-08 06:09:37 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "AddressMode",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2021-03-25 01:51:13 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Body",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Command",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
connect: enable automatic expose paths for individual group service checks
Part of #6120
Building on the support for enabling connect proxy paths in #7323, this change
adds the ability to configure the 'service.check.expose' flag on group-level
service check definitions for services that are connect-enabled. This is a slight
deviation from the "magic" that Consul provides. With Consul, the 'expose' flag
exists on the connect.proxy stanza, which will then auto-generate expose paths
for every HTTP and gRPC service check associated with that connect-enabled
service.
A first attempt at providing similar magic for Nomad's Consul Connect integration
followed that pattern exactly, as seen in #7396. However, on reviewing the PR
we realized having the `expose` flag on the proxy stanza inseperably ties together
the automatic path generation with every HTTP/gRPC defined on the service. This
makes sense in Consul's context, because a service definition is reasonably
associated with a single "task". With Nomad's group level service definitions
however, there is a reasonable expectation that a service definition is more
abstractly representative of multiple services within the task group. In this
case, one would want to define checks of that service which concretely make HTTP
or gRPC requests to different underlying tasks. Such a model is not possible
with the course `proxy.expose` flag.
Instead, we now have the flag made available within the check definitions themselves.
By making the expose feature resolute to each check, it is possible to have
some HTTP/gRPC checks which make use of the envoy exposed paths, as well as
some HTTP/gRPC checks which make use of some orthongonal port-mapping to do
checks on some other task (or even some other bound port of the same task)
within the task group.
Given this example,
group "server-group" {
network {
mode = "bridge"
port "forchecks" {
to = -1
}
}
service {
name = "myserver"
port = 2000
connect {
sidecar_service {
}
}
check {
name = "mycheck-myserver"
type = "http"
port = "forchecks"
interval = "3s"
timeout = "2s"
method = "GET"
path = "/classic/responder/health"
expose = true
}
}
}
Nomad will automatically inject (via job endpoint mutator) the
extrapolated expose path configuration, i.e.
expose {
path {
path = "/classic/responder/health"
protocol = "http"
local_path_port = 2000
listener_port = "forchecks"
}
}
Documentation is coming in #7440 (needs updating, doing next)
Modifications to the `countdash` examples in https://github.com/hashicorp/demo-consul-101/pull/6
which will make the examples in the documentation actually runnable.
Will add some e2e tests based on the above when it becomes available.
2020-03-25 01:49:55 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Expose",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "FailuresBeforeCritical",
|
|
|
|
Old: "5",
|
|
|
|
New: "0",
|
|
|
|
},
|
2018-05-03 23:54:42 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "GRPCService",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "GRPCUseTLS",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
2016-08-17 18:07:11 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "InitialStatus",
|
|
|
|
Old: "critical",
|
|
|
|
New: "passing",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Interval",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
2017-08-16 21:41:37 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Method",
|
|
|
|
Old: "",
|
|
|
|
New: "POST",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Name",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2021-01-22 19:45:26 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "OnUpdate",
|
|
|
|
Old: "require_healthy",
|
|
|
|
New: "ignore_warnings",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Path",
|
|
|
|
Old: "foo",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2016-07-08 23:31:54 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "PortLabel",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Protocol",
|
|
|
|
Old: "http",
|
|
|
|
New: "http",
|
|
|
|
},
|
2020-08-08 01:22:06 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "SuccessBeforePassing",
|
|
|
|
Old: "4",
|
|
|
|
New: "4",
|
|
|
|
},
|
2017-04-19 18:37:57 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "TLSSkipVerify",
|
|
|
|
Old: "false",
|
|
|
|
New: "false",
|
|
|
|
},
|
2019-08-19 13:17:38 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "TaskName",
|
|
|
|
Old: "",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Timeout",
|
|
|
|
Old: "1000000000",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Type",
|
|
|
|
Old: "http",
|
|
|
|
New: "tcp",
|
|
|
|
},
|
|
|
|
},
|
2017-08-16 21:41:37 +00:00
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Header",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Eggs[0]",
|
|
|
|
Old: "",
|
|
|
|
New: "spam",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Foo[0]",
|
|
|
|
Old: "bar",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Foo[1]",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 22:25:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-09-28 21:06:18 +00:00
|
|
|
{
|
|
|
|
Name: "CheckRestart edited",
|
|
|
|
Old: &Task{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Checks: []*ServiceCheck{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
CheckRestart: &CheckRestart{
|
|
|
|
Limit: 2,
|
|
|
|
Grace: 2 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
CheckRestart: &CheckRestart{
|
|
|
|
Limit: 3,
|
|
|
|
Grace: 3 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Services: []*Service{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Checks: []*ServiceCheck{
|
|
|
|
{
|
|
|
|
Name: "foo",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
CheckRestart: &CheckRestart{
|
|
|
|
Limit: 1,
|
|
|
|
Grace: 1 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "bar",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "baz",
|
|
|
|
Type: "http",
|
|
|
|
Command: "foo",
|
|
|
|
Args: []string{"foo"},
|
|
|
|
Path: "foo",
|
|
|
|
Protocol: "http",
|
|
|
|
Interval: 1 * time.Second,
|
|
|
|
Timeout: 1 * time.Second,
|
|
|
|
CheckRestart: &CheckRestart{
|
|
|
|
Limit: 4,
|
|
|
|
Grace: 4 * time.Second,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Service",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Check",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "CheckRestart",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Grace",
|
|
|
|
Old: "3000000000",
|
|
|
|
New: "4000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Limit",
|
|
|
|
Old: "3",
|
|
|
|
New: "4",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Check",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "CheckRestart",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Grace",
|
|
|
|
New: "1000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "IgnoreWarnings",
|
|
|
|
New: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Limit",
|
|
|
|
New: "1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Check",
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "CheckRestart",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Grace",
|
|
|
|
Old: "2000000000",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "IgnoreWarnings",
|
|
|
|
Old: "false",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Limit",
|
|
|
|
Old: "2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-09-21 20:49:34 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Vault added",
|
|
|
|
Old: &Task{},
|
2016-09-21 20:49:34 +00:00
|
|
|
New: &Task{
|
|
|
|
Vault: &Vault{
|
2016-10-18 21:54:14 +00:00
|
|
|
Policies: []string{"foo", "bar"},
|
|
|
|
Env: true,
|
|
|
|
ChangeMode: "signal",
|
|
|
|
ChangeSignal: "SIGUSR1",
|
2016-09-21 20:49:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Vault",
|
|
|
|
Fields: []*FieldDiff{
|
2016-10-18 21:54:14 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ChangeMode",
|
|
|
|
Old: "",
|
|
|
|
New: "signal",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ChangeSignal",
|
|
|
|
Old: "",
|
|
|
|
New: "SIGUSR1",
|
|
|
|
},
|
2016-09-21 20:49:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Env",
|
|
|
|
Old: "",
|
|
|
|
New: "true",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Policies",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Vault deleted",
|
2016-09-21 20:49:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Vault: &Vault{
|
2016-10-18 21:54:14 +00:00
|
|
|
Policies: []string{"foo", "bar"},
|
|
|
|
Env: true,
|
|
|
|
ChangeMode: "signal",
|
|
|
|
ChangeSignal: "SIGUSR1",
|
2016-09-21 20:49:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Vault",
|
|
|
|
Fields: []*FieldDiff{
|
2016-10-18 21:54:14 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ChangeMode",
|
|
|
|
Old: "signal",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ChangeSignal",
|
|
|
|
Old: "SIGUSR1",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-09-21 20:49:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Env",
|
|
|
|
Old: "true",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Policies",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "bar",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Vault edited",
|
2016-09-21 20:49:34 +00:00
|
|
|
Old: &Task{
|
|
|
|
Vault: &Vault{
|
2020-07-17 14:41:45 +00:00
|
|
|
Namespace: "ns1",
|
2016-10-18 21:54:14 +00:00
|
|
|
Policies: []string{"foo", "bar"},
|
|
|
|
Env: true,
|
|
|
|
ChangeMode: "signal",
|
|
|
|
ChangeSignal: "SIGUSR1",
|
2016-09-21 20:49:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Vault: &Vault{
|
2020-07-17 14:41:45 +00:00
|
|
|
Namespace: "ns2",
|
2016-10-18 21:54:14 +00:00
|
|
|
Policies: []string{"bar", "baz"},
|
|
|
|
Env: false,
|
|
|
|
ChangeMode: "restart",
|
|
|
|
ChangeSignal: "foo",
|
2016-09-21 20:49:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Vault",
|
|
|
|
Fields: []*FieldDiff{
|
2016-10-18 21:54:14 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ChangeMode",
|
|
|
|
Old: "signal",
|
|
|
|
New: "restart",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "ChangeSignal",
|
|
|
|
Old: "SIGUSR1",
|
|
|
|
New: "foo",
|
|
|
|
},
|
2016-09-21 20:49:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Env",
|
|
|
|
Old: "true",
|
|
|
|
New: "false",
|
|
|
|
},
|
2020-07-17 14:41:45 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Namespace",
|
|
|
|
Old: "ns1",
|
|
|
|
New: "ns2",
|
|
|
|
},
|
2016-09-21 20:49:34 +00:00
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Policies",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Vault edited with context",
|
2016-09-21 20:49:34 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
|
|
|
Vault: &Vault{
|
2020-07-17 14:41:45 +00:00
|
|
|
Namespace: "ns1",
|
2016-10-18 21:54:14 +00:00
|
|
|
Policies: []string{"foo", "bar"},
|
|
|
|
Env: true,
|
|
|
|
ChangeMode: "signal",
|
|
|
|
ChangeSignal: "SIGUSR1",
|
2016-09-21 20:49:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Vault: &Vault{
|
2020-07-17 14:41:45 +00:00
|
|
|
Namespace: "ns1",
|
2016-10-18 21:54:14 +00:00
|
|
|
Policies: []string{"bar", "baz"},
|
|
|
|
Env: true,
|
|
|
|
ChangeMode: "signal",
|
|
|
|
ChangeSignal: "SIGUSR1",
|
2016-09-21 20:49:34 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Vault",
|
|
|
|
Fields: []*FieldDiff{
|
2016-10-18 21:54:14 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "ChangeMode",
|
|
|
|
Old: "signal",
|
|
|
|
New: "signal",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "ChangeSignal",
|
|
|
|
Old: "SIGUSR1",
|
|
|
|
New: "SIGUSR1",
|
|
|
|
},
|
2016-09-21 20:49:34 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Env",
|
|
|
|
Old: "true",
|
|
|
|
New: "true",
|
|
|
|
},
|
2020-07-17 14:41:45 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Namespace",
|
|
|
|
Old: "ns1",
|
|
|
|
New: "ns1",
|
|
|
|
},
|
2016-09-21 20:49:34 +00:00
|
|
|
},
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "Policies",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "",
|
|
|
|
New: "baz",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeNone,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "bar",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Policies",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-09-23 23:14:20 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Template edited",
|
2016-09-23 23:14:20 +00:00
|
|
|
Old: &Task{
|
|
|
|
Templates: []*Template{
|
|
|
|
{
|
2016-10-03 19:42:18 +00:00
|
|
|
SourcePath: "foo",
|
|
|
|
DestPath: "bar",
|
|
|
|
EmbeddedTmpl: "baz",
|
|
|
|
ChangeMode: "bam",
|
|
|
|
ChangeSignal: "SIGHUP",
|
|
|
|
Splay: 1,
|
2017-02-01 04:00:33 +00:00
|
|
|
Perms: "0644",
|
2016-09-23 23:14:20 +00:00
|
|
|
},
|
|
|
|
{
|
2016-10-03 19:42:18 +00:00
|
|
|
SourcePath: "foo2",
|
|
|
|
DestPath: "bar2",
|
|
|
|
EmbeddedTmpl: "baz2",
|
|
|
|
ChangeMode: "bam2",
|
|
|
|
ChangeSignal: "SIGHUP2",
|
|
|
|
Splay: 2,
|
2017-02-01 04:00:33 +00:00
|
|
|
Perms: "0666",
|
2017-05-27 00:05:14 +00:00
|
|
|
Envvars: true,
|
2016-09-23 23:14:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
|
|
|
Templates: []*Template{
|
|
|
|
{
|
2016-10-03 19:42:18 +00:00
|
|
|
SourcePath: "foo",
|
|
|
|
DestPath: "bar",
|
|
|
|
EmbeddedTmpl: "baz",
|
|
|
|
ChangeMode: "bam",
|
|
|
|
ChangeSignal: "SIGHUP",
|
|
|
|
Splay: 1,
|
2017-02-01 04:00:33 +00:00
|
|
|
Perms: "0644",
|
2016-10-03 19:42:18 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
SourcePath: "foo3",
|
|
|
|
DestPath: "bar3",
|
|
|
|
EmbeddedTmpl: "baz3",
|
|
|
|
ChangeMode: "bam3",
|
|
|
|
ChangeSignal: "SIGHUP3",
|
|
|
|
Splay: 3,
|
2017-02-01 04:00:33 +00:00
|
|
|
Perms: "0776",
|
2016-09-23 23:14:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Template",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "ChangeMode",
|
|
|
|
Old: "",
|
|
|
|
New: "bam3",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2016-10-06 22:17:34 +00:00
|
|
|
Name: "ChangeSignal",
|
2016-09-23 23:14:20 +00:00
|
|
|
Old: "",
|
2016-10-06 22:17:34 +00:00
|
|
|
New: "SIGHUP3",
|
2016-09-23 23:14:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2016-10-06 22:17:34 +00:00
|
|
|
Name: "DestPath",
|
2016-09-23 23:14:20 +00:00
|
|
|
Old: "",
|
2016-10-06 22:17:34 +00:00
|
|
|
New: "bar3",
|
2016-09-23 23:14:20 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2016-10-06 22:17:34 +00:00
|
|
|
Name: "EmbeddedTmpl",
|
2016-09-23 23:14:20 +00:00
|
|
|
Old: "",
|
2016-10-06 22:17:34 +00:00
|
|
|
New: "baz3",
|
2016-09-23 23:14:20 +00:00
|
|
|
},
|
2017-05-27 00:05:14 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Envvars",
|
|
|
|
Old: "",
|
|
|
|
New: "false",
|
|
|
|
},
|
2017-02-01 04:00:33 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Perms",
|
|
|
|
Old: "",
|
|
|
|
New: "0776",
|
|
|
|
},
|
2016-09-23 23:14:20 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "SourcePath",
|
|
|
|
Old: "",
|
|
|
|
New: "foo3",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "Splay",
|
|
|
|
Old: "",
|
|
|
|
New: "3",
|
|
|
|
},
|
2020-03-10 21:55:16 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "VaultGrace",
|
|
|
|
Old: "",
|
|
|
|
New: "0",
|
|
|
|
},
|
2016-09-23 23:14:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Template",
|
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "ChangeMode",
|
|
|
|
Old: "bam2",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2016-10-06 22:17:34 +00:00
|
|
|
Name: "ChangeSignal",
|
|
|
|
Old: "SIGHUP2",
|
2016-09-23 23:14:20 +00:00
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2016-10-06 22:17:34 +00:00
|
|
|
Name: "DestPath",
|
|
|
|
Old: "bar2",
|
2016-09-23 23:14:20 +00:00
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2016-10-06 22:17:34 +00:00
|
|
|
Name: "EmbeddedTmpl",
|
|
|
|
Old: "baz2",
|
2016-09-23 23:14:20 +00:00
|
|
|
New: "",
|
|
|
|
},
|
2017-05-27 00:05:14 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Envvars",
|
|
|
|
Old: "true",
|
|
|
|
New: "",
|
|
|
|
},
|
2017-02-01 04:00:33 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Perms",
|
|
|
|
Old: "0666",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-09-23 23:14:20 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "SourcePath",
|
|
|
|
Old: "foo2",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "Splay",
|
|
|
|
Old: "2",
|
|
|
|
New: "",
|
|
|
|
},
|
2020-03-10 21:55:16 +00:00
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "VaultGrace",
|
|
|
|
Old: "0",
|
|
|
|
New: "",
|
|
|
|
},
|
2016-09-23 23:14:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-12-15 23:40:18 +00:00
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "DispatchPayload added",
|
|
|
|
Old: &Task{},
|
2016-12-15 23:40:18 +00:00
|
|
|
New: &Task{
|
2017-01-26 05:06:16 +00:00
|
|
|
DispatchPayload: &DispatchPayloadConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
File: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
2017-01-26 05:06:16 +00:00
|
|
|
Name: "DispatchPayload",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeAdded,
|
|
|
|
Name: "File",
|
|
|
|
Old: "",
|
|
|
|
New: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "DispatchPayload deleted",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: &Task{
|
2017-01-26 05:06:16 +00:00
|
|
|
DispatchPayload: &DispatchPayloadConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
File: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
2017-01-26 05:06:16 +00:00
|
|
|
Name: "DispatchPayload",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeDeleted,
|
|
|
|
Name: "File",
|
|
|
|
Old: "foo",
|
|
|
|
New: "",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
Name: "Dispatch payload edited",
|
2016-12-15 23:40:18 +00:00
|
|
|
Old: &Task{
|
2017-01-26 05:06:16 +00:00
|
|
|
DispatchPayload: &DispatchPayloadConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
File: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
2017-01-26 05:06:16 +00:00
|
|
|
DispatchPayload: &DispatchPayloadConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
File: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2017-01-26 05:06:16 +00:00
|
|
|
Name: "DispatchPayload",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "File",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2017-04-19 18:37:57 +00:00
|
|
|
// Place holder for if more fields are added
|
|
|
|
Name: "DispatchPayload edited with context",
|
2016-12-15 23:40:18 +00:00
|
|
|
Contextual: true,
|
|
|
|
Old: &Task{
|
2017-01-26 05:06:16 +00:00
|
|
|
DispatchPayload: &DispatchPayloadConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
File: "foo",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
New: &Task{
|
2017-01-26 05:06:16 +00:00
|
|
|
DispatchPayload: &DispatchPayloadConfig{
|
2016-12-15 23:40:18 +00:00
|
|
|
File: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Expected: &TaskDiff{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Objects: []*ObjectDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
2017-01-26 05:06:16 +00:00
|
|
|
Name: "DispatchPayload",
|
2016-12-15 23:40:18 +00:00
|
|
|
Fields: []*FieldDiff{
|
|
|
|
{
|
|
|
|
Type: DiffTypeEdited,
|
|
|
|
Name: "File",
|
|
|
|
Old: "foo",
|
|
|
|
New: "bar",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-05-11 05:23:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for i, c := range cases {
|
2017-04-19 18:37:57 +00:00
|
|
|
t.Run(c.Name, func(t *testing.T) {
|
2021-05-07 16:10:26 +00:00
|
|
|
t.Logf("running case: %d %v", i, c.Name)
|
2016-05-11 05:23:34 +00:00
|
|
|
|
2021-05-07 16:10:26 +00:00
|
|
|
actual, err := c.Old.Diff(c.New, c.Contextual)
|
|
|
|
if c.Error {
|
|
|
|
require.Error(t, err)
|
|
|
|
} else {
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, c.Expected, actual)
|
2017-04-19 18:37:57 +00:00
|
|
|
}
|
|
|
|
})
|
2016-05-11 05:23:34 +00:00
|
|
|
}
|
|
|
|
}
|