Commit Graph

2970 Commits

Author SHA1 Message Date
Derek Collison
c8b4b2efa3 Merge pull request #1478 from nats-io/no_responders
Allow support for no responders nil response message.
2020-06-15 10:39:07 -07:00
Derek Collison
e1c397342c Merge branch 'master' into no_responders 2020-06-15 10:23:01 -07:00
Derek Collison
ddb4219f7a Allow support for a empty response message when no responders are present.
This will also set a response status of 503 with the new header support.

Signed-off-by: Derek Collison <derek@nats.io>
2020-06-15 10:10:21 -07:00
Derek Collison
2b9e3e5b15 Merge pull request #1476 from nats-io/cluster_name
Cluster names are now required.
2020-06-15 10:07:30 -07:00
Derek Collison
1e52a1007b More updates based on feedback
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-13 08:00:57 -07:00
Derek Collison
146d8f5dcb Updates based on feedback, sped up some slow tests
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-12 17:26:43 -07:00
Ivan Kozlovic
498e625fba Merge pull request #1475 from nats-io/fix_leafnode_solicit_failure_race
[FIXED] LeafNode solicit failure race could leave conn registered
2020-06-12 17:04:16 -06:00
Ivan Kozlovic
b36672a6bc Fixed flapper
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 16:51:40 -06:00
Derek Collison
dd61535e5a Cluster names are now required.
Added cluster names as required for prep work for clustered JetStream. System can dynamically pick a cluster name and settle on one even in large clusters.

Signed-off-by: Derek Collison <derek@nats.io>
2020-06-12 15:48:38 -07:00
Ivan Kozlovic
61cccbce02 [FIXED] LeafNode solicit failure race could leave conn registered
This was found due to a recent test that was flapping. The test
was not checking the correct server for leafnode connection, but
that uncovered the following bug:

When a leafnode connection is solicited, the read/write loops are
started. Then, the connection lock is released and several
functions invoked to register the connection with an account and
add to the connection leafs map.
The problem is that the readloop (for instance) could get a read
error and close the connection *before* the above said code
executes, which would lead to a connection incorrectly registered.

This could be fixed either by delaying the start of read/write loops
after the registration is done, or like in this PR, check the
connection close status after registration, and if closed, manually
undoing the registration with account/leafs map.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 16:01:13 -06:00
Ivan Kozlovic
7545ff1cef Merge pull request #1473 from nats-io/fix_1451
[ADDED] Print the config file being used in startup banner
2020-06-12 13:51:38 -06:00
Ivan Kozlovic
d6de05f49a Fixed a test with data race
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 13:04:05 -06:00
Ivan Kozlovic
67d2638859 [ADDED] Print the config file being used in startup banner
Resolves #1451

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 12:21:50 -06:00
Ivan Kozlovic
02eb98c3c6 Merge pull request #1470 from nats-io/fix_websocket_auth_override_and_perf
[FIXED] LeafNode TLSMap and websocket auth override
2020-06-12 10:14:03 -06:00
Ivan Kozlovic
e9679523d8 Merge pull request #1471 from nats-io/fix_ping_test
Fixed TestPing test
2020-06-12 10:13:08 -06:00
Ivan Kozlovic
b60d5e6796 Fixed TestPing test
The test was not checking that PINGs were sent, however, without
disabling the first short ping and with a very low interval, there
was chance on Travis that the first short ping was sent before
the client had connected, which would break the NATS client protocol
that expects to receive a PONG to initial PING (after CONNECT).
The client library could arguably be updated to accept PING during
the CONNECT phase.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-12 10:03:47 -06:00
Derek Collison
240e72b91c Merge pull request #1469 from nats-io/fix-typo
Fix typo in maintainers.md
2020-06-11 16:33:01 -07:00
Waldemar Quevedo
c1a4372949 Fix maintainers typo 2020-06-11 16:31:09 -07:00
Ivan Kozlovic
d2a8282a0d [FIXED] LeafNode TLSMap and websocket auth override
We added authentication override block for websocket configuration
in PR #1463 and #1465 which somehow introduced a drop in perf as
reported by the bench tests.
This PR refactors a bit to restore the performance numbers.

This change also fixes the override behavior for websocket auth:
- If websocket's NoAuthUser is configured, the websocket's auth
  block MUST define Users, and the user be present.
