Commit Graph

1435 Commits

Author SHA1 Message Date
Ivan Kozlovic
0da1afaf88 Fixed data race
Resolves #1176

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-30 20:10:37 -06:00
Ivan Kozlovic
cbbc21ac25 Some update to leafnode subscription handling
- Send all subs in place if smap is small
- Skip sending update until after sendAllLeafSubs() is done

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-30 20:01:49 -06:00
Ivan Kozlovic
17a7d0d866 [FIXED] Server should not send RTT PING before sending initial PONG
As soon as server has processed a client CONNECT, it was possible
that if Connz() or other was requested, the server will send a
PING to compute the RTT. This would cause clients that expect
the first PONG as part of synchronous CONNECT logic to fail.

Make sure that we delay the first RTT ping to after sending the
first PONG, or if client does not send PING as part of the CONNECT,
after 2 seconds have elapsed since the tcp connection was accepted.

Resolves #1174

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-30 19:50:19 -06:00
Ivan Kozlovic
51f83220c6 Fix race introduced in #1170
Code for leafnode loop detection had a data race.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 19:09:21 -06:00
Ivan Kozlovic
6bcb717722 Updates following code review
- Make "lds." a constant
- Create remote's get/reset functions for loop delay
- Bump loop delay to 30 seconds

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 17:59:15 -06:00
Ivan Kozlovic
279cab2aaf [FIXED] Detect loop between LeafNode servers
This is achieved by subscribing to a unique subject. If the LS+
protocol is coming back for the same subject on the same account,
then this indicates a loop.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 16:14:35 -06:00
Ivan Kozlovic
e126a1f9d8 Merge pull request #1169 from nats-io/fix_monitor_link
[UPDATED] Link to monitoring page in new doc [ci skip]
2019-10-29 15:07:52 -06:00
Ivan Kozlovic
280c432787 [UPDATED] Link to monitoring page in new doc [ci skip]
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 14:48:12 -06:00
Ivan Kozlovic
07bf4a499e Issue with multiple users in Leafnode authorization
This was introduced in master #1147, not in any public release.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-29 13:34:30 -06:00
Ivan Kozlovic
d20f76cbaa Merge pull request #1166 from nats-io/add_servername_to_routestat
[ADDED] Server name in the RouteStat for statsz
2019-10-28 13:19:53 -06:00
Ivan Kozlovic
5a44e3b4c6 Changes on how tests can override route protocol
I may need to introduce a new route protocol version for an upcoming
PR and realized that this needed some cleaning.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-26 10:12:30 -06:00
Ivan Kozlovic
12eb1f5b00 [ADDED] Server name in the RouteStat for statsz
Add the remote server name for a route in the statsz event

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-25 16:34:07 -06:00
Ivan Kozlovic
75ec78c232 [FIXED] Explicit gateway not using discovered URLs
If cluster A configures a gateway to cluster B, the server on A
tries to connect to that server URL. If there is no server on B
at that address, but a server on B with different address connects
to server on cluster A, that server should be able to create its
outbound connection in response.
That was not the case because the configured URLs were snapshot
before the loop of trying to connect. When accepting an inbound
connection and updating the array, this new URL was not being used.

The issue is only if the server on A had no outbound connection
at that time.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-24 16:40:38 -06:00
Ivan Kozlovic
27ee8b80e3 Fixed nil dereference reported by staticcheck
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-10-24 15:07:06 -06:00
Derek Collison
daabd4dfde Merge pull request #1158 from ripienaar/1153.hostname
Allows a descriptive server_name to be set
2019-10-17 10:31:41 -07:00
R.I.Pienaar
bcf96fa1de Allows a descriptive server_name to be set
This adds a new config option server_name that
when set will be exposed in varz, events and more
as a descriptive name for the server.

If unset though the server_name will default to the pk

Signed-off-by: R.I.Pienaar <rip@devco.net>
2019-10-17 18:51:19 +02:00
Derek Collison
35758ef7d4 Update the test CA and certs.
Expiration is now Oct 14 14:30:41 2029 GMT

