-
Notifications
You must be signed in to change notification settings - Fork 13
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 reading api-address from config file in container #874
Conversation
Always configure API server, start listener only if address is specified.
@@ -2,6 +2,8 @@ ARG BASE_IMAGE=gcr.io/distroless/static:nonroot | |||
|
|||
FROM ${BASE_IMAGE} | |||
|
|||
ENV PLATFORM=container |
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.
How about FORWARDER_PLATFORM
? Something to make it difficult to overwrite.
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 don't know, the FORWARDER_PLATFORM
does not make much sense to me.
We have two situations:
- The
PLATFORM
env var gets overwritten by hand when running container - for that we could log warning in the readiness check. - Our container behavior kicking in in another setting due to presence of the env var - here I think we are good since we must match both key and value (container)
Let me add some more logging 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.
I considered adding sth like this
if p := os.Getenv("PLATFORM"); p != "" {
if p == "container" {
c.apiAddr = "unix:" + cfg.APIUnixSocket
} else {
fmt.Fprintf(os.Stderr, "unexpected PLATFORM environment variable: %q\n", p)
}
}
But I guess it's not really useful.
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.
Ugly^
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.
Maybe I'm exaggerating, why would somebody add PLATFORM variable to forwarder container.
utils/httpx/httpx.go
Outdated
s.Close() | ||
}() | ||
|
||
return s.Serve(l) |
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.
It returns an error on server close
^C2024/08/01 08:12:27.518332 [ERROR] fatal error exiting: http: Server closed
exit status 1
"time" | ||
) | ||
|
||
func ServeUnixSocket(ctx context.Context, h http.Handler, socketPath string) error { |
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.
May we add some logging here?
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.
Any logging should go in handler as this is a helper function.
f6db10e
to
f3677ec
Compare
Add Config type and allow external configuration for better reuse. Use request timeout when sending readiness request. Support using Unix sockets as transport.
f3677ec
to
ee6be19
Compare
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.
LGTM
This patchset implements checking readiness over a Unix socket.
Unnecessary API servers in e2e tests are removed.
The ready command implementation is extended and improved for better reuse.
Fixes #873