-
Notifications
You must be signed in to change notification settings - Fork 18
feat(importer): update removed rulebases in db #3894
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
base: importer-rework
Are you sure you want to change the base?
feat(importer): update removed rulebases in db #3894
Conversation
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.
Pull Request Overview
This pull request adds functionality to properly track and mark removed rulebases during configuration imports. Previously, when a rulebase was deleted, it was only being skipped in processing without being explicitly marked as removed in the database.
Key changes:
- Added tracking of removed rulebases by collecting their UIDs when they're not found in the current configuration
- Implemented
mark_rulebases_removed()function to mark deleted rulebases in the database - Updated
remove_outdated_refs()documentation to clarify it handles references for both changed and removed rules
Comments suppressed due to low confidence (2)
roles/importer/files/importer/model_controllers/fwconfig_import_rule.py:131
- Variable num_removed_rulebases is not used.
num_removed_rulebases = self.mark_rulebases_removed(removed_rulebase_uids)
roles/importer/files/importer/model_controllers/fwconfig_import_rule.py:794
- Variable logger is not used.
logger = getFwoLogger()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| num_new_refs = self.add_new_refs(prevConfig) | ||
|
|
||
| num_deleted_rules, removed_rule_ids = self.mark_rules_removed(rule_order_diffs["deleted_rule_uids"]) | ||
| num_removed_rulebases = self.mark_rulebases_removed(removed_rulebase_uids) |
Copilot
AI
Nov 7, 2025
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.
The variable num_removed_rulebases is assigned but never used. Consider adding it to the statistics tracking (similar to how num_deleted_rules is added to RuleDeleteCount on line 140) or logging the count of removed rulebases for visibility.
| return changes, collectedRemovedRuleIds | ||
|
|
||
| def mark_rulebases_removed(self, removedRulebaseUids: list[str]) -> int: | ||
| logger = getFwoLogger() |
Copilot
AI
Nov 7, 2025
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.
The variable logger is declared but never used in this function. Consider removing it or adding appropriate logging statements (e.g., logging when rulebases are successfully marked as removed).
|
|
||
| if len(removedRulebaseUids) == 0: | ||
| return 0 | ||
|
|
Copilot
AI
Nov 7, 2025
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.
Trailing whitespace detected on this line. Please remove it to maintain code cleanliness.
tpurschke
left a comment
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.
Shouldn't we also mark all rules which belong to a removed rulebase as removed?
This is already happening as the ruleorder service detects those rules as changed. Not entirely sure yet how it works but I tested it and it worked. |
|



So far we did not updated removed (e.g. renamed) rulebases in the db, which lead to inconsistencies.
Now rulebases found in the previous config are set to removed if they do not appear in the new normalized config.
This will not fix existing inconsistent database states with rulebases missing the removed field.
see #3892