Signed-off-by: Derek Collison <derek@nats.io>
2019-10-17 07:33:08 -07:00
Derek Collison
9192a1f43c Fix for panic on #1159, do not allow wildcards in stream import prefix
Signed-off-by: Derek Collison <derek@nats.io>
2019-10-16 10:29:13 -07:00
Guangming Wang
9a003ba042 fix string trim func usage in pse
Signed-off-by: Guangming Wang <guangming.wang@daocloud.io>
2019-10-15 23:55:13 +08:00
Derek Collison
7cb6056a94 Account support for Connz and user or account filtering
1. Accounts will show up in connection info if auth=1.
2. You can filter by user (?auth=1&user=ivan) or account (?auth=1&acc=eng)

Signed-off-by: Derek Collison <derek@nats.io>
2019-10-11 10:22:08 -07:00
Jaime Piña
f62f6bda70 Add tilde support for leaf node credentials
Signed-off-by: Jaime Piña <jaime@synadia.com>
2019-10-02 13:30:09 -07:00
Ivan Kozlovic
fac004cfe3 Merge pull request #1147 from nats-io/fix_leafnode_auth
[ADDED] Basic auth for leafnodes
2019-10-01 11:43:08 -06:00
Ivan Kozlovic
18a1702ba2 [ADDED] Basic auth for leafnodes
Added a way to specify which account an accepted leafnode connection
should be bound to when using simple auth (user/password).

Singleton:
```
leafnodes {
  port: ...
  authorization {
    user: leaf
    password: secret
    account: TheAccount
  }
}
```
With above configuration, if a soliciting server creates a LN connection
with url: `nats://leaf:secret@host:port`, then the accepting server
will bind the leafnode connection to the account "TheAccount". This account
need to exist otherwise the connection will be rejected.

Multi:
```
leafnodes {
  port: ...
  authorization {
    users = [
      {user: leaf1, password: secret, account: account1}
      {user: leaf2, password: secret, account: account2}
    ]
  }
}
```
With the above, if a server connects using `leaf1:secret@host:port`, then
the accepting server will bind the connection to account `account1`.

If user/password (either singleton or multi) is defined, then the connecting
server MUST provide the proper credentials otherwise the connection will
be rejected.

If no user/password info is provided, it is still possible to provide the
account the connection should be associated with:
```
leafnodes {
  port: ...
  authorization {
    account: TheAccount
  }
}
```
With the above, a connection without credentials will be bound to the
account "TheAccount".

If credentials are used (jwt, nkey or other), then the server will attempt
to authenticate and if successful associate to the account for that specific
user. If the user authentication fails (wrong password, no such user, etc..)
the connection will be also rejected.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-30 19:42:11 -06:00
Jaime Piña
78966fbfa4 Reduce 2019-09-27 16:38:43 -07:00
Jaime Piña
64664946e7 Add QueueSubscribe permissions.
```
users = [
  {
    user: "foo", permissions: {
      sub: {
        # Allow plain subscription foo, but only v1 groups or *.dev queue groups
        allow: ["foo", "foo v1", "foo v1.>", "foo *.dev"]

        # Prevent queue subscriptions on prod groups
        deny: ["> *.prod"]
     }
  }
]
```

Signed-off-by: Jaime Piña <jaime@synadia.com>
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2019-09-27 16:08:24 -07:00
Ivan Kozlovic
3600accb79 [FIXED] Reject duplicate service import "to" subject
Report error from configuration parsing, and also return error
in AddServiceImport() (and its variants).

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-20 16:30:13 -06:00
Ivan Kozlovic
802074292f Release v2.1.0
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-20 12:19:27 -06:00
Waldemar Quevedo
d44b0dec51 Merge pull request #1136 from nats-io/svc-latency-values
Adjust to zero negative latency values
2019-09-20 11:39:33 -05:00
Waldemar Quevedo
d0e36f3b88 Adjust to zero negative latency values
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2019-09-20 09:24:18 -07:00
Derek Collison
ffdbe864a8 Version bump
Signed-off-by: Derek Collison <derek@nats.io>
2019-09-19 19:50:03 -07:00
Derek Collison
37a5612460 Merge pull request #1137 from nats-io/latency_update
Latency tracking updates
2019-09-19 19:48:53 -07:00
Derek Collison
0360f46c2f fixes based on PR updates
Signed-off-by: Derek Collison <derek@nats.io>
2019-09-19 17:16:36 -07:00
Derek Collison
7fe47ace2b Make sure to turn latency on with a claim update
Signed-off-by: Derek Collison <derek@nats.io>
2019-09-19 14:20:35 -07:00
Ivan Kozlovic
731941a18f Fixed ResponsePermissions
- Ensure that defaults are set when values are 0
- Fixed some tests
- Added some helpers in jwt tests to reduce copy/paste

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-19 14:42:38 -06:00
Ivan Kozlovic
256ad4ac15 Bump version to 2.1.0-RC1
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-18 14:26:42 -06:00
Jaime Piña
ab24cddc06 Add latency config
Currently, the config file doesn't recognize the latency config block in
account exports. This change exposes those settings in the config file.

