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

Saving a bad Data Template can damage Data Sources #4480

Closed
TheWitness opened this issue Nov 27, 2021 · 0 comments
Closed

Saving a bad Data Template can damage Data Sources #4480

TheWitness opened this issue Nov 27, 2021 · 0 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@TheWitness
Copy link
Member

Describe the bug

Cacti's Data Templates are very versatile, but there are dark corners that are not well explained or understood that can lead to catastrophic consequences if the author of the Data Template is not aware of them. Cacti should not allow these type of dark corners negatively impact the system as often as possible.

One such case is when you have a Data Template based upon a Data Query. For Data Queries, there are three "Custom Data" fields where the Checkbox to the left of the fields MUST be checked in order to not damage the Data Template. Just about all rookies, and even experts forget to check these checkboxes and as a result, months even years later, they may go back and re-save a Data Template, and damage all of their Graphs and Data Sources using that Data Template.

The same can be said of "Custom Data" using Special Type Codes, from the Device. There is really no case where these Special Type codes should not be applied, so that checkbox to the left of the field should always be checked.

Lastly, when editing a Data Template, a user should be warned that if they uncheck the checkbox, for Data Templates that already have Data Sources, that they may experience data loss.

To Reproduce

Steps to reproduce the behavior:

  1. Create Data Query Graphs from a Data Source

  2. Verify that you have Poller Items for these new Data Sources

  3. Edit the Data Template and Set Input Type, Input Value, Object Type ID checkboxes "off"

  4. Save the Data Template

  5. View the Poller Item again and notice that they have disappeared

Expected behavior

  • Cacti should not allow this negative behavior as much as possible
  • Since the problem can be undone, at least with Data Queries, provide repair tools to correct this problem for legacy templates that are structured well.
@TheWitness TheWitness added the bug Undesired behaviour label Nov 27, 2021
@TheWitness TheWitness added this to the v1.2.20 milestone Nov 27, 2021
TheWitness added a commit that referenced this issue Nov 27, 2021
Saving a Data Template can damage Data Sources if the Data Template is not constructed properly

This is the first of two commit's on this bug.  The second commit will provide a repair during upgrade.
TheWitness added a commit that referenced this issue Nov 27, 2021
Many special type codes can be over wrote in the template, there are a few that should not.  Open those type codes slightly so that they can be over wrote.
TheWitness added a commit that referenced this issue Nov 28, 2021
TheWitness added a commit that referenced this issue Nov 28, 2021
This repair script will fix the Data Queries.  Might drop this into lib/template.php, but keeping it here for now.
TheWitness added a commit that referenced this issue Nov 28, 2021
Broke this in the first commit
TheWitness added a commit that referenced this issue Nov 28, 2021
Make Data Sources "ok" as well as Data Templates
TheWitness added a commit that referenced this issue Nov 28, 2021
This is an additional find that I made.  I've not traced the source, so adding to repair_database.php script as well.
@TheWitness TheWitness added the resolved A fixed issue label Nov 28, 2021
TheWitness added a commit that referenced this issue Dec 10, 2021
TheWitness added a commit that referenced this issue Dec 10, 2021
This case should never happen, but just to be safe.
TheWitness added a commit that referenced this issue Dec 19, 2021
* The host_id is a special case where it should not be check, but it also should should continue to be read only/disabled.  Other host level type codes should be able to be changed at the data source level.
* Change also includes light PSR to remove shortcut syntax when mixed with SQL.
@netniV netniV changed the title Saving a Data Template can damage Data Sources if the Data Template is not constructed properly Saving a bad Data Template can damage Data Sources Apr 3, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Dec 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

1 participant