Generate RPM and support arbitrary files copied to the host#767
Generate RPM and support arbitrary files copied to the host#767giuseppe wants to merge 18 commits intoprojectatomic:masterfrom
Conversation
be1e761 to
7fc4711
Compare
| for root, _, files in os.walk(os.path.join(destdir, "etc")): | ||
| rel_path = os.path.relpath(root, destdir) | ||
| for f in files: | ||
| spec += "%config \"%s\"\n" % os.path.join("/", rel_path, f) |
There was a problem hiding this comment.
I'm confused, this line looks like you want to install container's /etc to host's /etc.
There was a problem hiding this comment.
here I am mapping from the temporary directory (where the container was checked out) to the absolute path `/etc' in the host (where the .rpm will install these files)
There was a problem hiding this comment.
Oh sorry, I thought that the destdir variable points to the container's root.
Atomic/install.py
Outdated
| system_xor_user.add_argument("--system", dest="system", | ||
| action='store_true', default=False, | ||
| help=_('install a system container')) | ||
| installp.add_argument("---generate-rpm", dest="generate_rpm", |
There was a problem hiding this comment.
I would prefer that the user not need to specify this. This should happen automatically if the image supports generation of rpms for install.
There was a problem hiding this comment.
Users will forget to do this, and we want to eventually make this the default for all of our system containers.
There was a problem hiding this comment.
the --generate-rpm doesn't probably belong here, I just didn't know where to add it.
I think we will need a way to just generate the .rpm, so that it can be used as any regular .rpm, you can even install it without using atomic at all.
Installing the .rpm could be the default here, but we will need a way to specify also to install the container in the usual way using /var/lib instead of '/usr/lib' if needed.
There was a problem hiding this comment.
Right I would say that is the fallback.
I believe the user puts the data in as templates rather then in labels. I am thinking a rpm.yaml file which specifies information for the spec file, but allows atomic CLI to do substitutions like the name of the container so the spec file ends up with foobar_etcd, and we could prefix all executables or paths with the container names.
Atomic/syscontainers.py
Outdated
|
|
||
| values["DESTDIR"] = destination | ||
| if prefix: | ||
| values["DESTDIR"] = os.path.join("/", os.path.relpath(destination, prefix)) |
There was a problem hiding this comment.
values["DESTDIR"] = (os.path.join("/", os.path.relpath(destination), prefix)) if prefix else destination)
| if os.path.exists(sym): | ||
| os.unlink(sym) | ||
| os.symlink(destination, sym) | ||
| if not prefix: |
There was a problem hiding this comment.
Should we just
if prefix:
return
Atomic/syscontainers.py
Outdated
| "--define", "_rpmdir %s" % cwd, | ||
| "--build-in-place", | ||
| "--buildroot=%s" % rpm_content] | ||
| util.write_out(" ".join(cmd)) |
|
I think there should be a rpm specification template in the container image that triggers the rpm build for install. This should be simpler then the rpm.spec, Perhaps just the files section as well as description, license, summary and potentially some other fields. Should we default post install of rpm package to atomic uninstall CONTAINER |
|
We can add a spec template, as we do with the other configuration files (and offer a substitution for the list of the installed files, it would be very tedious to list them otherwise). I thought of using labels so we will be able to query resolves/provides/conflicts remotely without fetching the image first. I have not added a preun script yet. I think it should just be to stop the systemd service. I think "atomic uninstall" should not interfere with rpm to handle/delete the files. |
|
Right I guess we could get a circular dependency here. rpm -e PACKAGE. |
|
@rhatdan I have addressed your comments for the code. I have pushed a bunch of other patches to cleanly support copied files to the host. I have included the idea of @jfilak to copy files from The files copied to the host can be also template files, the same substitution rules that are used for the runc configuration file and the systemd service file apply here. It is possible to specify that a system container doesn't install any service, so that can be used just as a way to copy files to the host, or to generate an rpm without the overhead of the service+rootfs files. |
5425cdd to
198f4f5
Compare
|
@TomasTomecek PTAL |
|
@baude PTAL |
|
I like this pull request and I told @giuseppe that he has done a great job in private chat. However, there is one thing that concerns me a bit. I think it's a pity that the whole system container thing is bundled in 'atomic' utility. I develop my containers on Fedora and I would appreciate a tool capable of installing a test container on my development machine. |
|
atomic command is available on Fedora as well as atomic host. It is a separate package. |
|
Atomic Host is part of Fedora. It is Fedora as much as a system managed via yum. |
|
Right atomic CLI is available on Fedora Server, Fedora Workstation, Fedora Cloud/Atomic |
|
So it is possible to develop a DNF plugin installing system containers through 'atomic' utility. It would be cool to run: |
| if installed_files: | ||
| for i in installed_files: | ||
| spec = spec + "%s\n" % i | ||
|
|
There was a problem hiding this comment.
Would it make sense to add changelog? So users know that the rpm is generated and installed by atomic.
|
Got this traceback with image you provided to me: |
|
@TomasTomecek |
|
I would like to setup a BlueJeans tomorrow to help design this tool to make sure everyone is on the same page. We need this to work for use cases outside of --system containers as well. |
This would be awesome. Right now I'm in a process of writing down use cases which could benefit greatly from this feature. Please, invite me to the discussion. |
|
yes, this PR makes possible to install arbitrary files on the host and track them with a rpm without requiring a running or even installed container/systemd service. Every file under /exports/hostfs will be copied to the host file system. If |
|
@giuseppe I scheduled the meeting tomorrow at 8:30 AM EST. I would like you to take the lead to describe what you are building and display different parts. Could you throw together a Google Doc in the mean time to help facilitate the discussion. |
|
BTW Add anyone you would like to the meeting. |
|
@TomasTomecek If you could write up your Use Cases, that would be helpful also. |
ff82c9f to
263ceed
Compare
|
☔ The latest upstream changes (presumably e405c6a) made this pull request unmergeable. Please resolve the merge conflicts. |
263ceed to
252b698
Compare
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
we have another mechanism to do this now. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
allow the $ORIGIN: prefix only when the branch is specified, otherwise it is not decidable if $ORIGIN is the source to pull the image from or the name of the image itself. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
when using system-package add to the default generated rpm only the files that are exported to the host not every file that is part of the container. We will still be able to take advantage of the OSTree storage. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This works only for not preinstalled containers (the ones under /usr) that are handled separately. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Add a hidden (for now) option ---generate-rpm to "install --system" to generate an rpm file instead of installing the container. The rpm can be installed on the system and the container won't be managed by atomic, update and uninstall are disabled. Differently from containers handled by atomic that installs the container under /var/lib/containers/atomic, the RPM version installs its files under /usr/lib/containers and can be integrated in an atomic image as a normal rpm. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
Copy the /exports/hostfs/ to the host file system. These files are tracked into the "info" file for a deployment. Change update/rollback/uninstall to honor the new configuration. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
When generating an rpm, ha the files copied to the file system in the rpm itself. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
It can be specified in the manifest.json file as:
"installedFilesTemplate" : [
"/usr/local/bin/hello-template.sh"
]
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #767
Approved by: rhatdan
with the rpm generation, it can be useful to copy files to the host
without the overhead of maintaining a dummy service.
Containers that do not use a service, can specify it in the
manifest file as:
"noContainerService": true
it also implies that the rootfs is deleted once all the files are
copied to the system.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #767
Approved by: rhatdan
allow to rename a copied file to host using the variable substitution.
In the manifest.json file it is permitted to specify the destination
file name of a file copied to the host as:
"renameFiles" : {
"/usr/local/bin/hello-template.sh" : "/usr/local/bin/hello-template-$NAME.sh"
},
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: #767
Approved by: rhatdan
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
Drop the hidden option ---generate-rpm in favor of --system-package. The new option controls how a system container is installed to the host: --generate-rpm=build build the rpm file without installing it. --generate-rpm=yes build the rpm and install it, the rpm is deleted. --generate-rpm=no do not attempt to build and install an rpm file. --generate-rpm=auto install the rpm only if a .spec file is defined in the image. This is the default. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
If an rpm file is already present the the container image. just use it. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
it stores the image id used to install the container. Use it in the generated spec file to refer to the image ID. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
it contains the name of the image used to install the container Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
we have another mechanism to do this now. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
allow the $ORIGIN: prefix only when the branch is specified, otherwise it is not decidable if $ORIGIN is the source to pull the image from or the name of the image itself. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
when using system-package add to the default generated rpm only the files that are exported to the host not every file that is part of the container. We will still be able to take advantage of the OSTree storage. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
This works only for not preinstalled containers (the ones under /usr) that are handled separately. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #767 Approved by: rhatdan
|
☀️ Test successful - status-redhatci |
this is a prototype to add "pre installed" system containers. The idea is to have another deployment tree under
/usr/lib/containers/atomicthat is not handled by "atomic install/uninstall/update", where '/var/lib/containers/atomic' is fully handled by atomic. The systemd files are also copied under '/usr/lib'.The second patch adds the possibility to install a system container into a rpm. The
---generate-rpm(three dashes) option is hidden for now. The spec file is auto generated, and stuff likeRequires,Provides,Conflictscan be specified through labels. So in the Dockerfile something like:LABEL Provides="etcd", will be translated directly to the specfile.Example: