-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes accidental state store updates from output-side fixups. #3867
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,26 +547,42 @@ func TestAgent_RemoveServiceRemovesAllChecks(t *testing.T) { | |
} | ||
} | ||
|
||
// TestAgent_ServiceWithTagChurn is designed to detect a class of issues where | ||
// we would have unnecessary catalog churn for services with tags. See issues | ||
// #3259, #3642, and #3845. | ||
func TestAgent_ServiceWithTagChurn(t *testing.T) { | ||
// TestAgent_IndexChurn is designed to detect a class of issues where | ||
// we would have unnecessary catalog churn from anti-entropy. See issues | ||
// #3259, #3642, #3845, and #3866. | ||
func TestAgent_IndexChurn(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("no tags", func(t *testing.T) { | ||
verifyIndexChurn(t, nil) | ||
}) | ||
|
||
t.Run("with tags", func(t *testing.T) { | ||
verifyIndexChurn(t, []string{"foo", "bar"}) | ||
}) | ||
} | ||
|
||
// verifyIndexChurn registers some things and runs anti-entropy a bunch of times | ||
// in a row to make sure there are no index bumps. | ||
func verifyIndexChurn(t *testing.T, tags []string) { | ||
t.Helper() | ||
|
||
a := NewTestAgent(t.Name(), "") | ||
defer a.Shutdown() | ||
|
||
svc := &structs.NodeService{ | ||
ID: "redis", | ||
Service: "redis", | ||
Port: 8000, | ||
Tags: []string{"has", "tags"}, | ||
Tags: tags, | ||
} | ||
if err := a.AddService(svc, nil, true, ""); err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
|
||
chk := &structs.HealthCheck{ | ||
CheckID: "redis-check", | ||
Name: "Service-level check", | ||
ServiceID: "redis", | ||
Status: api.HealthCritical, | ||
} | ||
|
@@ -577,18 +593,34 @@ func TestAgent_ServiceWithTagChurn(t *testing.T) { | |
t.Fatalf("err: %v", err) | ||
} | ||
|
||
chk = &structs.HealthCheck{ | ||
CheckID: "node-check", | ||
Name: "Node-level check", | ||
Status: api.HealthCritical, | ||
} | ||
chkt = &structs.CheckType{ | ||
TTL: time.Hour, | ||
} | ||
if err := a.AddCheck(chk, chkt, true, ""); err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
|
||
if err := a.sync.State.SyncFull(); err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
|
||
args := &structs.ServiceSpecificRequest{ | ||
Datacenter: "dc1", | ||
ServiceName: "redis", | ||
} | ||
var before structs.IndexedHealthChecks | ||
if err := a.RPC("Health.ServiceChecks", args, &before); err != nil { | ||
var before structs.IndexedCheckServiceNodes | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did the test have to change from calling Health.ServiceChecks to Health.ServiceNodes to illustrate this problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This problem wasn't uncovered by this test since you actually have to hit specific HTTP API endpoints to corrupt the data, but I did add a node-level check as part of trying to chase this down, so I changed this RPC endpoint to one that returns the service's check + the node-level checks to make this test more robust. It was when I could see this test passing but run this in an integrated fashion and watching /v1/health/service/ and see churn that I knew something super weird was happening! |
||
if err := a.RPC("Health.ServiceNodes", args, &before); err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
if got, want := len(before.HealthChecks), 1; got != want { | ||
if got, want := len(before.Nodes), 1; got != want { | ||
t.Fatalf("got %d want %d", got, want) | ||
} | ||
if got, want := len(before.Nodes[0].Checks), 3; /* incl. serfHealth */ got != want { | ||
t.Fatalf("got %d want %d", got, want) | ||
} | ||
|
||
|
@@ -598,8 +630,8 @@ func TestAgent_ServiceWithTagChurn(t *testing.T) { | |
} | ||
} | ||
|
||
var after structs.IndexedHealthChecks | ||
if err := a.RPC("Health.ServiceChecks", args, &after); err != nil { | ||
var after structs.IndexedCheckServiceNodes | ||
if err := a.RPC("Health.ServiceNodes", args, &after); err != nil { | ||
t.Fatalf("err: %v", err) | ||
} | ||
verify.Values(t, "", after, before) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue in https://github.com/hashicorp/consul/pull/3867/files#diff-3b7c7efd1037ec5aaf67f1c2e349cf82R149
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what issue you are referring to with this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You fixed it in c2a59f1, around line 150.