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

Fix SD mechanism source prefix handling. #1151

Merged
merged 1 commit into from
Oct 9, 2015
Merged

Conversation

juliusv
Copy link
Member

@juliusv juliusv commented Oct 8, 2015

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

@juliusv
Copy link
Member Author

juliusv commented Oct 8, 2015

@fabxc

ch <- tg
// Make a copy of the target group in case the discovery mechanism reuses
// the original object.
ptg := *tg
Copy link
Contributor

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.

@juliusv juliusv force-pushed the fix-sd-source-handling branch 5 times, most recently from d0ddf0c to 60b974e Compare October 9, 2015 12:06
@juliusv
Copy link
Member Author

juliusv commented Oct 9, 2015

@fabxc Changed the PR to do (minimal) depointerization instead and updated the PR/commit descriptions to reflect and explain that.

@juliusv juliusv force-pushed the fix-sd-source-handling branch 2 times, most recently from 94b938c to 50b552f Compare October 9, 2015 12:08
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
@juliusv juliusv force-pushed the fix-sd-source-handling branch from 50b552f to d88aea7 Compare October 9, 2015 12:08
@beorn7
Copy link
Member

beorn7 commented Oct 9, 2015

👍

@juliusv
Copy link
Member Author

juliusv commented Oct 9, 2015

@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.

juliusv added a commit that referenced this pull request Oct 9, 2015
Fix SD mechanism source prefix handling.
@juliusv juliusv merged commit 288964e into master Oct 9, 2015
@juliusv juliusv deleted the fix-sd-source-handling branch October 9, 2015 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

targets defined by consul_sd_config listed multiple times
3 participants