-
Notifications
You must be signed in to change notification settings - Fork 8.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
Replace Status port using a socket #3684
Conversation
107afcc
to
d637a05
Compare
ff6027f
to
a95213d
Compare
make sense 👍 But I don't see how it's going to fix #3457. That issue seems to be result of Nginx not having enough resources - so this PR will help a bit since it reduces overhead but when the server is under more load the same thing will happen. |
Please check comments after #3457 (comment) For some reason, the health checks start failing without valid reason. If you enter in the container and run |
@aledbf I support switching to using UNIX socket. And this might indeed fix the issue but it also might not. It'd be nice to understand
-- Again, this PR is a right direction! |
Agree. The issue here is that I cannot reproduce this issue and why I am waiting for feedback from #3457. |
9fe173e
to
897439d
Compare
cmd/nginx/flags.go
Outdated
@@ -161,6 +160,7 @@ Feature backed by OpenResty Lua libraries. Requires that OCSP stapling is not en | |||
) | |||
|
|||
flags.MarkDeprecated("sort-backends", "Feature removed because of the lua load balancer that removed the need of reloads for change in endpoints") | |||
flags.MarkDeprecated("status-port", `Status port is a unix socket.`) |
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 also applies to sort-backends
, but why are we marking these flags deprecated when we are removing them? Aren't they either deprecated or removed, but not both?
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.
To avoid breaking existing deployments using the flags. We can remove the flags in 0.24
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.
When 0.22 was released, using --sort-backends
generated an error (unknown flag: --sort-backends
) because the flag was removed. MarkDeprecated doesn't do anything if the flag is removed. See also @ElvinEfendi comment here: #3655 (comment)
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.
fixed.
ControllerPodsCount: pcfg.ControllerPodsCount, | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if statusCode != http.StatusCreated { | ||
return fmt.Errorf("unexpected error code: %d", statusCode) | ||
} |
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.
I wonder why did we not do this before. Also where are you not doing the same above for backends?
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.
check added to backends
18bb412
to
15f56c6
Compare
internal/nginx/main.go
Outdated
|
||
// NewGetStatusRequest creates a new GET request to the internal NGINX status server | ||
func NewGetStatusRequest(path string) (int, []byte, error) { | ||
client := buildUnixSocketClient() |
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.
why do you build the client for every request? why not build it once and use the same client always?
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.
changed
internal/nginx/main.go
Outdated
// StreamSocket defines the location of the unix socket used by NGINX for the NGINX stream configuration socket | ||
var StreamSocket = "/tmp/ingress-stream.sock" | ||
|
||
var nginxUnixLocation = "nginx-status" |
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.
nitpick: statusLocation
probably makes more sense since this is an alias to StatusSocket
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.
done
rootfs/etc/nginx/template/nginx.tmpl
Outdated
listen {{ $all.ListenPorts.Status }} default_server {{ if $all.Cfg.ReusePort }}reuseport{{ end }} backlog={{ $all.BacklogSize }}; | ||
{{ if $IsIPV6Enabled }}listen [::]:{{ $all.ListenPorts.Status }} default_server {{ if $all.Cfg.ReusePort }}reuseport{{ end }} backlog={{ $all.BacklogSize }};{{ end }} | ||
set $proxy_upstream_name "-"; | ||
listen unix:/tmp/nginx-status-server.sock; |
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.
Can you avoid hardcoding this here and use https://github.com/kubernetes/ingress-nginx/pull/3684/files#diff-6c2cb34e0bc02a92a477db1ea8101b69R34 instead?
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.
done
} | ||
|
||
{{ template "CUSTOM_ERRORS" (buildCustomErrorDeps $all.ProxySetHeaders $cfg.CustomHTTPErrors $all.EnableMetrics) }} |
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.
Why are you deleting this now? Why did we even have this here, does not make sense
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.
Why are you deleting this now?
Because before this change we publish the server to port 18080.
Why did we even have this here, does not make sense
Keep in mind we had more content before 0.16 (like vts pages)
/lgtm |
Please don't modify history during review process, makes it hard to review new changes :) |
/lgtm I guess the change was to avoid PID hardcoding. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aledbf, ElvinEfendi The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Sorry about that but I didn't want a new commit just to fix a template in the issue. |
What this PR does / why we need it:
Which issue this PR fixes: fixes #3457
The new status server is configured like this: