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

fix: trying to bind to an outbound ip returns an empty list of port bindings #533

Merged
merged 4 commits into from
Nov 15, 2024

Conversation

atzoum
Copy link
Contributor

@atzoum atzoum commented Sep 23, 2024

Keep calling docker inspect with a short delay until all port bindings are properly populated.

Related Issue or Design Document

When trying to bind to an outbound interface, the first docker inspect call right after the container has been created doesn't return port bindings properly in the response. This causes an empty host/port to be calculated by the resource.

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact [email protected]) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

if err != nil {
return nil, err
}
const maxRetries = 10
Copy link
Contributor Author

@atzoum atzoum Sep 23, 2024

Choose a reason for hiding this comment

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

Note: you may verify the existence of the bug by setting maxRetries = 0

@atzoum
Copy link
Contributor Author

atzoum commented Oct 10, 2024

@aeneasr can you please review?

go.mod Outdated
@@ -14,7 +14,7 @@ require (
github.com/lib/pq v1.10.9
github.com/moby/term v0.5.0
github.com/opencontainers/image-spec v1.1.0
github.com/opencontainers/runc v1.1.13
github.com/opencontainers/runc v1.1.14
Copy link
Contributor

@alexandear alexandear Oct 15, 2024

Choose a reason for hiding this comment

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

I'm not sure we need upgrading runc version in this PR. It's the work for @dependabot (see #538)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

iirc a check was failing, shall I revert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

The maintainer merges #538 and the fail in this branch will be gone.

dockertest.go Outdated
for _, bindings := range c.NetworkSettings.Ports {
if len(bindings) == 0 {
time.Sleep(100 * time.Millisecond)
return d.inspectContainerWithRetries(id, retry+1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to avoid recursion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@atzoum atzoum requested a review from alexandear October 15, 2024 14:28
@atzoum atzoum force-pushed the fix.publicFacingIP branch from d0e025e to ba3a749 Compare October 15, 2024 14:43
@aeneasr aeneasr enabled auto-merge (squash) November 15, 2024 12:45
@aeneasr aeneasr merged commit f845de5 into ory:v3 Nov 15, 2024
5 checks passed
}(); !hasEmptyPortBindings {
return c, nil
}
retryNum++
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be placed into the for PostStmt.

Created the PR #544 to show this

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

Successfully merging this pull request may close these issues.

3 participants