-
-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Allowed specifying additional options for InfluxDB backend (UDP) #458 #472
Conversation
I have found some caveats with using UDP for writing data to the InfluxDB:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have mixed feelings about this, I do not feel comfortable in merging such a change while ignoring the test failures. See below.
I think the results which are coming out of the tests are encouraging on the perfomance side, but on the functionality side there's more work to do to merge this safely.
tests/openwisp2/settings.py
Outdated
@@ -28,7 +28,15 @@ | |||
'NAME': 'openwisp2', | |||
'HOST': os.getenv('INFLUXDB_HOST', 'localhost'), | |||
'PORT': '8086', | |||
'OPTIONS': {'use_udp': True, 'udp_port': 8088}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should switch to use UDP by default yet because this will add friction and impredictable consequences right now:
-
The fact that we cannot run tests against the UDP mode worries me, what if there's some critical part of the system which will not work as expected in this mode? How will we find out? It seems to me that this is the case, how are you sure that alert settings and thresholds are working fine in this mode?
-
The newcomers who do not use docker and will want to test out this module will have to enable UDP in their influxdb instance, most likely they will come to the support chats to complain about this.
I think we shoud run both the app and the tests in HTTP mode but we could run a subsets of the tests in UDP mode just to make sure we have some automated tests using the UDP functionality and confirming is working as expected.
I just tried the following configuration and I was able to run a subset of the tests with only a few failures after adding a sleep of 0.1 in the timeseries_write celery task:
[[udp]]
enabled = true
database = "openwisp2_test"
batch-size = 1
batch-pending = 1
batch-timeout = "0.1s"
A possible subsets of the test to run is the following, please double check my suggestion to see if there's anything critical regarding the interaction with the timeseries DB to add:
./manage.py test openwisp_monitoring.device.tests.test_api openwisp_monitoring.device.tests.test_models openwisp_monitoring.monitoring.tests.test_monitoring_notifications openwisp_monitoring.monitoring.tests.test_db_creation openwisp_monitoring.monitoring.tests.test_models openwisp_monitoring.check.tests.test_ping openwisp_monitoring.check.tests.test_models
The main problem is that the logic which performs the check of thresholds and alert settings relies on the fact that the data is written immediately, so we have to look into ways to work around that.
022244a
to
977144f
Compare
@@ -127,10 +128,12 @@ def test_general_check_threshold_crossed_for_long_time(self): | |||
self.assertEqual(m.is_healthy_tolerant, True) | |||
self.assertEqual(Notification.objects.count(), 0) | |||
|
|||
time.sleep(0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure this sleep is executed only when in UDP mode and use the function mentioned above
3198e37
to
a2ce4cb
Compare
tests/openwisp2/settings.py
Outdated
@@ -31,7 +31,10 @@ | |||
'OPTIONS': {'udp_writes': True, 'udp_port': 8089}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not default to UDP as that will cause issues with new developers trying this module out. Default on TCP and enable UDP in the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update the docs where it mentions the various timeseries retry options to make it explicit that it doesn't apply when using UDP mode.
I also see no mention of this new feature in the README and that's not good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's test this more before merging.
cfade98
to
21f084d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok great one docs change requested below.
enabled = true | ||
bind-address = "127.0.0.1:8090" | ||
database = "openwisp2" | ||
retention-policy = 'short' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention that when using ansible-openwisp2 this can be done easily by setting the new var addded in openwisp/ansible-ow-influxdb#17 to true
and link the role variables section of the ansible-ow-influxdb repo for reference.
This should help users figure out how to use this feature autonomously.
…458 - Additional options can be specified to the TIMESERIES_DATABASE setting which are passed to the underlying backend library. This allows using UDP for writing to InfluxDB. - "openwisp_monitoring.db.backends.influxdb.client.DatabaseClient.write" will use "InfluxDBClient.write_points" instead of "InfluxDBClient.write" because the former allows writing data using the UDP protocol. Closes #458
ece7394
to
fa195eb
Compare
e4b34d4
to
3f6e529
Compare
Closes #458
Checks: