Commit Graph

833 Commits

Author SHA1 Message Date
Derek Collison
803ca55e87 Merge pull request #729 from nats-io/sublist_race
Avoid a race between sublist and cache on store
2018-08-29 11:48:43 -06:00
Derek Collison
5b7cabd25e Avoid race between sublist and cache on store-s 2018-08-29 11:34:55 -06:00
Ivan Kozlovic
1cdf39d7f4 Merge pull request #727 from nats-io/fix_route_permissions
Fixed crash related to route permissions after allow/deny feature
2018-08-27 19:16:35 -06:00
Ivan Kozlovic
156224a85b Fix sublist cache flapping test
Use `checkFor` to ensure that cache size is ok. Repeated test
1000 times and no failure now.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-27 15:01:38 -06:00
Ivan Kozlovic
7e39d0935d Fixed crash related to route permissions after allow/deny feature
This is an issue in master only, not in any public release.
The issue is that permissions should be assigned as-is for the
route perms because Publish/Subscribe could be nil, so trying
to dereference Publish.Allow/Deny or Subscribe.Allow/Deny could
crash. The code checking for permissions correctly check if
Publish/Subscribe is nil or not.

This was introduced with PR #725

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-27 14:43:32 -06:00
Derek Collison
c926b56d1f Merge pull request #726 from nats-io/sublist_cache
Sublist Shared Cache Improvements
2018-08-27 12:03:49 -07:00
Derek Collison
2c4b7e7d54 Let cache sweeper run
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-27 12:56:28 -06:00
Derek Collison
ad3a1506d3 Move test into cache test, make sure it fails
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-27 12:49:29 -06:00
Derek Collison
ab9e4c7d8a Fix for wildcard cache addition
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-27 12:28:32 -06:00
Derek Collison
d21ac8de35 Use sync.Map for cache, fast version of literal test
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-25 17:42:36 -07:00
Derek Collison
543d403337 Optimize sublist cache, add tests for cache contention
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-25 14:33:15 -07:00
Derek Collison
34b556dd9f Additional nil checks for perms
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-25 09:49:29 -07:00
Derek Collison
7b9bab22c9 Reduce duplicate code, check subjects
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-23 16:47:20 -07:00
Derek Collison
3798df3044 Undo tmp changes not meant for PR
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-23 16:41:55 -07:00
Derek Collison
5955f22d65 Add in route permission support
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-23 14:42:43 -07:00
Derek Collison
a79806e79d Add enforcement of allow and deny permissions
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-23 11:00:35 -07:00
Derek Collison
65188f9768 Added parser for new style authorizations
Signed-off-by: Derek Collison <derek@nats.io>
2018-08-22 20:41:48 -07:00
Ivan Kozlovic
3ad63c7cb6 Merge pull request #722 from nats-io/changes_for_service_and_syslog
Update service and syslog code to use variable instead of constant
2018-08-16 11:47:12 -06:00
Ivan Kozlovic
2153a45050 Update service and syslog code to use variable instead of constant
for the process name and service name. This allows the reuse of this
code in NATS Streaming Server by invoking the new setters to
change the service and process names.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-16 10:21:01 -06:00
Ivan Kozlovic
b1bb181f3d Ensure URLs are compared using reflect.DeepEqual
I don't think it is a good thing to compare the pointers and we
should use the DeepEqual instead.
When comparing a solicited route's URL to the URL that was created
during the parsing of the configuration, the pointers maybe the
same and so u1 == u2 would work. However, there are cases where
the URL is built on the fly based on the received route INFO protocol
so I think it is safer to use a function that does a reflect.DeepEqual
instead.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-16 09:48:32 -06:00
Ivan Kozlovic
d98d51c8cc [FIXED] Possible cluster Authorization Error during config reload
When changing something in the cluster, such as Timeout and doing
a config reload, the route could be closed with an `Authorization
Error` report. Moreover, the route would not try to reconnect,
even if specified as an explicit route.

There were 2 issues:
- When checking if a solicited route is still valid, we need to
  check the Routes' URL against the URL that we try to connect
  to but not compare the pointers, but either do a reflect
  deep equal, or compare their String representation (this is
  what I do in the PR).
- We should check route authorization only if this is an accepted
  route, not an explicit one. The reason is that we a server
  explicitly connect to another server, it does not get the remote
  server's username and password. So the check would always fail.

Note: It is possible that a config reload even without any change
in the cluster triggers the code checking if routes are properly
authorized, and that happens if there is TLS specified. When
the reload code checks if config has changed, the TLSConfig
between the old and new seem to indicate a change, eventhough there
is apparently none. Another reload does not detect a change. I
suspect some internal state in TLSConfig that causes the
reflect.DeepEqual() to report a difference.

