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

spec: create/own /etc/containers/networks #2265

Merged

Conversation

dustymabe
Copy link
Contributor

In some cases if /etc/ is mounted read-only the non-existence of the /etc/containers/networks directory will cause basic functionality to fail.

bash-5.2# mount --bind -o ro /etc/containers/ /etc/containers/
bash-5.2# podman info
Error: mkdir /etc/containers/networks: read-only file system

Since it's going to get created anyway let's just have the directory exist from the beginning.

@dustymabe dustymabe force-pushed the dusty-rpm-spec-networks branch from 21ec3c5 to aa7bc16 Compare December 5, 2024 17:00
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

dustymabe added a commit to dustymabe/osbuild that referenced this pull request Dec 5, 2024
The org.osbuild.container-deploy stage uses podman. Including it
in the build here will allow that stage to be used with this
pipeline as the buildroot.

Include a workaround here for what I consider to be a bug [1] in that
`podman` will create `/etc/containers/networks` on first run if it
doesn't exist. That dir should just be created by an RPM. If we
don't include this workaround then the stage will fail when `podman`
attempts the `mkdir` because `/etc/containers` is mounted in from
the buildroot readonly.

[1] containers/common#2265
@rhatdan
Copy link
Member

rhatdan commented Dec 5, 2024

You need to create the directory in prep section, I believe.

error: Directory not found: /builddir/build/BUILDROOT/containers-common-0.61.0-1.20241205170236038297.pr2265.37.gaa7bc162.el9.x86_64/etc/containers/networks

In some cases if /etc/ is mounted read-only the non-existence
of the `/etc/containers/networks` directory will cause basic
functionality to fail.

```
bash-5.2# mount --bind -o ro /etc/containers/ /etc/containers/
bash-5.2# podman info
Error: mkdir /etc/containers/networks: read-only file system
```

Since it's going to get created anyway let's just have the
directory exist from the beginning.

Signed-off-by: Dusty Mabe <[email protected]>
@dustymabe dustymabe force-pushed the dusty-rpm-spec-networks branch from aa7bc16 to 9f2002b Compare December 5, 2024 21:26
@dustymabe
Copy link
Contributor Author

Thanks Dan, let's see if the new push makes it happy.

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.

I mean the init logic does try to create the dir but if the dir is read only then creating networks will still fail.

Would it be better if we change the code to only create the dir when we try to write to it (podman network create)? Then we just don't create the dir by default anymore. The original reason why we had to do it was the there was a lockfile in the dir as well that is needed for basically any network operation but that file was long moved to /run/lock/... so I think fixing the code seems better

@dustymabe
Copy link
Contributor Author

so I think fixing the code seems better

that works for me too

@rhatdan
Copy link
Member

rhatdan commented Dec 6, 2024

While fixing the code might be better, it could take a while for a new version of the code to get created, fixing the spec file can happen much more quickly ...

@Luap99
Copy link
Member

Luap99 commented Dec 6, 2024

I can patch this in the code within the next 15 mins if this is a priority for you. Of course the change would only make it into the podman 5.4 release in February. If you need this fix ASAP then I agree fixing the spec upstream/downstream is much quicker.

@dustymabe
Copy link
Contributor Author

The problem I was hitting was an issue with using an OSBuild stage. In OSBuild they bind mount a lot of things in read-only using bwrap and this was one issue I was hitting. See this file from osbuild/osbuild#1947

If we want this in OSBuild sooner in RHEL I guess the packaging approach would be useful.

I guess one option would be to do both fixes. This one to get it in faster (and also to have some RPM own /etc/containers/networks so rpm -qf will show something) and the podman runtime fix that will benefit anyone (including other distros) not using RPMs.

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
cc @lsm5

Copy link
Contributor

openshift-ci bot commented Dec 6, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dustymabe, 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 label Dec 6, 2024
@Luap99
Copy link
Member

Luap99 commented Dec 6, 2024

Agree, I mean there is no harm shipping one extra directory in the rpm here.
I fix up the code next week.

@rhatdan
Copy link
Member

rhatdan commented Dec 6, 2024

The package can be released with the current version of podman with just an update to the spec file releasever, no reason to wait for a podman release.
/lgtm

@openshift-ci openshift-ci bot added the lgtm label Dec 6, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit a2b7fc0 into containers:main Dec 6, 2024
15 checks passed
@lsm5
Copy link
Member

lsm5 commented Dec 9, 2024

LGTM.

cc @jnovy for upcoming CS/rhel changes.

Luap99 added a commit to Luap99/common that referenced this pull request Dec 9, 2024
Podman creates/initializes the network backend for every command. Howver
most commands will not need it so we should keep the required actions we
do to a minimum.

In this case the config directory /etc/containers/networks by default as
root may not exists and then we try to create it which can fail, i.e.
when /etc is read only[1].

The code here are a bit more changes then I would have liked but we must
make sure the default in memory network always exists and do not create
the directory there.

[1] containers#2265

Signed-off-by: Paul Holzinger <[email protected]>
Luap99 added a commit to Luap99/common that referenced this pull request Dec 9, 2024
Podman creates/initializes the network backend for every command. However
most commands will not need it so we should keep the required actions we
do to a minimum.

In this case the config directory /etc/containers/networks by default as
root may not exists and then we try to create it which can fail, i.e.
when /etc is read only[1].

The code here are a bit more changes then I would have liked but we must
make sure the default in memory network always exists and do not create
the directory there.

[1] containers#2265

Signed-off-by: Paul Holzinger <[email protected]>
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.

4 participants