KNOX-2844 - Remote config monitor should not automatically delete local files if they're missing from the DB#680
Merged
zeroflag merged 5 commits intoapache:masterfrom Nov 29, 2022
Conversation
…al files if they're missing from the DB
added 3 commits
November 22, 2022 12:00
…al files if they're missing from the DB
…al files if they're missing from the DB
…al files if they're missing from the DB
…al files if they're missing from the DB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
KNOX-2835 introduced an unwanted side effect after enabling the SQL based topology monitor.
The intent of synchronization which was added in KNOX-2835 is:
But what really happens, implementation wise is that:
These two are not exactly the same. If a user creates a descriptor/provider on the file system, it will be deleted by the topology monitor even though it never existed in the DB. The Zookeeper implementation uses onDeleteEvents which are only triggered when something was previously added but later it was deleted. But the SQL based topology uses polling.
So if one enable this feature with an empty DB, all of the descriptors/providers are going to be deleted.
To address this issue, this patch introduces logical deletes. Deleting a descriptor/provider only sets the delete=true column in the DB. The monitor only deletes a local file if a corresponding record exists in the DB and the delete column is set to true. If something never existed in the DB it'll never be deleted.
The logically deleted records are eventually cleared up to.
How was this patch tested?
Tested manually with 3 instances of knox. I created a custom descriptor + provider via the admin UI and checked the file content on each host. I deleted a descriptor/provider and checked if the file disappeared from the hosts. I checked the DB content to see the delete=true flag. I waited until the record was physically deleted.
I checked that existing topologies were not effected by the deletes.