changed format of JSClusterNoPeers error (#3459)

* changed format of JSClusterNoPeers error

This error was introduced in #3342 and reveals to much information
This change gets rid of cluster names and peer counts.

All other counts where changed to booleans,
which are only included in the output when the filter was hit.

In addition, the set of not matching tags is included.
Furthermore, the static error description in server/errors.json 
is moved into selectPeerError

sample errors:
1) no suitable peers for placement, tags not matched ['cloud:GCP', 'country:US']"
2) no suitable peers for placement, insufficient storage

Signed-off-by: Matthias Hanel <mh@synadia.com>
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Co-authored-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Matthias Hanel
2022-09-08 18:25:48 -07:00
committed by GitHub
parent 50d62cede3
commit f7cb5b1f0d
6 changed files with 98 additions and 59 deletions

View File

@@ -79,7 +79,7 @@ func TestJetStreamSuperClusterMetaPlacement(t *testing.T) {
// Make sure we get correct errors for tags and bad or unavailable cluster placement.
sdr := stepdown("C22")
if sdr.Error == nil || !strings.Contains(sdr.Error.Description, "no suitable peers") {
if sdr.Error == nil || !strings.Contains(sdr.Error.Description, "no replacement peer connected") {
t.Fatalf("Got incorrect error result: %+v", sdr.Error)
}
// Should work.
@@ -184,7 +184,7 @@ func TestJetStreamSuperClusterUniquePlacementTag(t *testing.T) {
si, err := js.AddStream(&nats.StreamConfig{Name: name, Replicas: test.replicas, Placement: test.placement})
if test.fail {
require_Error(t, err)
require_Contains(t, err.Error(), "no suitable peers for placement")
require_Contains(t, err.Error(), "no suitable peers for placement", "server tag not unique")
return
}
require_NoError(t, err)
@@ -1503,7 +1503,8 @@ func TestJetStreamSuperClusterStreamTagPlacement(t *testing.T) {
Subjects: []string{"foo"},
Placement: &nats.Placement{Tags: tags},
})
require_Contains(t, err.Error(), "no suitable peers for placement")
require_Contains(t, err.Error(), "no suitable peers for placement", "tags not matched")
require_Contains(t, err.Error(), tags...)
}
placeErr("C1", []string{"cloud:GCP", "country:US"})
@@ -2393,7 +2394,7 @@ func TestJetStreamSuperClusterMaxHaAssets(t *testing.T) {
_, err = js.AddStream(&nats.StreamConfig{Name: "S3", Replicas: 3, Placement: &nats.Placement{Cluster: "C1"}})
require_Error(t, err)
require_Contains(t, err.Error(), "nats: no suitable peers for placement")
require_Contains(t, err.Error(), "misc: 3")
require_Contains(t, err.Error(), "miscellaneous issue")
require_NoError(t, js.DeleteStream("S1"))
waitStatsz(3, 2)
waitStatsz(3, 1)
@@ -2427,7 +2428,7 @@ func TestJetStreamSuperClusterMaxHaAssets(t *testing.T) {
_, err = js.UpdateStream(&nats.StreamConfig{Name: "S2", Replicas: 3, Placement: &nats.Placement{Cluster: "C2"}})
require_Error(t, err)
require_Contains(t, err.Error(), "nats: no suitable peers for placement")
require_Contains(t, err.Error(), "misc: 3")
require_Contains(t, err.Error(), "miscellaneous issue")
}
func TestJetStreamSuperClusterStreamAlternates(t *testing.T) {