- If there is any override (username/pwd,token,etc..) then the
  whole block config will be used when authenticating a websocket
  client, which means that if websocket NoAuthUser is empty we
  are not falling back to the regular client's NoAuthUser config.
- TLSMap always override the regular client's config. That is,
  whatever TLSMap value specified in the websocket's tls{} block
  will be used.

The TLSMap configuration was not used for LeafNodes. The behavior
now will be:
- If LeafNode's auth block contains users and TLSMap is true,
  the user is looked up based on the cert's info. If not found,
  authentication will fail. If found, it will be authenticated
  and bound to associated account.
- If no user is specified in LeafNode's auth block and TLSMap
  is true, then the cert's info will be used against the global
  users map.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-11 17:06:54 -06:00
R.I.Pienaar
967bb66061 Merge pull request #1430 from nats-io/header-spec
Header specification from the perspective of client libraries.
2020-06-11 22:06:27 +02:00
R.I.Pienaar
1546b3da82 Merge pull request #1405 from ripienaar/distributed_tracing_adr
distributed tracing adr
2020-06-11 22:06:08 +02:00
Alberto Ricart
3c3ee22e9f changed \r to and \n to 2020-06-11 12:11:43 -05:00
Ivan Kozlovic
ddfbc33c95 Merge pull request #1465 from nats-io/users_nkeys_map
Refactor some code to make it reuseable
2020-06-09 17:50:03 -06:00
Ivan Kozlovic
313cf898c1 Refactor some code to make it reuseable
Building server's nkeys and users map out of slices form options
has been made a function so it can be used for the server and
websocket (and in future for mqtt)

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-09 17:27:51 -06:00
Ivan Kozlovic
d18b013676 Merge pull request #1463 from nats-io/websocket_auth_block
Added dedicated auth block for websocket
2020-06-09 16:09:41 -06:00
Ivan Kozlovic
ec5caa692b Merge pull request #1464 from nats-io/fix_flapper
Fixed flappers
2020-06-09 16:08:50 -06:00
Ivan Kozlovic
b9bd5c2d35 Fixed flappers
Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-09 15:34:52 -06:00
Ivan Kozlovic
01b14c2abe Added dedicated auth block for websocket
Websocket can now override
- Username/password
- Token
- Users
- NKeys
- no_auth_user
- auth_timeout

For TLS, support for verify and verify_and_map. We used to set
tls config's ClientAuth to NoClientCert. It will now depend
if the config requires client certificate verification, which
is needed if TLSMap is enabled.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-09 11:29:52 -06:00
Derek Collison
bfe52fdb77 Merge pull request #1458 from nats-io/mixed
Allow mixed TLS and non-TLS on same port.
2020-06-08 11:12:45 -07:00
Ivan Kozlovic
6413fcd9c0 Merge pull request #1460 from nats-io/fix_1459
[ADDED] lame_duck_grace_period option
2020-06-08 12:07:47 -06:00
Ivan Kozlovic
cd6d71deaa [ADDED] lame_duck_grace_period option
The grace period used to be hardcoded at 10 seconds.
This option allows the user to configure the amount of time the
server will wait before initiating the closing of client connections.

Note that the grace period needs to be strictly lower than the overall
lame_duck_duration. The server deducts the grace period from that
overall duration and spreads the closing of connections during
that time.
For instance, if there are 1000 connections and the lame duck
duration is set to 30 seconds and grace period to 10, then
the server will use 30-10 = 20 seconds to spread the closing
of those 1000 connections, so say roughly 50 clients per second.

Resolves #1459.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-08 11:43:25 -06:00
Derek Collison
3a4e835311 Key off TLS first byte
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-06 13:41:34 -07:00
Derek Collison
75395ed862 Read 4 bytes, wait TLS timeout
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 18:38:20 -07:00
Derek Collison
4dee03b587 Allow mixed TLS and non-TLS on same port
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 18:04:11 -07:00
Derek Collison
ede25f65a6 Merge pull request #1457 from nats-io/sisubs
Don't leak service import subs on claim updates
2020-06-05 13:35:32 -07:00
Derek Collison
d0f65c8a74 Don't leak service import subs on claim updates
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 13:28:40 -07:00
Ivan Kozlovic
82968f64d4 Merge pull request #1455 from nats-io/fix_ln_sub_interest_propagation
[FIXED] Unsubscribe may not be propagated through a leaf node
2020-06-05 11:11:26 -06:00
Ivan Kozlovic
25bd5ca352 [FIXED] Unsubscribe may not be propagated through a leaf node
There is a race between the time the processing of a subscription
and the init/send of subscriptions when accepting a leaf node
connection that may cause internally a subscription's subject
to be counted many times, which would then prevent the send of
an LS- when the subscription's interest goes away.

