-
Notifications
You must be signed in to change notification settings - Fork 202
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
libnetwork: Add support for host-gatway #1549
libnetwork: Add support for host-gatway #1549
Conversation
This change adds support for the special IP designator `host-gateway` to the etchosts package. The first part of fixing containers/podman#14390 Signed-off-by: Gregor Eichelberger <[email protected]>
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.
Thanks for the PR.
Should we really also add the host.containers.internal
entry even if a user requested a custom one? I think it is better to just omit it our default entry in this case.
libnetwork/etchosts/hosts.go
Outdated
@@ -243,7 +243,11 @@ func parseExtraHosts(extraHosts []string) (HostEntries, error) { | |||
if values[1] == "" { | |||
return nil, fmt.Errorf("IP address in host entry %q is empty", entry) | |||
} | |||
e := HostEntry{IP: values[1], Names: []string{values[0]}} | |||
ip := values[1] | |||
if values[1] == "host-gateway" { |
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.
Please split out host-gateway to a const at the top of the file and export it (starts with upper case)
Then you can just import than one in podman and we do not define the same string twice.
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 just recognized that HostContainersInternalIP is optional. Skipping the entry like the host.containers.internal
one will be unexpected, and I should return an error. What do you think?
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.
returning an error sounds good
f9a4067
to
e65f73d
Compare
Signed-off-by: Gregor Eichelberger <[email protected]>
e65f73d
to
870255d
Compare
Should I move the section to parseExtraHosts? |
I don't think so, that could cause regressions. The order is important, see the difference in userEntries and containerIPs in writeHosts() |
@geichelberger Still working on this? |
0bdcead
to
2b301aa
Compare
@Luap99 PTAL |
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
Should the default |
What do you think? I can live with both behaviors and do not have a real preference. |
I don't know if a user would expect that behavior. |
libnetwork/etchosts/hosts.go
Outdated
if values[1] == HostGateway && hostContainersInternalIP == "" { | ||
return nil, fmt.Errorf("unable to replace %q of host entry %q: host containers internal IP address is empty", HostGateway, entry) |
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.
sorry I just took another look, can you move this into the if values[1] == HostGateway {
branch below. There is no reason to check the same condition twice.
Signed-off-by: Gregor Eichelberger <[email protected]>
2b301aa
to
9d93afa
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
@vrothberg @rhatdan PTAL
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: geichelberger, Luap99, vrothberg 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 |
This change adds support for the special IP designator
host-gateway
to the etchosts package.The first part of fixing containers/podman#14390 as mentioned in containers/podman#14392 (review)