Skip to content
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

Merged

Conversation

geichelberger
Copy link
Contributor

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)

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 <gregor.eichelberger@tuwien.ac.at>
Copy link
Member

@Luap99 Luap99 left a 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.

@@ -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" {
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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

Signed-off-by: Gregor Eichelberger <gregor.eichelberger@tuwien.ac.at>
@geichelberger
Copy link
Contributor Author

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.

https://github.com/containers/common/blob/f9277d700f76b581c7538cd36b44c3846dae9add/libnetwork/etchosts/hosts.go#L120C1-L123C3

Should I move the section to parseExtraHosts?

@Luap99
Copy link
Member

Luap99 commented Jul 10, 2023

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.

https://github.com/containers/common/blob/f9277d700f76b581c7538cd36b44c3846dae9add/libnetwork/etchosts/hosts.go#L120C1-L123C3

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()

@rhatdan
Copy link
Member

rhatdan commented Jul 14, 2023

@geichelberger Still working on this?

@rhatdan
Copy link
Member

rhatdan commented Jul 17, 2023

@Luap99 PTAL

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@geichelberger
Copy link
Contributor Author

Should the default host.container.internal entry still be omitted?

@Luap99
Copy link
Member

Luap99 commented Jul 17, 2023

Should the default host.container.internal entry still be omitted?

What do you think? I can live with both behaviors and do not have a real preference.

@geichelberger
Copy link
Contributor Author

I don't know if a user would expect that behavior.

Comment on lines 247 to 248
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)
Copy link
Member

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 <gregor.eichelberger@tuwien.ac.at>
Copy link
Member

@Luap99 Luap99 left a 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

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 19, 2023

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants