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

Various patches to build extensions container using podman build in production #4044

Merged
merged 5 commits into from
Mar 18, 2025

Conversation

jlebon
Copy link
Member

@jlebon jlebon commented Mar 17, 2025

We're getting ready to build the extensions container in production as part of the layered node image work. To be able to build it using podman build directly and not via cosa build-extensions-container, a few adjustments are needed.

See individual commit messages.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Another one of those that's assumed by some userspace apps (in this
case, apparently, `podman run`).
@@ -239,6 +244,9 @@ Examples:
parser.add_argument(
'--git-sub-dir', default='', required=False,
help='Git sub directory to use for container build')
parser.add_argument(
'--git-file', default='', required=False,
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: I think the name of the argument is confusing, containerfile is enough, with the help text as is IMO

Copy link
Member

@dustymabe dustymabe Mar 17, 2025

Choose a reason for hiding this comment

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

I kind of agree.. alternatively.. --contextdir= where you can specify the full path to the containerfile as an option.

Copy link
Member Author

Choose a reason for hiding this comment

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

I want something with git in it to make it clear it's about the git repo. Maybe just --git-containerfile?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, just went with --git-containerfile for now.

raise Exception("Error encountered when checking if manifest exists")
if cp.returncode == 0:
return True
cmd = ["podman", "image", "exists", f"{repo}:{tag}"]
Copy link
Member

@dustymabe dustymabe Mar 17, 2025

Choose a reason for hiding this comment

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

I wouldn't make this change unless we've tested it fully.

My experience here was that we needed them both: 44901a6. If I could have used just one I definitely would have.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, meant to point you at this for a sanity-check.

OK so testing this in depth now:

  • if an image is not a manifest list:
    • podman manifest exists returns 125
    • podman image exists returns 0
  • if an image is a manifest list:
    • podman manifest exists returns 0
    • podman image exists returns 1
  • if an image doesn't exist
    • podman manifest exists returns 1
    • podman image exists returns 1

I think there's a bug there and podman image exists should probably actually return 0 if the image exists but it's a manifest.

But anyway... I think we can work around this by reversing the order in which we call the two commands?

If it doesn't exist, then both iterations will pass. If it's a manifest, the second iteration returns True. If it's an image, the first iteration returns True.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for not thinking critically on this. Today has had a lot going on.

Are you saying there is a bug in the current code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I summarized it in the commit message.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, I think it's debatable whether it's a bug in our code or a bug in podman that our code is hitting. I'd argue more for the latter.

Copy link
Member

Choose a reason for hiding this comment

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

yeah. I'm surprised. I was pretty sure I tested all permutations when I added this code because we were hitting an issue where someone had pulled the image on the node (i.e. not manifest listed) and I needed to update it and I thought I handled all cases.

Either way, it sounds like you've got all cases covered so LGTM

@jlebon jlebon force-pushed the pr/extensions-build branch 2 times, most recently from 3c6feeb to e2c2709 Compare March 17, 2025 19:30
dustymabe
dustymabe previously approved these changes Mar 18, 2025
Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

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

LGTM - merge when you're ready

jlebon added 4 commits March 18, 2025 16:41
Instead of bind-mounting `/tmp/extensions.json`, just extract it from
the image now that it's baked in there.
For building the extensions, we need to be able to point buildah at the
root of the git repo for the context dir but the Dockerfile in the
`extensions/` subdirectory.

Add a `--git-containerfile` for this.
When cloning the git repo to pass to buildah, make sure to initiatlize
submodules. E.g. building the extensions container requires parsing the
manifest, which references bits in the fedora-coreos-config submodule.
There's an asymmetry between `podman image exists` and `podman manifest
exists`. The first will return 1 if the image is a manifest. The second
will return 125 if the image is _not_ a manifest.

I think this is probably a bug in podman, but for now we can work around
this by reverting the order in which we do the checking. That way, if
the image exists but isn't a manifest, we'll return `True` and not
actually call `podman manifest exists` on it.
@jlebon
Copy link
Member Author

jlebon commented Mar 18, 2025

I reworked this to make the build-extensions-container.sh change compatible with both the old and the new way so that we can merge it now so that we can merge this PR first so that in turn we don't need to override tests in openshift/os#1772 to merge that one.

@dustymabe
Copy link
Member

I reworked this to make the build-extensions-container.sh change compatible with both the old and the new way so that we can merge it now so that we can merge this PR first so that in turn we don't need to override tests in openshift/os#1772 to merge that one.

I think the updated change to support this is fine, but would like to PR later this week or something to drop the extra code/workaround.

Copy link
Member

@dustymabe dustymabe left a comment

Choose a reason for hiding this comment

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

/lgtm

@jlebon jlebon enabled auto-merge (rebase) March 18, 2025 21:15
@jlebon jlebon merged commit e61093c into coreos:main Mar 18, 2025
5 checks passed
@jlebon jlebon deleted the pr/extensions-build branch March 18, 2025 23:20
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.

None yet

3 participants