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

compose: Add rpmdb option, default to bdb #2221

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

cgwalters
Copy link
Member

The design of https://fedoraproject.org/wiki/Changes/Sqlite_Rpmdb
is problematic for us for multiple reasons. The first big reason
is that rpm-ostree is designed for "cross" builds and e.g. today
we use a Fedora-derived container to build RHEL CoreOS images.

However the default database lives inside the rpm package which
means that if we e.g. upgrade the coreos-assembler container to F33
it will suddenly try to use sqlite for RHCOS which is obviously broken.

Related to this, rebases from f32 to f33 w/layered packages
are broken: https://bugzilla.redhat.com/show_bug.cgi?id=1876194#c3

With this we can configure things to continue to use bdb for f33
for ostree-based systems, so that by enforcing an upgrade order
f32 -> f33 [bdb] -> f34 [sqlite] ... the intermediate f33 w/bdb
still understands sqlite and hence rebases will work.

@cgwalters
Copy link
Member Author

Marking draft for lack of tests, but I did validate this works manually by creating a f33 version of my dev container, building rpm-ostree in that and validating two things:

  1. Without rpmdb: sqlite set running cosa build still gives me FCOS w/bdb
  2. Setting rpmdb: sqlite does what you expect

@jlebon
Copy link
Member

jlebon commented Sep 10, 2020

Yeah, that's probably the cleaner approach overall. For FCOS at least, we could opt into sqlite much earlier than f34 because we have update barriers. I don't think we gain anything major on the technical side by doing it earlier, but it does have better optics to match the rest of Fedora.

@cgwalters
Copy link
Member Author

OK I added some basic tests, but actually testing the sqlite path would require us to build a f33 cosa which we should do, just not sure I want to block on it.

rust/src/treefile.rs Outdated Show resolved Hide resolved
rust/src/treefile.rs Outdated Show resolved Hide resolved
src/libpriv/rpmostree-core.c Outdated Show resolved Hide resolved
Comment on lines 757 to 760
const char *db_backend = "bdb";
if (self->treefile_rs && ror_treefile_get_sqlite (self->treefile_rs))
db_backend = "sqlite";
dnf_context_set_rpm_macro (self->dnfctx, "_db_backend", db_backend);
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, but actually shouldn't this be something like:

Suggested change
const char *db_backend = "bdb";
if (self->treefile_rs && ror_treefile_get_sqlite (self->treefile_rs))
db_backend = "sqlite";
dnf_context_set_rpm_macro (self->dnfctx, "_db_backend", db_backend);
if (self->treefile_rs)
dnf_context_set_rpm_macro (self->dnfctx, "_db_backend", ror_treefile_get_rpmdb (self->treefile_rs) ?: "bdb");

On the client side, we don't want to touch this macro at all, right?

Copy link
Member

Choose a reason for hiding this comment

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

Thinking more on this, I think what we want to do is also drop a file in /usr/lib/rpm/macros.d so it's part of the commit itself. So then dnf_context_set_rpm_macro would only be used server-side to make sure the baked rpmdb type matches the macro we write in postprocessing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking more on this, I think what we want to do is also drop a file in /usr/lib/rpm/macros.d so it's part of the commit itself.

Hmm. But that also will be picked up by any kind of "yum --installroot" that happens to run from the host context. I believe we'll transparently inherit the "base commit" default because rpm will autodetect the database type in the target root. I think. But we clearly need to test that.

Choose a reason for hiding this comment

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

RPM does do this correctly, as long as there's only one type of rpmdb in the rpmdb path. If there are two different types and one is specified in configuration, that one wins.

rust/src/treefile.rs Outdated Show resolved Hide resolved
Copy link
Member

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

Shouldn't the commit message say "default to bdb"? Apart from that, just one final comment about a comment.

@@ -753,6 +753,13 @@ rpmostree_context_setup (RpmOstreeContext *self,
/* This is what we use as default. */
dnf_context_set_rpm_macro (self->dnfctx, "_dbpath", "/" RPMOSTREE_RPMDB_LOCATION);

// Default for now for compat reasons
Copy link
Member

Choose a reason for hiding this comment

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

This comment should be on the Rust side now.

@Conan-Kudo
Copy link

@jlebon It should default to whatever rpm defaults, rather than picking something. For Fedora, that'll be SQLite. For openSUSE, that'd be NDB. For RHEL (for now), that'll be BDB.

@cgwalters
Copy link
Member Author

@jlebon It should default to whatever rpm defaults, rather than picking something. For Fedora, that'll be SQLite. For openSUSE, that'd be NDB. For RHEL (for now), that'll be BDB.

No - rpm-ostree is too strongly oriented towards "cross" builds. Perhaps in the future we could add an "auto" which inherits whatever the "host" librpm default is though.

The design of https://fedoraproject.org/wiki/Changes/Sqlite_Rpmdb
is problematic for us for multiple reasons.  The first big reason
is that rpm-ostree is designed for "cross" builds and e.g. today
we use a Fedora-derived container to build RHEL CoreOS images.

However the default database lives inside the `rpm` package which
means that if we e.g. upgrade the coreos-assembler container to F33
it will suddenly try to use sqlite for RHCOS which is obviously broken.

Related to this, rebases from f32 to f33 w/layered packages
are broken: https://bugzilla.redhat.com/show_bug.cgi?id=1876194#c3

With this we can configure things to continue to use bdb for f33
for ostree-based systems, so that by enforcing an upgrade order
f32 → f33 [bdb] → f34 [sqlite] ... the intermediate f33 w/bdb
still understands sqlite and hence rebases will work.
@jlebon jlebon changed the title compose: Add rpmdb option, default to sqlite compose: Add rpmdb option, default to bdb Sep 11, 2020
@jlebon
Copy link
Member

jlebon commented Sep 11, 2020

/lgtm

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cgwalters, Conan-Kudo, jlebon

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

@cgwalters
Copy link
Member Author

If anything, the default should somehow inherit from the target - but that's tricky to do automatically. Maybe in the future since repodata XML is enormous anyways we can do things like stick a tiny bit of metadata in there that has things like <osmetadata><rpmdb>sqlite</rpmdb></osmetadata>.

@Conan-Kudo
Copy link

@cgwalters "auto" is the behavior now, though, so absent this code, it should do that already.

@cgwalters
Copy link
Member Author

@cgwalters "auto" is the behavior now, though, so absent this code, it should do that already.

It's auto only from the host which is wrong for the reason mentioned in the commit message:

However the default database lives inside the rpm package which
means that if we e.g. upgrade the coreos-assembler container to F33
it will suddenly try to use sqlite for RHCOS which is obviously broken.

@openshift-merge-robot openshift-merge-robot merged commit 456a3ec into coreos:master Sep 11, 2020
jlebon added a commit to jlebon/rpm-ostree that referenced this pull request Sep 14, 2020
A few goodies, but mostly to get coreos#2221 out.
@jlebon jlebon mentioned this pull request Sep 14, 2020
openshift-merge-robot pushed a commit that referenced this pull request Sep 15, 2020
A few goodies, but mostly to get #2221 out.
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.

5 participants