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

ConfigWatch not triggered when a key is deleted #780

Closed
DanielYWoo opened this issue May 18, 2022 · 1 comment
Closed

ConfigWatch not triggered when a key is deleted #780

DanielYWoo opened this issue May 18, 2022 · 1 comment

Comments

@DanielYWoo
Copy link

DanielYWoo commented May 18, 2022

Describe the bug
Adding/changing a key triggers refreshing values for Environment and @value. But deleting a key does not. This is a strange behavior. e.g., you have two paths to watch in Consul: /default/config and /my-service/config, if I add a key to my-service/config I can override the default settings in /default/config, but when I delete the key, nothing happens and I have to restart my app.

Moreover, when I delete a key, in ConfigWatch.watchConfigKeyValues(), the index will stop increasing. Suppose you get an index 16866 previously, then for the deletion event we should increase the current index to the new index in the response, maybe 16914. Currently the watch just stops at 16866 and retry and retry over again. If you set timeout shorter to 3 second you will see this busy loop behavior from log. Without increasing the index, it's a little less efficient and we will waste some resources.

I think the problem is, when 404 with a higher index is returned, it means the key was deleted, and we should publish the RefreshEvent and increase the index. Then the spring config framework should listen to the event and change accordingly, maybe delete the key from ConsulPropertySource.

Sample
N/A

PR: #781

@spencergibb
Copy link
Member

Duplicates #740

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

No branches or pull requests

3 participants