Commit Graph

97 Commits

Author SHA1 Message Date
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
Alberto Ricart
456c09855e fmt 2018-07-02 15:50:03 -05: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
Alberto Ricart
c35607cd95 [ADD] internal option to write a ports file --ports_file_dir
The added option writes a file in the specified directory called <exename>_<pid>.ports which
contains a JSON representation of ports that the gnatsd has opened.

This change is intended to facilitate testing by having ports be specified with a -1, so
they are auto assigned and allow tests to locate and connect to the launched gnatsd(s).
2018-06-22 16:15:39 -05: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
Ivan Kozlovic
b0ebdbed7d Fixed typo 2018-04-09 09:14:21 -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
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
acf4a31e4b Major updates + support for config reload of client/cluster advertise 2018-02-05 20:15:36 -07: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
032b0b4cd7 Address CR feedback 2017-06-27 16:53:18 -05:00
Tyler Treat
84d00a0395 Add comment about random map iteration 2017-06-27 16:09:14 -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
a0f32a156d Fix grammatical mistake in docstring 2017-06-22 17:03:59 -05:00
Tyler Treat
88c864b2af Add reload support for ping interval, max pings, and write deadline 2017-06-22 17:01:56 -05:00
Tyler Treat
5501e288a8 Support syslog config reload 2017-06-22 16:33:33 -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
11c2720e0e Add support for reloading max_connections 2017-06-22 12:59:54 -05:00
Tyler Treat
8f5aa0433d Add support for reloading logtime and log_file 2017-06-22 12:59:13 -05:00
Tyler Treat
06d9aa7739 Fix race condition 2017-06-19 15:14:31 -05:00
Tyler Treat
564f498fe8 Add config reload TODO 2017-06-19 14:32:26 -05:00
Tyler Treat
c97a4f6e45 Ignore NoLog option in config reload 2017-06-19 14:17:58 -05:00
Tyler Treat
50e9d0fa87 Close unauthorized routes when authorization changes 2017-06-16 16:45:59 -05:00
Tyler Treat
56ab619498 First pass at implementing cluster reload 2017-06-16 15:53:07 -05:00
Tyler Treat
1e964e4aab Address CR feedback 2017-06-14 16:48:11 -05:00
Tyler Treat
e4ccaa25bd Remove unused switch case 2017-06-14 12:09:01 -05:00
Tyler Treat
ac04d555f2 Merge branch 'master' of github.com:nats-io/gnatsd into users_reload 2017-06-14 09:28:18 -05:00
Tyler Treat
44966230db Handle permissions changes on config reload 2017-06-13 16:04:38 -05:00
Tyler Treat
fa12181094 Add support for reloading users credentials 2017-06-12 13:17:30 -05:00
Tyler Treat
d11a3979fc Log changes to AuthTimeout and TLSTimeout 2017-06-12 12:13:32 -05:00
Tyler Treat
9ba55f0f21 Add support for reloading single-user and token authentication 2017-06-12 11:52:11 -05:00
Peter Miron
d1f38f38a2 changes to support random ports for clusters and profiler. 2017-06-10 10:35:01 -04:00
Tyler Treat
4c33177bd3 Bump up TLS timeout in test configs 2017-06-07 18:05:28 -05:00
Tyler Treat
d172ca5801 Add unit tests around TLS config reload 2017-06-07 16:34:39 -05:00
Tyler Treat
b7211f6dc8 Improve readability of TLSVerify assignment 2017-06-07 14:58:30 -05:00
Tyler Treat
b70e2c2fc2 Implement config reload support for TLS
Allows reloading TLS config. This includes enabling/disabling TLS,
rotating keys/certs, enabling/disabling client verification, etc.
2017-06-07 12:25:56 -05:00
Tyler Treat
687a20be1c Implement config reload support for debug
Add config reload support for `debug` option.
2017-06-06 11:30:06 -05:00
Tyler Treat
cc30af8ede Address code review feedback 2017-06-05 17:43:42 -05:00
Tyler Treat
c468abd15f Merge branch 'master' of github.com:nats-io/gnatsd into config_reload 2017-06-05 13:41:04 -05:00
Tyler Treat
677ff0aae0 Rename opts to diffOpts in diffOptions for clarity 2017-06-01 14:22:41 -05:00
Tyler Treat
9902c3da84 First pass at implementing config reload 2017-05-30 16:18:36 -05:00