Commit Graph

182 Commits

Author SHA1 Message Date
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
e1058d4dd8 Make sure closed connection with options are race safe
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-26 14:45:58 -07:00
Derek Collison
ec8e2636de Track closed connections and reason for closing
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-25 17:56:07 -07:00
Ivan Kozlovic
06f74a0e3a [UPDATED] Elevate TLS error logs from DBG to ERR
The one for route was already changed. Changing the one for
client handshake and TLS timeout.

Resolves #513

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-06-22 09:33:07 -06:00
Derek Collison
b7ece91825 Avoid race by using conditional deep copy
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-21 18:22:06 -07:00
Derek Collison
3f39c244e4 Fixes for comments
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-21 17:37:40 -07:00
Derek Collison
17fecd4c9b Support CID in client INFO, allow filtering /connz by CID
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-21 15:23:15 -07:00
Derek Collison
6299e034cb dynamic buffer updates
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-04 17:45:05 -07:00
Derek Collison
049db6e854 Support for queue subscriber retries over routes
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-04 17:45:05 -07:00
Derek Collison
481697ef67 New outbound data architecture
Signed-off-by: Derek Collison <derek@nats.io>
2018-06-04 17:45:05 -07:00
Ivan Kozlovic
ac42bb0bb9 Remove route connection from temp map
When a route connection is created, the server will keep track
of the client structure in a special map until the route protocol
completes. This is meant so that if the server is shutdown before
the route is registered in routes map, the server can kick out
the connection's readLoop.

The route connection was correctly removed on success, but was
not for route connections that were not registered and dropped.
This was not causing any issue, but for correctness, doing the
removal now when server removes a route connection.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
2018-04-11 16:49:08 -06:00
Ivan Kozlovic
40cf0107d6 Ensure sig handler routine returns on shutdown, turn it off in most tests
I noticed that when running the test suite, there would be a file
server/log1.txt left. This file is created by one of the config
reload test. Running this test individually was doing the proper
cleanup. I noticed that the Signal test that was checking
that files could be rotated was causing this side effect.
It turns out that none of the config reload tests were disabling
the signal handler (NoSigs=true), and since the go routine would
be left running, running the TestSignalToReOpenLogFile() test
would interact with an already finished test.

I put a thread dump in handleSignals() to track all tests that
were causing this function to start the go routine because NoSigs
was not set to true. I fixed all those tests. At this time, there
are only 2 tests that need to start the signal handler.

I have also fixed the code so that the signal handler routine select
on a server quitCh that is closed on shutdown so that this go routine
exit and is waiting on using the grWG wait group.
2018-04-06 17:14:02 -06:00
Ivan Kozlovic
fb972bd0fc Remove ssl_required references 2018-03-23 13:40:10 -06:00
Derek Collison
00901acc78 Update license to Apache 2 2018-03-15 22:31:07 -07:00
Ivan Kozlovic
461ab96a58 Additional fix to #631
This is the result of flapping tests in go-nats that were caused
by a defect (see PR https://github.com/nats-io/go-nats/pull/348).
However, during debugging, I realize that there were also things
that were not quite right in the server side. This change should
make it the notification of cluster topology changes to clients
more robust.
2018-03-05 20:03:46 -07:00
Ivan Kozlovic
aeca31ce51 [FIXED] Cluster toplogy change possibly not sent to clients
When a server accepts a route, it will keep track of that server
`connectURLs` array. However, if the server was creating a route
to that other server at the same time, it will promote the route
as a solicited one. The content of that array was not transfered,
which means that on a disconnect, it was possible that the cluster
topology change was not properly sent to clients.
2018-03-04 14:38:03 -07:00
Ivan Kozlovic
1acf330e07 [ADDED] Notification to clients when servers leave the cluster
Until now, a server would only notify clients of servers that join
the cluster. More than that, a server would send ot its clients only
information if new servers were added.
This PR changes this by sending to clients that support async INFO
the list of URLs for all servers in the cluster any time that there
is a change (joining or leaving the cluster).
As of now, clients will not be affected by the change (and will not
take benefit of this: removing servers from their server pool). This
will be addressed in each supported client once this is merged.
2018-02-27 14:22:13 -07:00
Ivan Kozlovic
f8f1f026e2 Merge pull request #624 from nats-io/injected-version
[ADDED] Print release's GitCommit in the banner
2018-02-26 09:25:05 -07:00
Ivan Kozlovic
163ba3f6a7 Merge pull request #608 from nats-io/fix_issue_447
[ADDED] Client and Cluster Advertise. Issue #447
2018-02-26 09:12:58 -07:00
Alberto Ricart
ce6a5e6c8c Merge remote-tracking branch 'origin/injected-version' into injected-version
- Renamed GitHash to gitCommit as per discussions with Ivan
- Set gitHash to 'not set' if not set (as in the case of a local build)

# Conflicts:
#	server/server.go
2018-02-21 19:24:40 -06:00
Alberto Ricart
68b7aa0155 [ADD] Added github.com/nats-io/gnatsd/server.GITHASH compile variable which allows for linker to inject the githash that gnatsd was built from. See https://husobee.github.io/golang/compile/time/variables/2015/12/03/compile-time-const.html. The githash is exposed on server startup (debug) and on /varz.
[FIX] Docker images were injecting the compile time variable `github.com/nats-io/gnatsd/version.GITCOMMIT`, however this is not referenced nor exposed anywhere.
2018-02-21 17:29:21 -06:00
Alberto Ricart
0bcc360de1 [ADD] Added github.com/nats-io/gnatsd/server.GITHASH compile variable which allows for linker to inject the githash that gnatsd was built from. See https://husobee.github.io/golang/compile/time/variables/2015/12/03/compile-time-const.html. The githash is exposed on server startup (debug) and on /varz.
[FIX] Docker images were injecting the compile time variable `github.com/nats-io/gnatsd/version.GITCOMMIT`, however this is not referenced nor exposed anywhere.
2018-02-21 17:26:41 -06:00
Ivan Kozlovic
acf4a31e4b Major updates + support for config reload of client/cluster advertise 2018-02-05 20:15:36 -07:00
Peter Miron
306a3f9507 Resolving Ivan's feedback. 2017-11-29 15:35:05 -05:00
Peter Miron
4829592107 removed support for array of Advertise addresses. Added support for Route advertise address. 2017-11-29 11:41:08 -05:00
Peter Miron
7d34b890c6 Takes list of client connect addresses. Uses the first as the host / port sent on info. 2017-11-28 09:55:35 -05:00
Ivan Kozlovic
b002db4a1c Merge pull request #606 from nats-io/always_send_info
[CHANGED] Server notifies clients when server rejoins cluster
2017-11-27 13:37:21 -07:00
Peter Miron
6852298e7b draft of fix for issue #447. allows advertising separate host:ports to client. 2017-11-27 15:34:15 -05:00
Ivan Kozlovic
cde2aa6d2f Merge pull request #604 from nats-io/fix_connz_tls_handshake
[FIXED] Connz would "block" for TLS clients still in TLS handshake
2017-11-17 12:31:58 -07:00
Ivan Kozlovic
fa86ff93eb [CHANGED] Server notifies clients when server rejoins cluster
When the option Cluster.NoAdvertise is false, a server will send
an INFO protocol message to its client when a server has joined
the cluster.

Previously, the protocol would be sent only if the
joining server's "client URLs" (the addresses where clients connect
to) were new. It will now be sent regardless if the server joins
(for the first time) or rejoins the cluster.

Clients are still by default invoking the DiscoveredServersCB callback
only if they themselves detect that new URLs were added. A separate
PR may be filled to client libraries repo to be able to invoke
the callback anytime an async INFO protocol is received.

Based on @madgrenadier PR #597.
2017-11-17 12:21:34 -07:00
Ivan Kozlovic
6fad293a21 [FIXED] Connz would "block" for TLS clients still in TLS handshake
If server requires TLS and clients are connecting, and a Connz
request is made while clients are still in TLS Handshake, the
call to tls.Conn.ConnectionState() would block for the duration
of the handshake. This would cause the overall http request to
take too long.
We will now not try to gather TLSVersion and TLSCipher from a
client that is still in TLS handshake.

