From 1d5cc21c3cd5b99a79bbb5dcefa18345453ecaa6 Mon Sep 17 00:00:00 2001 From: David Laban Date: Tue, 17 Aug 2021 17:34:57 +0100 Subject: [PATCH] make error actionable when adding operator+leafnodes There are many examples in the documentation for one half of this configuration or the other, but none which configure a leafnode remote on an operator-authenticated cluster. The error "operator mode requires account nkeys in remotes." is not very clear or actionable. --- server/leafnode.go | 5 ++++- server/leafnode_test.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/leafnode.go b/server/leafnode.go index d70ed9ec..f28cea3f 100644 --- a/server/leafnode.go +++ b/server/leafnode.go @@ -276,7 +276,10 @@ func validateLeafNode(o *Options) error { } for _, r := range o.LeafNode.Remotes { if !nkeys.IsValidPublicAccountKey(r.LocalAccount) { - return fmt.Errorf("operator mode requires account nkeys in remotes") + return fmt.Errorf( + "operator mode requires account nkeys in remotes. " + + "Please add an `account` key to each remote in your `leafnodes` section, to assign it to an account. " + + "Each account value should be a 56 character public key, starting with the letter 'A'") } } if o.LeafNode.Port != 0 && o.LeafNode.Account != "" && !nkeys.IsValidPublicAccountKey(o.LeafNode.Account) { diff --git a/server/leafnode_test.go b/server/leafnode_test.go index 9a862640..0e1a591f 100644 --- a/server/leafnode_test.go +++ b/server/leafnode_test.go @@ -2483,7 +2483,9 @@ func TestLeafNodeOperatorBadCfg(t *testing.T) { authorization { account: notankey }`, - `operator mode requires account nkeys in remotes`: `remotes: [{url: u}]`, + ("operator mode requires account nkeys in remotes. " + + "Please add an `account` key to each remote in your `leafnodes` section, to assign it to an account. " + + "Each account value should be a 56 character public key, starting with the letter 'A'"): `remotes: [{url: u}]`, } { t.Run(errorText, func(t *testing.T) { conf := createConfFile(t, []byte(fmt.Sprintf(`