-
Notifications
You must be signed in to change notification settings - Fork 251
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
Weights support in Synapse #179
Open
scarletmeow
wants to merge
4
commits into
airbnb:master
Choose a base branch
from
scarletmeow:safe-weights
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
44b7ae9
Create an option to stop ignoring weights. By default weights will still
minkovich 2e0c6f2
Changes position of weight in HAProxy backend line, prevents two node…
minkovich 6d9b95a
Remove option ignore_weights so weights will be used by default and c…
minkovich 42c4d48
Restart haproxy if backend 'weights' setting is changed
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -714,6 +714,11 @@ def generate_backend_stanza(watcher, config) | |
log.info "synapse: restart required because haproxy_server_options changed for #{backend_name}" | ||
@restart_required = true | ||
end | ||
if (old_backend.fetch('weight', "") != | ||
backend.fetch('weight', "")) | ||
log.info "synapse: restart required because weight changed for #{backend_name}" | ||
@restart_required = true | ||
end | ||
end | ||
backends[backend_name] = backend.merge('enabled' => true) | ||
end | ||
|
@@ -748,6 +753,17 @@ def generate_backend_stanza(watcher, config) | |
end | ||
end | ||
b = "#{b} #{watcher.haproxy['server_options']}" if watcher.haproxy['server_options'] | ||
if backend.has_key?('weight') | ||
# Check if server_options/haproxy_server_options already contains weight, if so log a warning | ||
if watcher.haproxy.fetch('server_options', '').include? 'weight' | ||
log.warn "synapse: weight is defined in both server_options and nerve. nerve weight takes precedence" | ||
end | ||
if backend['haproxy_server_options'] and backend['haproxy_server_options'].include? 'weight' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately, due to how the parsing logic in ServiceWatcher works today, |
||
log.warn "synapse: weight is defined in both haproxy_server_options and nerve. nerve weight takes precedence" | ||
end | ||
weight = backend['weight'].to_i | ||
b = "#{b} weight #{weight}" | ||
end | ||
b = "#{b} #{backend['haproxy_server_options']}" if backend['haproxy_server_options'] | ||
b = "#{b} disabled" unless backend['enabled'] | ||
b } | ||
|
This file contains 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
This file contains 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
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.
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.
so, it looks like this section of code is only invoked if the state file is enabled. i think this needs a little re-thinking...
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.
We detect a restart as long as the output config file is different: https://github.com/airbnb/synapse/blob/master/lib/synapse/haproxy.rb#L844. So you're right to point out this block of code as being out-of-place. I'm writing some tests to see if we even need any of the logic here.