Skip to content
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

bug - Component "error" length issue #15918

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

PipoCanaja
Copy link
Contributor

@PipoCanaja PipoCanaja commented Apr 1, 2024

This DB field is limited to 255 chars currently. This PR checks for longer strings to avoid errors.

Next Illuminate\Database\QueryException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'error' at row 1 (Connection: mysql, SQL: update `component` set `error` = Pool Member is Down: /Common/monitor-xxxxxxxxxx-externalws.xxxxxxxxxx.xxxxxxxxxx-reverse_proxy_front_end_https: No successful responses received before deadline. @2024/03/25 13:53:15. /Common/monitor-xxxxxxxxxx-externalws.xxxxxxxxxx.xxxxxxxxxx-reverse_proxy_tcp_5061: No successful responses received before deadline. @2024/03/25 13:53:15. where `id` = 11745) in /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
Stack trace:
#0 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php(783): Illuminate\Database\Connection->runQueryCallback('update `compone...', Array, Object(Closure))
#1 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php(619): Illuminate\Database\Connection->run('update `compone...', Array, Object(Closure))
#2 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Connection.php(552): Illuminate\Database\Connection->affectingStatement('update `compone...', Array)
#3 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3487): Illuminate\Database\Connection->update('update `compone...', Array)
#4 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1060): Illuminate\Database\Query\Builder->update(Array)
#5 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1213): Illuminate\Database\Eloquent\Builder->update(Array)
#6 /opt/librenms/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1130): Illuminate\Database\Eloquent\Model->performUpdate(Object(Illuminate\Database\Eloquent\Builder))
#7 /opt/librenms/LibreNMS/Component.php(244): Illuminate\Database\Eloquent\Model->save()
#8 /opt/librenms/vendor/laravel/framework/src/Illuminate/Collections/Traits/EnumeratesValues.php(240): LibreNMS\Component->LibreNMS\{closure}(Object(App\Models\Component), 453)
#9 /opt/librenms/LibreNMS/Component.php(275): Illuminate\Support\Collection->each(Object(Closure))
#10 /opt/librenms/includes/polling/loadbalancers/f5-ltm.inc.php(214): LibreNMS\Component->setComponentPrefs(566, Array)
#11 /opt/librenms/includes/polling/loadbalancers.inc.php(13): include('/opt/librenms/i...')
#12 /opt/librenms/LibreNMS/Modules/LegacyModule.php(114): include('/opt/librenms/i...')
#13 /opt/librenms/LibreNMS/Poller.php(176): LibreNMS\Modules\LegacyModule->poll(Object(LibreNMS\OS\F5), Object(LibreNMS\Data\Store\Datastore))
#14 /opt/librenms/LibreNMS/Poller.php(103): LibreNMS\Poller->pollModules()
#15 /opt/librenms/app/Console/Commands/DevicePoll.php(45): LibreNMS\Poller->poll()
#16 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): App\Console\Commands\DevicePoll->handle(Object(App\Polling\Measure\MeasurementManager))
#17 /opt/librenms/vendor/laravel/framework/src/Illuminate/Container/Util.php(41): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

DO NOT DELETE THE UNDERLYING TEXT

Please note

Please read this information carefully. You can run ./lnms dev:check to check your code before submitting.

  • Have you followed our code guidelines?
  • If my Pull Request does some changes/fixes/enhancements in the WebUI, I have inserted a screenshot of it.
  • If my Pull Request makes discovery/polling/yaml changes, I have added/updated test data.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

@PipoCanaja PipoCanaja self-assigned this Apr 1, 2024
@Jellyfrog
Copy link
Member

Shouldnt the field be extended instead?

@PipoCanaja
Copy link
Contributor Author

The field contains the vip name that can be almost any length. So extending it will not solve the issue, only make it less frequent. And whatever length we choose, we need to ensure that we don't try any longer string.
I would go with this fix first, and I'll see in our F5 if we need to extend at some point the field.

@@ -229,6 +229,15 @@ public function setComponentPrefs($device_id, $updated)

// update component attributes
$component->fill($update);
// sanity check
if (! is_null($component->error)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might be better to put these in the model as mutators?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good occasion to learn how a mutator works :) just had a look at the doc and it makes sense indeed.
Will send a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants