Fix reading api-address from config file in container#874
Conversation
Always configure API server, start listener only if address is specified.
|
|
||
| FROM ${BASE_IMAGE} | ||
|
|
||
| ENV PLATFORM=container |
There was a problem hiding this comment.
How about FORWARDER_PLATFORM? Something to make it difficult to overwrite.
There was a problem hiding this comment.
I don't know, the FORWARDER_PLATFORM does not make much sense to me.
We have two situations:
- The
PLATFORMenv 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.
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.
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.
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.
May we add some logging here?
There was a problem hiding this comment.
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
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