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

bib: run "dnf" inside the container again #670

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mvo5
Copy link
Collaborator

@mvo5 mvo5 commented Oct 9, 2024

In 17d3b56 osbuild-dnf-json was changed to run outside the
container. This lead to a regression in accessing subscribed
content. This commit partially reverts this commit to run
dnf again inside the container so that we have access to
the /run/secrets and RHEL repos.

This also adds a bunch of extra tests that needs to run
on a fedora/rhel/centos machine to test dnfjson and
subscriptions inside the container environment. Those
will only run in testingfarm (or locally) not in GH actions.

Closes: https://issues.redhat.com/browse/BIFROST-429

P.S. We should probably also look into how to inject osbuild-dnf-json into
the container, this way is not ideal, we maybe need to reconsider
putting it all into a single file again or think about other ways to make
this slightly easier. The tests/refactor hopefully makes this slightly easier
now.

@mvo5 mvo5 requested a review from ondrejbudai October 9, 2024 18:46
@mvo5 mvo5 marked this pull request as draft October 10, 2024 08:05
achilleas-k
achilleas-k previously approved these changes Oct 10, 2024
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

LGTM.

Couple of questions.

Comment on lines 185 to 186
matches, err := filepath.Glob("/etc/pki/entitlement/*.pem")
if err == nil && len(matches) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

What does len(matches) > 0 mean here? That the machine is already subscribed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it's basically just double checking if the machine is subscribed already (because the helper unsubscribes machines that got subscribed just for the test again), actually there should be a comment to explain this and a "XXX: find a better way", I had trouble finding some machine readable API and stuff like "subscription-manager status"/"list" is both slow and hard to parse. But maybe I'm missing something :/

Comment on lines 150 to 151
// XXX: hardcoded python3.12
if err := c.CopyInto("/usr/lib//python3.12/site-packages/osbuild", "/"); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

What's the long term plan for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A good question, I think we need to have a brainstorm about it - one way would be to just make it a single file script again another to find/fix the root cause why "dnf.SetRootdir()" does not work with subscribed content.

Copy link
Member

Choose a reason for hiding this comment

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

find/fix the root cause why "dnf.SetRootdir()" does not work with subscribed content

Need me to look into this? It sounds like we have a bug here in the depsolver.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@achilleas-k Sure thing, feel free to look at this, I'm very curious. The easiest is to start from a subscribed machine, then revert 3540536 and run (as root) cd bib/internal/cntdnf && go test -v

In 17d3b56 osbuild-dnf-json was changed to run outside the
container. This lead to a regression in accessing subscribed
content. This commit partially reverts this commit to run
dnf again inside the container so that we have access to
the /run/secrets and RHEL repos.
This commit adds a test that ensures that InitDNF() results in
triggering the dnf plugin that updates the subscriptions.
This commit adds a test for the DNF solver inside a subscribed RHEL
container.
This commit moves the logic of dealing with `osbuild-json-dnf` for
containers into a new container dnf `cntdnf` go module. Also move
the integration test for dnfjson with subscribed/normal content
there.
This commit wires up the needed credentials and scaffolding to
run the integration tests about subscribed content in containers
via tmt. For this it passes in the `RHSM_{ORG,ACTIVATION_KEY}`
secrets and runs the go tests as root.

This splits the go unit tests into a new github action to avoid
having to wait for both to finish.
For unknown and inexplicable reasons the progressbar does not
generate output when run with testingfarm. This is not observed
on a normal fedora40 or the GH runners, the reason is unknown
and should be investigated but to unblock us the test is currently
disabled in this specific environment.
@mvo5 mvo5 marked this pull request as ready for review October 10, 2024 11:51
@@ -0,0 +1,43 @@
---
name: Testing farm go unit tests
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This duplication is sad, we should look into something like actions/starter-workflows#245 (comment) here too.

bib/internal/cntdnf/cntdnf.go Outdated Show resolved Hide resolved
Ondrej suggested to remove the `cntdnf` package again and move
the code back into container. My original thinking was to have
a separate package because it a "container" should not need to
have knowledge about dnf and we could have a `cnfapt` later but
then YAGNI and we can always split it out later.
@achilleas-k achilleas-k self-requested a review October 17, 2024 14:32
Copy link
Member

@ondrejbudai ondrejbudai left a comment

Choose a reason for hiding this comment

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

Looks good. @achilleas-k wanna take one last look? :)

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