-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Fix SD mechanism source prefix handling. #1151
Conversation
ch <- tg | ||
// Make a copy of the target group in case the discovery mechanism reuses | ||
// the original object. | ||
ptg := *tg |
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.
At this stage the value could already be modified, no?
Wondering whether we should change the interface to only use values to begin with – or forbid the re-use in the interface contract, i.e. remove it from the Consul implementation.
d0ddf0c
to
60b974e
Compare
@fabxc Changed the PR to do (minimal) depointerization instead and updated the PR/commit descriptions to reflect and explain that. |
94b938c
to
50b552f
Compare
The prefixed target provider changed a pointerized target group that was reused in the wrapped target provider, causing an ever-increasing chain of source prefixes in target groups from the Consul target provider. We now make this bug generally impossible by switching the target group channel from pointer to value type and thus ensuring that target groups are copied before being passed on to other parts of the system. I tried to not let the depointerization leak too far outside of the channel handling (both upstream and downstream) because I tried that initially and caused some nasty bugs, which I want to minimize. Fixes #1083
50b552f
to
d88aea7
Compare
👍 |
@beorn7 and I noticed that this still could cause problems if an SD mechanism mutated the labels map or targets slice included in the copied target group (because no deep copy happens). However, at least in the Consul SD, these fields always get replaced completely rather than being mutated in place. So we should be safe, or at least not more unsafe, for now, with this. |
Fix SD mechanism source prefix handling.
The prefixed target provider changed a pointerized target group that was
reused in the wrapped target provider, causing an ever-increasing chain
of source prefixes in target groups from the Consul target provider.
We now make this bug generally impossible by switching the target group
channel from pointer to value type and thus ensuring that target groups
are copied before being passed on to other parts of the system.
I tried to not let the depointerization leak too far outside of the
channel handling (both upstream and downstream) because I tried that
initially and caused some nasty bugs, which I want to minimize.
Fixes #1083