Imagine this sequence of events, each side represents a "thread"
of execution:
```
client readLoop                         leaf node readLoop
----------------------------------------------------------
recv SUB foo 1
sub added to account's sublist

                                         recv CONNECT
                                     auth, added to acc.

updateSmap
smap["foo"]++ -> 1
no LS+ because !allSubsSent

                                         init smap
                                    finds sub in acc sl
                                    smap["foo"]++ -> 2
                                        sends LS+ foo
                                    allSubsSent == true

recv UNSUB 1
updateSmap
smap["foo"]-- -> 1
no LS- because count != 0
----------------------------------------------------------
```
Equivalent result but with slightly diffent execution:
```
client readLoop                         leaf node readLoop
----------------------------------------------------------
recv SUB foo 1
sub added to account's sublist

                                         recv CONNECT
                                     auth, added to acc.

                                         init smap
                                    finds sub in acc sl
                                    smap["foo"]++ -> 1
                                        sends LS+ foo
                                    allSubsSent == true

updateSmap
smap["foo"]++ -> 2
no LS+ because count != 1

recv UNSUB 1
updateSmap
smap["foo"]-- -> 1
no LS- because count != 0
----------------------------------------------------------
```

The approach for the fix is delay the creation of the smap
until we actually initialize the map and send the subs on processing
of the CONNECT.
In the meantime, as soon as the LN connection is registered
and available in updateSmap, we check that smap is nil or
not. If nil, we do nothing.

In "init smap" we keep track of the subscriptions that have been
added to smap. This map will be short lived, just enough to
protect against races above.

In updateSmap, when smap is not nil, we need to checki, if we
are adding, that the subscription has not already been handled.
The tempory subscription map will be ultimately emptied/set to
nil with the use of a timer (if not emptied in place when
processing smap updates).

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2020-06-05 10:07:15 -06:00
Derek Collison
19fcafa175 Merge pull request #1454 from nats-io/sys
Add default system account back to accounts after reload
2020-06-05 09:06:57 -07:00
Derek Collison
a57d1794e9 Merge pull request #1453 from nats-io/subsz
Add account details to subsz.
2020-06-05 09:00:24 -07:00
Derek Collison
4ea9c12d23 Add default system account back to accounts after reload
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 08:59:04 -07:00
Derek Collison
b91c8879ad Consolidate subDetail
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 08:37:18 -07:00
Derek Collison
c1ffd48638 Add account details to subsz.
Also allow ability to filter based on account.

Signed-off-by: Derek Collison <derek@nats.io>
2020-06-05 05:53:01 -07:00
Derek Collison
326f6c2e00 Merge pull request #1452 from ripienaar/nightly_fix
fix nightly schedule
2020-06-05 04:07:50 -07:00
R.I.Pienaar
04271d7ead fix nightly schedule
Signed-off-by: R.I.Pienaar <rip@devco.net>
2020-06-05 12:21:36 +02:00
Derek Collison
eed381d617 Merge pull request #1450 from nats-io/restore_unsub
Do proper ubsubscribe when shutting off restore endpoint
2020-06-04 11:32:50 -07:00
Derek Collison
9c6d54f20c Merge pull request #1449 from ripienaar/nightly_docker
add nightly docker build workflows
2020-06-04 08:59:39 -07:00
Derek Collison
c969e7e424 Do proper ubsubscribe when shutting off restore endpoint
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-04 08:58:14 -07:00
Derek Collison
f7f40f16a5 Bumped version
Signed-off-by: Derek Collison <derek@nats.io>
2020-06-04 07:15:14 -07:00
Derek Collison
f07533c823 Merge pull request #1448 from nats-io/restore
Snapshot restore now works across leafnodes.
2020-06-04 07:13:12 -07:00