Signed-off-by: Jaime Piña <jaime@synadia.com>
Signed-off-by: Waldemar Quevedo <wally@synadia.com>
2019-09-18 13:20:26 -07:00
Ivan Kozlovic
6a70f36e09 Merge pull request #1131 from nats-io/fix_acc_lookup
[FIXED] Locking issue around account lookup/updates
2019-09-18 12:59:28 -06:00
Ivan Kozlovic
20a925ae86 Updates to registerAccount
Make it a function that grabs server lock/unlock and invokes
registerAccountNoLock(). Use that function when already under
the server's lock.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-18 12:45:12 -06:00
Derek Collison
7cf211b056 Use multiple connections to amortize TLS
Signed-off-by: Derek Collison <derek@nats.io>
2019-09-18 11:40:00 -07:00
Derek Collison
0551371b31 Add in JWT support for tracking latency
Signed-off-by: Derek Collison <derek@nats.io>
2019-09-18 08:51:43 -07:00
Ivan Kozlovic
150d47cab3 [FIXED] Locking issue around account lookup/updates
Ensure that lookupAccount does not hold server lock during
updateAccount and fetchAccount.
Updating the account cannot have the server lock because it is
possible that during updateAccountClaims(), clients are being
removed, which would try to get the server lock (deep down in
closeConnection/s.removeClient).
Added a test that would have show the deadlock prior to changes
in this PR.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-17 18:48:23 -06:00
Derek Collison
b98b75b166 Merge pull request #1127 from nats-io/sysdebug
System level services for debugging.
2019-09-17 09:45:53 -07:00
Derek Collison
52430c304a System level services for debugging.
This is the first pass at introducing exported services to the system account for generally debugging of blackbox systems.
The first service reports number of subscribers for a given subject. The payload of the request is the subject, and optional queue group, and can contain wildcards.

Signed-off-by: Derek Collison <derek@nats.io>
2019-09-17 09:37:35 -07:00
Alberto Ricart
eb56ad22ea review comment 2019-09-17 09:56:03 -05:00
Alberto Ricart
af97b5b9df FIX #1128 - Modified the cluster listenstr parsing to allow cluster urls that have
a -1 for a port. This re-enables ability to create clusters on a random
port for testing.
2019-09-16 10:45:27 -05:00
Ivan Kozlovic
5eebc42f47 Merge pull request #1126 from nats-io/fix_acc_lock_issue
Fixed a lock inversion issue with account
2019-09-13 15:11:02 -06:00
Ivan Kozlovic
15201a19cd Fixed a lock inversion issue with account
In updateRouteSubscriptionMap(), when a queue sub is added/removed,
the code locks the account and then the route to send the update.
However, when a route is accepted and the subs are sent, the
opposite (locking wise) occurs. The route is locked, then the account.

This lock inversion is possible because a route is registered (added
to the server's map) and then the subs are sent.

Use a special lock to protect the send, but don't hold the acc.mu
lock while getting the route's lock.

The tests that were created for the original missed queue updates
issue, namely TestClusterLeaksSubscriptions() and
TestQueueSubWeightOrderMultipleConnections() pass with this change.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2019-09-13 14:30:00 -06:00
Derek Collison
26db43001f Shorter names for latency tracking JSON
Signed-off-by: Derek Collison <derek@nats.io>
2019-09-12 15:11:43 -07:00
Derek Collison
25d5cb337d Make json tags consistent
Signed-off-by: Derek Collison <derek@nats.io>
2019-09-11 17:30:01 -07:00
Derek Collison
94f143ccce Latency tracking updates.
Will now breakout the internal NATS latency to show requestor client RTT, responder client RTT and any internal latency caused by hopping between servers, etc.

Signed-off-by: Derek Collison <derek@nats.io>
2019-09-11 16:43:19 -07:00