Resolves #600
2017-11-09 09:47:05 -07:00
Ivan Kozlovic
22cff99e58 [Fixed] Profiling and Monitoring timeout issues
The http servers for those two were recently modified to set
a ReadTimeout and WriteTimeout. The WriteTimeout specifically
caused issues for Profiling since it is common to ask sampling
of several seconds. Pprof code would reject the request if it
detected that http server's WriteTimeout was more than sampling
in request.
For monitoring, any situation that would cause the monitoring code
to take more than 2 seconds to gather information (could be due
to locking, amount of objects to return, time required for sorting,
etc..) would also cause cURL to return empty response or WebBrowser
to fail to display the page.

Resolves #600
2017-11-08 14:58:10 -07:00
Ivan Kozlovic
d4695d5e99 [FIXED] Name of selected new cipher suites
Use a map by id to return name of all supported ciphers. Use that
name to display the cipher name on handshake completion.

Resolves #591
2017-09-25 10:56:36 -06:00
Tyler Treat
4a6fd4317a Change client Accept error log level
This is an error users should know about. Thus, the log level should be
error.

Fixes #583
2017-09-11 09:14:10 -05:00
Ivan Kozlovic
379a14b8cc [FIXED] Override from command line not always working
There were some cases where override would not work. Any command
line parameter that would be set to the type default value (false
for boolean, "" for string, etc) would not be taken into account.

I moved all the flags parsing and options configuration into
a new function, which may help reduce code duplication in
NATS Streaming.

The other advantage of moving this in a function is that it
can now be unit tested.

I am also removing call to `RemoveSelfReference()` which attempted
to remove a route to self, which has been already solved at runtime
with detecting and ignoring a route to self.

This function would be invoked only when routes were defined in
the configuration file, not in the command line parameter.

Removing this call also solves an user issue (#577)

Resolves #574
Resolves #577
2017-09-06 17:31:53 -06:00
Ivan Kozlovic
20926a6176 Added megacheck
This tool combines staticcheck, gosimple and unused.
Fixed reports from unused.
2017-08-11 17:28:18 -06:00
Ivan Kozlovic
2befd973cc Fixed DATA RACE and ensure route is not created/accepted on shutdown
- Created a setter for the closed flag.
- Check if route is closed under lock and set a boolean if so,
  so we don't check c.route outside of c's mutex.
- Ensure that we do not create a route on shutdown, which would
  leave a connection hanging (was seen in some config reload tests).
2017-07-19 10:42:18 -06:00
Tyler Treat
2ed9c64f66 Merge branch 'master' of github.com:nats-io/gnatsd into enable_config_reload 2017-06-28 14:42:11 -05:00
Tyler Treat
901a5c7122 Address CR feedback 2017-06-28 11:05:02 -05:00
Tyler Treat
dd3ad77ea8 Replace reloaded varz field with config_load_time 2017-06-27 14:33:06 -05:00
Tyler Treat
9adfae11a2 Add reload count to server for monitoring 2017-06-23 10:03:01 -05:00
Tyler Treat
d60085d7c3 Replace mpay locking with atomic 2017-06-22 16:17:31 -05:00
Tyler Treat
b898b5561a Add reload support for pid_file, max_control_line, and max_payload 2017-06-22 14:48:40 -05:00
Tyler Treat
56ab619498 First pass at implementing cluster reload 2017-06-16 15:53:07 -05:00
Peter Miron
00744ff426 converted MonitorAddr and ClusterAddr to *net.TCPAddr 2017-06-12 17:40:36 -04:00
Peter Miron
606502091c Updated based on @tylertreat feedback. 2017-06-12 10:48:30 -04:00
Peter Miron
5e640f099d clean up of log files. removed FatalError function to make sure I'm minimizing changes to actual server. 2017-06-11 16:20:04 -04:00
Peter Miron
da1cb9abb2 missed go fmt'ing. 2017-06-10 10:39:09 -04:00
Peter Miron
d1f38f38a2 changes to support random ports for clusters and profiler. 2017-06-10 10:35:01 -04:00
Peter Miron
f2a9cc8cb0 fixed go fmt'ing 2017-06-08 11:37:23 -04:00