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

always add short container id as net alias #11751

Merged
merged 3 commits into from
Sep 28, 2021

Conversation

Luap99
Copy link
Member

@Luap99 Luap99 commented Sep 27, 2021

This matches what docker does. Also make sure the net aliases are also
shown when the container is stopped.

docker-compose uses this special alias entry to check if it is already
correctly connected to the network. [1]
Because we do not support static ips on network connect at the moment
calling disconnect && connect will loose the static ip.

Fixes #11748

[1] https://github.com/docker/compose/blob/0bea52b18dda3de8c28fcfb0c80cc08b8950645e/compose/service.py#L663-L667

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 27, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Luap99

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 27, 2021
@Luap99
Copy link
Member Author

Luap99 commented Sep 27, 2021

@baude @mheon 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
@mheon PTAL

@Luap99
Copy link
Member Author

Luap99 commented Sep 27, 2021

I reworked the logic. Instead of adding the ID to the DB I will just append it to the aliases when they are queried . This is better because we do not have to create the buckets if they are no extra aliases. I also moved network aliases validation to container create instead of the network backend. Otherwise we could make old containers with aliases non functional.

@TomSweeneyRedHat
Copy link
Member

@Luap99 all kinds of test unhappiness @Luap99

@Luap99 Luap99 force-pushed the net-alias branch 2 times, most recently from afc6e0d to 98eb456 Compare September 27, 2021 16:34
@rhatdan
Copy link
Member

rhatdan commented Sep 27, 2021

/lgtm
/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2021
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 27, 2021
@Luap99
Copy link
Member Author

Luap99 commented Sep 28, 2021

@edsantiago PTAL at the system test error

# #/vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# #|     FAIL: short container id in network aliases
# #| expected: '[19e84a88e6f0]'
# #|   actual: '[19e84a88e6f0]'
# #\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I don't understand what's wrong with that?

@edsantiago
Copy link
Member

The brackets. The way the is function is coded, it accepts character classes and patterns, so [xyz] means 'x, y, or z`. Can you get rid of the brackets in the output?

@@ -415,6 +415,10 @@ load helpers
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
mac="$output"

# check network alias for container short id
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").Aliases}}"
is "$output" "[${cid:0:12}]" "short container id in network aliases"
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, try \\[...\\] (double backslashes). Or maybe single backslashes, or maybe triple.

Copy link
Member Author

Choose a reason for hiding this comment

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

A single backslash worked

This matches what docker does. Also make sure the net aliases are also
shown when the container is stopped.

docker-compose uses this special alias entry to check if it is already
correctly connected to the network. [1]
Because we do not support static ips on network connect at the moment
calling disconnect && connect will loose the static ip.

Fixes containers#11748

[1] https://github.com/docker/compose/blob/0bea52b18dda3de8c28fcfb0c80cc08b8950645e/compose/service.py#L663-L667

Signed-off-by: Paul Holzinger <[email protected]>
Podman 4.0 currently errors when you use network aliases for a network which
has dns disabled. Because the error happens on network setup this can
cause regression for old working containers. The network backend should not
validate this. Instead podman should check this at container create time
and also for network connect.

Signed-off-by: Paul Holzinger <[email protected]>
@openshift-ci openshift-ci bot removed the lgtm Indicates that a PR is ready to be merged. label Sep 28, 2021
@Luap99
Copy link
Member Author

Luap99 commented Sep 28, 2021

@edsantiago Can I recommend changing the error output from is. Something like expected (regex)

@edsantiago
Copy link
Member

That whole function needs serious cleanup, and one of the first priorities is to actually try a simple = before expr. I think I'll tackle that right now.

@mheon
Copy link
Member

mheon commented Sep 28, 2021

LGTM.

@rhatdan
Copy link
Member

rhatdan commented Sep 28, 2021

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 28, 2021
@rhatdan
Copy link
Member

rhatdan commented Sep 28, 2021

/hold cancel
Lets cleanup the tests in other PR.

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 28, 2021
@openshift-merge-robot openshift-merge-robot merged commit 2d22d17 into containers:main Sep 28, 2021
@Luap99 Luap99 deleted the net-alias branch September 28, 2021 14:05
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Container wont use static ip if start with docker-compose up without detached
7 participants