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

Weights support in Synapse #179

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

scarletmeow
Copy link
Contributor

Follow up to #174.

Adds logic to signal HAProxy restart if weight has changed.

Added an additional warning if weights is redefined in haproxy_server_options. I would prefer not to implement behavior that strips out any user-defined weight X statement in HAProxy server options. It seems sufficient to warn about the unexpected behavior in either case.

if watcher.haproxy.fetch('server_options', '').include? 'weight'
log.warn "synapse: weight is defined by server_options and by nerve"
end
if backend['haproxy_server_options'] and backend['haproxy_server_options'].include? 'weight'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, due to how the parsing logic in ServiceWatcher works today, haproxy_server_options always exists as a key in backend and defaults to value nil

@jolynch
Copy link
Collaborator

jolynch commented Apr 23, 2016

👍

Looks good to me, although it looks like travis flaked out?

@jolynch
Copy link
Collaborator

jolynch commented Apr 23, 2016

Also are you going to follow up with live update capability via the stats socket, or do we want to keep punting on that?

@scarletmeow scarletmeow deleted the safe-weights branch May 27, 2016 01:29
@scarletmeow scarletmeow restored the safe-weights branch May 27, 2016 18:15
@scarletmeow scarletmeow reopened this May 27, 2016
@scarletmeow
Copy link
Contributor Author

Gonna keep punting on the live update part for now. I'll be happy being able to merge this PR and close out the outstanding PRs from the two previous attempts at this.

minkovich and others added 4 commits May 27, 2016 11:46
be ignored. This commit is based on:
airbnb#131

but does the following things differently:
1. By default weights are ignored. This is to maintain current behavior
for safety.
2. HAProxy will reconfigure if weights changes.
…s from taking traffic just because they have different weights, add more tests.
@scarletmeow
Copy link
Contributor Author

@jolynch still good to merge this?

@@ -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', "") !=
Copy link
Collaborator

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

Copy link
Contributor Author

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.

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.

4 participants