Note2: This commit also contains fixes to regex that staticcheck
would otherwise complain about (they did not have any special
character), and I have removed printing the usage on startup when
getting an error. The usage is still correctly printed if passing
a parameter that is unknown.

Resolves #719

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-08-15 18:20:29 -06:00
Ivan Kozlovic
cd28d58a90 Prepare for release 1.2.0
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-07-05 10:12:06 -06:00
Ivan Kozlovic
508240ba8b Merge pull request #708 from nats-io/flaky
Fix for flaky tests
2018-07-03 11:31:23 -06:00
Ivan Kozlovic
895f05e5e9 Merge pull request #691 from nats-io/port-file
Added Internal option to write a ports file `--ports_file_dir`
2018-07-02 18:03:47 -06:00
Derek Collison
f7241aa435 Allow max and max/2 for edge conditions
Signed-off-by: Derek Collison <derek@nats.io>
2018-07-02 14:29:29 -07:00
Alberto Ricart
456c09855e fmt 2018-07-02 15:50:03 -05:00
Derek Collison
85c2edc314 Make sure to flush the sub
Signed-off-by: Derek Collison <derek@nats.io>
2018-07-02 12:10:17 -07:00
Derek Collison
90a3a1d8b4 Slow down sweeper to make sure we receive all messages
Signed-off-by: Derek Collison <derek@nats.io>
2018-07-02 12:02:59 -07:00
Derek Collison
bd972a9aca fixes
Signed-off-by: Derek Collison <derek@nats.io>
2018-07-02 11:46:40 -07:00
Derek Collison
3a4a1a060c Changes from comments on PR
Signed-off-by: Derek Collison <derek@nats.io>
2018-07-02 10:35:18 -07:00
Derek Collison
e78d587083 Added support for maximum subscriptions per connection
Signed-off-by: Derek Collison <derek@nats.io>
2018-07-01 15:13:59 -07:00
Derek Collison
305d7bdf88 Allow subsz detail and test for matching subs
Signed-off-by: Derek Collison <derek@nats.io>
2018-07-01 13:02:28 -07:00
Derek Collison
cd834a36fa Added more sort options, fixed some broken ones.
Fixes #700, #701, #702

Signed-off-by: Derek Collison <derek@nats.io>
2018-06-29 17:44:01 -07:00
Derek Collison
2e0830201c Make sure closed conn accounting correct for bad clients
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-29 11:42:23 -07:00
Derek Collison
a7dd092136 Add in proto to INFO
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-29 10:43:08 -07:00
Derek Collison
535367e340 Make sure sub registered, wait a bit for all msgs
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-28 18:45:46 -07:00
Derek Collison
061788ab9b Add no echo feature
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-28 18:34:27 -07:00
Derek Collison
3b953ce838 Allow localhost to not be defined, only need 127.0.0.1
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-28 16:10:19 -07:00
Derek Collison
719deacc3d Fixes #686
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-28 13:14:18 -07:00
Ivan Kozlovic
aff1dcf089 Fix some tests
Add some helpers to check on some state.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-27 17:26:49 -06:00
Ivan Kozlovic
f692c0ef8a Add debug info for failed RTT test
The test TestConnzRTT() failed once with "invalid duration". Adding
the original string in case of error to understand better.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-26 19:54:12 -06:00
Ivan Kozlovic
cb1c2e7352 Use waitForClientConnCount() in TestConnzTLSInHandshake()
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-26 19:42:55 -06:00
Ivan Kozlovic
093ced686a Fix for TestClosedConnsAccounting() test
Add sleep to ensure closed connections are stored in expected
order since we later test on expected cid.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-26 19:31:04 -06:00
Ivan Kozlovic
c092c3d19e Wait for correct client count in TestConnzTLSInHandshake
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-26 18:52:56 -06:00
Ivan Kozlovic
0e422812cd Tune some more tests
- Increate WriteDeadline test that otherwise could cause a client
  connect to fail
- Check failed NumRoutes() with retry
- Check that subs are propagated in route permissions test

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-26 18:52:56 -06:00
Ivan Kozlovic
9259da2d3d Moved some tests to test files that compile only in no race mode
Some tests consume too much memory when running with -race which
can cause some failures on Travis.
Moreover, those tests may not be meaningful if they are running
slow, which -race causes.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-26 18:52:56 -06:00
Ivan Kozlovic
a759ad23aa Add back NoSigs=true to runServerWithSymlinkConfig()
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-26 18:52:56 -06:00
Derek Collison
81a1b02f0b Slightly higher so publisher can connect
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-26 17:01:51 -07:00
Derek Collison
57e57892da Test for closed state being correct
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-26 16:54:11 -07:00
Derek Collison
f9f478b143 Wait for all closed connections before starting
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-26 15:14:32 -07:00