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

stage_executor: inline --network add default string #4659

Merged
merged 1 commit into from
Apr 5, 2023

Conversation

flouthoc
Copy link
Collaborator

Inline RUN --network=default should do nothing. This matches buildkit's behaviour here: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#run---networkdefault

Also added to podman's document here: containers/common#1366

What type of PR is this?

/kind api-change
/kind bug
/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind other

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

stage_executor: inline `--network` add `default` string

@flouthoc
Copy link
Collaborator Author

@nalind @rhatdan @giuseppe @vrothberg @containers/buildah-maintainers 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

tests/bud/inline-network/Dockerfile4 Outdated Show resolved Hide resolved
@TomSweeneyRedHat
Copy link
Member

LGTM
but please do clean up that blank line that @vrothberg spotted.

@flouthoc flouthoc force-pushed the run-network branch 2 times, most recently from c7eaa9f to ddd3c67 Compare March 16, 2023 04:32
@flouthoc
Copy link
Collaborator Author

@TomSweeneyRedHat @vrothberg done.

@flouthoc flouthoc requested a review from vrothberg March 16, 2023 05:35
Copy link
Member

@giuseppe giuseppe 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 Mar 16, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, giuseppe

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

tests/bud.bats Outdated Show resolved Hide resolved
tests/bud.bats Outdated
@@ -43,6 +43,13 @@ load helpers
expect_output --substring "unsupported value"
}

@test "build with inline RUN --network=default" {
run_buildah build --network=host $WITH_POLICY_JSON -t source -f $BUDFILES/inline-network/Dockerfile4
build1="$output"
Copy link
Member

Choose a reason for hiding this comment

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

This should be the same as the network namespace that this test itself is running in.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

tests/bud.bats Outdated
run_buildah build --network=host $WITH_POLICY_JSON -t source -f $BUDFILES/inline-network/Dockerfile4
build1="$output"
run_buildah build --network=private $WITH_POLICY_JSON -t source -f $BUDFILES/inline-network/Dockerfile4
assert "$output" !~ "$build1"
Copy link
Member

Choose a reason for hiding this comment

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

... and running with --network=private should get a result that's both different from the --network=host test and the previous --network=private, unless I'm mistaken.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did you mean different with the previous --network=host and another --network=private ? Yes I think two different builds should have different namespaces.

I can add two builds with --network=private and compare them if you mean that.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's what I was suggesting, since we're creating a new network namespace each time.

Copy link
Member

Choose a reason for hiding this comment

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

This assert probably needs to be changed - it's comparing the entire output from the previous build to the entire output of this one. Since we're not caching, I'd expect to get different image IDs in those outputs, at least.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems buildah re-uses private namespace and only assigns new private namespace when other one is occupied, so this happens only when two private builds are parallel otherwise consecutive private build ends up getting same private namespace.

Copy link
Member

Choose a reason for hiding this comment

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

That's surprising to me, but I'm seeing it when I run unshare -Urnmpf readlink /proc/self/ns/net twice in succession, so the takeaway is that it's something the kernel's doing, and I was wrong to think that they'd be different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah i see its the kernel, anyways I have dropped this part from the test, only comparing a host and private ns build.

@TomSweeneyRedHat
Copy link
Member

@flouthoc needs a rebase and it looks like the tests are still barking.

@TomSweeneyRedHat
Copy link
Member

@flouthoc the tests are still spitting up a bit.

@flouthoc
Copy link
Collaborator Author

@TomSweeneyRedHat Looks like a flake i have restarted.

tests/bud.bats Outdated Show resolved Hide resolved
tests/bud.bats Show resolved Hide resolved
Inline `RUN --network=default` should do nothing. This matches
buildkit's behaviour here: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/reference.md#run---networkdefault

Also added to podman's document here: containers/common#1366

Signed-off-by: Aditya R <arajan@redhat.com>
@flouthoc
Copy link
Collaborator Author

flouthoc commented Apr 5, 2023

@nalind @TomSweeneyRedHat @rhatdan PTAL

@nalind
Copy link
Member

nalind commented Apr 5, 2023

LGTM, give or take a rebase.

@rhatdan
Copy link
Member

rhatdan commented Apr 5, 2023

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Apr 5, 2023
@rhatdan rhatdan merged commit fc7916d into containers:main Apr 5, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants