-
Notifications
You must be signed in to change notification settings - Fork 123
Do a soft reload of haproxy #212
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -64,25 +64,34 @@ func (p *HAProxyLoadBalancer) Template() string { | |
| } | ||
|
|
||
| func (p *HAProxyLoadBalancer) Reload(proxyContainers []types.Container) error { | ||
| // drop SYN to allow for restarts | ||
| if err := p.dropSYN(); err != nil { | ||
| log().Warnf("error signaling clients to resend; you will notice dropped packets: %s", err) | ||
| } | ||
|
|
||
| // reload all interlock managed haproxy containers | ||
| for _, cnt := range proxyContainers { | ||
| // restart | ||
| log().Debugf("restarting proxy container: id=%s", cnt.ID) | ||
| d := time.Millisecond * 1000 | ||
| if err := p.client.ContainerRestart(context.Background(), cnt.ID, &d); err != nil { | ||
| log().Errorf("error restarting container: id=%s err=%s", cnt.ID[:12], err) | ||
| // update the proxy container status | ||
| cInfo, err := p.client.ContainerInspect(context.Background(), cnt.ID) | ||
| if err != nil { | ||
| log().Errorf("unable to inspect proxy container: %s", err) | ||
| continue | ||
| } | ||
| switch cInfo.State.Status { | ||
| case "exited": | ||
| log().Infof("restarting proxy container: id=%s", cnt.ID) | ||
| d := time.Millisecond * 1000 | ||
| if err := p.client.ContainerRestart(context.Background(), cnt.ID, &d); err != nil { | ||
| log().Errorf("error restarting container: id=%s err=%s", cnt.ID[:12], err) | ||
| continue | ||
| } | ||
| case "running": | ||
| log().Debugf("reloading proxy container: id=%s", cnt.ID) | ||
|
Owner
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. This is needed to safely reload (see above comment). |
||
| if err := p.client.ContainerKill(context.Background(), cnt.ID, "HUP"); err != nil { | ||
|
Owner
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. Are you sure HAProxy handles this properly? I believe we've tried
Owner
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. That being said, if we can test it I would love to get rid of the TCP hacks. :)
Author
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. Pretty sure it is stable in v1.7.x. I have been using it (outside of interlock) for a while. |
||
| log().Errorf("error reloading container: id=%s err=%s", cnt.ID[:12], err) | ||
| continue | ||
| } | ||
|
Owner
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. Are you sure this catches all cases? A
Author
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. I will add it and update the PR. |
||
| default: | ||
| log().Infof("haproxy container id=%s name=%s in state %s", cnt.ID[:12], cnt.Names[0], cInfo.State.Status) | ||
| continue | ||
| } | ||
|
|
||
| log().Infof("restarted proxy container: id=%s name=%s", cnt.ID[:12], cnt.Names[0]) | ||
| } | ||
|
|
||
| if err := p.resumeSYN(); err != nil { | ||
| log().Warnf("error signaling clients to resume; you will notice dropped packets: %s", err) | ||
| log().Infof("reloaded proxy container: id=%s name=%s", cnt.ID[:12], cnt.Names[0]) | ||
| } | ||
|
|
||
| return nil | ||
|
|
||
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.
This will fall through without a
continue.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.
The continue is there.
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.
Ah I didn't see it from the diff. 👍