As it was, any error in a weighted mapping would return a very unhelpfull error message.
e.g. `nats-server: mappingtest.cfg:38:39: interface conversion: interface {} is []interface {}, not string`
This was because the line `err := &configErr{tk, fmt.Sprintf("Error adding mapping for %q to %q : %v", subj, v.(string), err)}` would panic on the `v.(string)` since in weighted mapping that interface{} is actually a map[string]interface{} (since there's can be more than one mapping in weighted mappings).
Now returns the actual error:
e.g. `nats-server: mappingtest.cfg:40:3: Error adding mapping for "bla" : invalid mapping destination: wildcard index out of range in {{wildcard(1)}}`
2: improves subject transform checking and catches if the destination is using a mapping function and there are no partial wildcards in the source.
Signed-off-by: Jean-Noël Moyne <jnmoyne@gmail.com>
The issue really was that the test was sharing remote options. The way
options are used is not ideal since we reference the user provided
options (but it is relied upon now in many tests and possibly users
setups). The other side of the issue was that when no local account is
specified in a "remote" specification, we set it to the global account,
but that was done when creating the leafnode object (when soliciting),
which in the case of the test could race with the second server doing
the validation.
In this PR we move the setting to global account during the validation,
but also fixed the tests to not share the remote options configuration
slice between the two servers.
Resolves#4191
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
The issue really was that the test was sharing remote options. The
way options are used is not ideal since we reference the user provided
options (but it is relied upon now in many tests and possibly users
setups). The other side of the issue was that when no local account
is specified in a "remote" specification, we set it to the global
account, but that was done when creating the leafnode object (when
soliciting), which in the case of the test could race with the
second server doing the validation.
In this PR we move the setting to global account during the validation,
but also fixed the tests to not share the remote options configuration
slice between the two servers.
Resolves#4191
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This is a rework of incorrect changes made in PR #4001. Changes did not
work for changes to export permissions. Test was modified to add export
changes.
This affects only the `dev` branch.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
- [X] Branch rebased on top of current main (`git pull --rebase origin
main`)
- [X] Changes squashed to a single commit (described
[here](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html))
- [ ] Build is green in Travis CI
- [X] You have certified that the contribution is your original work and
that you license the work to the project under the [Apache 2
license](https://github.com/nats-io/nats-server/blob/main/LICENSE)
### Changes proposed in this pull request:
Allows (exposes) the existing cluster filtering option of account level
subject mapping, thereby allowing you to define different mapping
destination per cluster (e.g. to insert the cluster name as a subject
token).
Example:
```
mappings {
"foo":[
{destination:"foo-east", cluster: "east", weight:100},
{destination:"foo-west", cluster: "west", weight:100},
]
}
```
This adds a workflow to mark issues and PRs stale after the configured
period of time, followed by closing the issue/PR after a subsequent
period of time if there was no additional activity.
The `debug-only` option is so currently, so even when merged, it will do
a dry-run and not perform any actions. Once we inspect the initial logs
of the effect of an initial run (impacting existing issues), we can
adjust accordingly and then follow-up with making it active.
For the debug logs to be enabled, we do need to add a repository secret
named `ACTIONS_STEP_DEBUG` with a value set to `true` per [this
instruction](https://github.com/marketplace/actions/close-stale-issues#debugging).
1. When catching up do not try forever and if needed reset cluster state.
2. In checking if a stream is healthy check for node drift.
3. When restarting a stream make sure the current node is stopped.
Signed-off-by: Derek Collison <derek@nats.io>
This is similar to PR #4115 but for LeafNodes.
Compression mode can be set on both side (the accept and in remotes).
```
leafnodes {
port: 7422
compression: s2_best
remotes [
{
url: "nats://host2:74222"
compression: s2_better
}
]
}
```
Possible modes are similar than for routes (described in PR #4115),
except that when not defined we default to `s2_auto`.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
Make sure to wait properly until we believe we are caught up to enable
direct gets on followers.
Signed-off-by: Derek Collison <derek@nats.io>
Resolves#4162
This is similar to PR #4115 but for LeafNodes.
Compression mode can be set on both side (the accept and in remotes).
```
leafnodes {
port: 7422
compression: s2_best
remotes [
{
url: "nats://host2:74222"
compression: s2_better
}
]
}
```
Possible modes are similar than for routes (described in PR #4115),
except that when not defined we default to `s2_auto`.
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
When the first block was truncated and missing any index info we would
not properly rebuild the state.
Signed-off-by: Derek Collison <derek@nats.io>
Resolves#3734