Skip to content

oscontainer: New command - #90

Merged
jlebon merged 1 commit into
coreos:masterfrom
cgwalters:add-oscontainer-extract
Sep 24, 2018
Merged

jlebon merged 1 commit into
coreos:masterfrom
cgwalters:add-oscontainer-extract

Conversation

@cgwalters

Copy link
Copy Markdown
Member

No description provided.

@dustymabe

Copy link
Copy Markdown
Member

Do you have an example of running this command?

Should we put this under another toplevel in the future so that we don't end up with too many? Maybe coreos-assembler util oscontainer-extract --src --dest

@cgwalters

Copy link
Copy Markdown
Member Author

Do you have an example of running this command?

Don't have a publicly available container image that does this, but it's just oscontainer-extract containerimage destination.

Should we put this under another toplevel in the future so that we don't end up with too many?

Maybe an oscontainer verb, so we'd have coreos-assembler oscontainer [extract|build] or so?

@dustymabe

Copy link
Copy Markdown
Member

Do you have an example of running this command?

Don't have a publicly available container image that does this, but it's just oscontainer-extract containerimage destination.

thanks

Should we put this under another toplevel in the future so that we don't end up with too many?

Maybe an oscontainer verb, so we'd have coreos-assembler oscontainer [extract|build] or so?

yeah I was wondering if a util toplevel would be useful for things that weren't mainstream (like build, init, run) so that we could keep it clear which ones were the main ones. I'm fine with any approach you like to take at this point, just trying to brainstorm as we go.

Comment thread coreos-assembler Resolved
Comment thread src/cmd-oscontainer-extract Outdated
@@ -0,0 +1,43 @@
#!/usr/bin/python3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A description here would be nice for anyone that stumbles upon this file.

@dustymabe

Copy link
Copy Markdown
Member

a few pending non-fatal comments.. going to go ahead and approve.

@cgwalters

Copy link
Copy Markdown
Member Author

yeah I was wondering if a util toplevel would be useful for things that weren't mainstream (like build, init, run) so that we could keep it clear which ones were the main ones. I'm fine with any approach you like to take at this point, just trying to brainstorm as we go.

I'll do something like that first, yeah.

a few pending non-fatal comments.. going to go ahead and approve.

I think this one can wait a bit until I have a chance to clean up more. One min.

@cgwalters

Copy link
Copy Markdown
Member Author

OK, I updated this - it now has build and extract sub-commands.

The code is derived from https://github.com/ostreedev/ostree-releng-scripts/blob/master/experimental/tree2oci

However...the oscontainer build doesn't support having a base layer yet, which means there's no binaries like e.g. bash to run as an entrypoint. That in turn breaks what the pivot command is doing today of running a dummy sleep just to mount the running container.

Theoretically we could do more sophisticated things if this was written in Go and vendored https://github.com/containers/storage or so. Probably best even if this shared code with pivot.

That said though I'm wary of the overhead of vendoring a separate copy of containers/storage. All we really need from the stack is way to mount a container without running a process in it, but still holding a lock on the storage as if a process was running, so that e.g. concurrently running OpenShift instance doing normal pruning wouldn't prune the oscontainer. Or alternatively, we could always use a separate container storage directory.

@jlebon

jlebon commented Sep 20, 2018

Copy link
Copy Markdown
Member

OK, so for this to address openshift/os#307, we'd want to have this script be part of the build run, right?

@jlebon

jlebon commented Sep 20, 2018

Copy link
Copy Markdown
Member

Re. sleep, one big hack would be to add a tiny golang binary that just sleeps.

@cgwalters

Copy link
Copy Markdown
Member Author

OK, so for this to address openshift/os#307, we'd want to have this script be part of the build run, right?

Yes, eventually but for now my idea is that we'd run these scripts in the Jenkins pipeline before/after build.

Anyways don't merge yet, I'm rewriting this.

Re. sleep, one big hack would be to add a tiny golang binary that just sleeps.

I asked about this on #podman and Giuseppe noted we can just podman create to get a non-running container.

@cgwalters cgwalters changed the title oscontainer-extract: New command WIP: oscontainer-extract: New command Sep 20, 2018
jlebon added a commit to jlebon/pivot that referenced this pull request Sep 20, 2018
jlebon added a commit to jlebon/pivot that referenced this pull request Sep 20, 2018
ashcrow pushed a commit to openshift/pivot that referenced this pull request Sep 20, 2018
@cgwalters
cgwalters force-pushed the add-oscontainer-extract branch from ceb67af to e34e2f4 Compare September 20, 2018 19:06
@cgwalters cgwalters changed the title WIP: oscontainer-extract: New command oscontainer: New command Sep 20, 2018
@cgwalters cgwalters removed the WIP PR still being worked on label Sep 20, 2018
@cgwalters

Copy link
Copy Markdown
Member Author

OK I totally rewrote this code to use podman/buildah --root.

@jlebon jlebon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice! I much prefer this version.

Comment thread src/cmd-oscontainer Resolved
Comment thread src/cmd-oscontainer Resolved
Comment thread src/cmd-oscontainer Resolved
@cgwalters
cgwalters force-pushed the add-oscontainer-extract branch from e34e2f4 to c0f0ee2 Compare September 20, 2018 21:45
@cgwalters

Copy link
Copy Markdown
Member Author

All comments resolved ⬆️

@cgwalters
cgwalters force-pushed the add-oscontainer-extract branch 2 times, most recently from 5687475 to 5b5fb9d Compare September 20, 2018 21:47
@dustymabe

Copy link
Copy Markdown
Member

LGTM, i'll defer to jonathan to review changes for his comments.

@jlebon

jlebon commented Sep 21, 2018 •

Copy link
Copy Markdown
Member

Still testing out build. It's doing... something, but not really printing out anything past the Resolved fedora/29/x86_64/coreos = ... line. There is a process which is taking 100% CPU called exe. Are you running this as root or non-root?

@jlebon

jlebon commented Sep 21, 2018

Copy link
Copy Markdown
Member

Interrupting:

Resolved fedora/29/x86_64/coreos = 8bc1f21c4fd2a85a9a4dafb21e37d7dafd95658a2562a99617eb5b4f080a43b7
^CTraceback (most recent call last):
  File "/home/jlebon/Code/gh/coreos/coreos-assembler/src/cmd-oscontainer", line 105, in <module>
    push=args.push)
  File "/home/jlebon/Code/gh/coreos/coreos-assembler/src/cmd-oscontainer", line 66, in oscontainer_build
    bid = subprocess.check_output(['buildah', rootarg, 'from', 'scratch']).strip()
  File "/usr/lib64/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib64/python3.6/subprocess.py", line 405, in run
    stdout, stderr = process.communicate(input, timeout=timeout)
  File "/usr/lib64/python3.6/subprocess.py", line 830, in communicate
    stdout = self.stdout.read()
KeyboardInterrupt

Yet, if I manually do:

$ buildah --root=$PWD/tmp/containers-storage from scratch
working-container

it returns right away.

@cgwalters

Copy link
Copy Markdown
Member Author

There is a process which is taking 100% CPU called exe. Are you running this as root or non-root?

Non-root inside my privileged dev container.

@jlebon

jlebon commented Sep 21, 2018

Copy link
Copy Markdown
Member

Hmm, OK same here. But for some reason check_output() is blocking on the first buildah invocation.

Comment thread src/cmd-oscontainer
@@ -0,0 +1,105 @@
#!/usr/bin/python3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This file needs a chmod a+x.

Comment thread src/cmd-oscontainer Outdated

rootarg = '--root='+containers_storage
bid = subprocess.check_output(['buildah', rootarg, 'from', 'scratch']).strip()
subprocess.check_call(['buildah', rootarg, 'copy', bid, src, '/srv/repo'])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is copying the whole repo though. We should be bundling just the latest commit, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Working on this.

@jlebon

jlebon commented Sep 21, 2018

Copy link
Copy Markdown
Member

So I figured out the hang has something to do with having:

$ echo $LANG
en_US.UTF-8

in my pet container. Running it with LANG=C works fine for me. Using encoding='utf-8' in that first check_output call also fixes it, which I'm not sure why since without it bid should remain in bytes and work just fine. I then tried to reproduce the problem again by removing encoding='utf-8' and it kept working. So 🤷‍♂️

@cgwalters

Copy link
Copy Markdown
Member Author

Using encoding='utf-8' in that first check_output call also fixes it

Ugh man Python and Unicode... But yeah we should be consistently decoding. Will fix.

@cgwalters
cgwalters force-pushed the add-oscontainer-extract branch from 6082c72 to ec16f4b Compare September 21, 2018 17:07
@cgwalters

Copy link
Copy Markdown
Member Author

OK so...I've been doing more hacking on this but hitting one last stumbling block, which is that for some reason the buildah config --entrypoint=/enoent isn't ending up in the built container, but it totally is when I invoke things manually 😕

@cgwalters

Copy link
Copy Markdown
Member Author

for some reason the buildah config --entrypoint=/enoent isn't ending up in the built container, but it totally is when I invoke things manually confused

OK so first, skopeo inspect doesn't show the entrypoint. That totally confused me into thinking the problem was in the build side but really the problem is that unprivileged podman create for some reason can't find it.

So for now let's just add --entrypoint in the extract process here, but it should work for pivot.

@cgwalters
cgwalters force-pushed the add-oscontainer-extract branch from 47e43f6 to b32af4a Compare September 21, 2018 20:59

@jlebon jlebon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good, just a few final nits.

Comment thread src/cmd-oscontainer Resolved
Comment thread src/cmd-oscontainer Resolved
For Red Hat CoreOS, we plan to ship the OSTree inside a container,
or "oscontainer" for short.

This script offers two subcommands: `extract` and `build`.
Now, an important point to understand is that these tools are
expected to run from inside an existing container.  Since
overlayfs-on-overlayfs is not supported, we use a separate
`--workdir` which translates into `podman --root`.  Hence
these tools have nothing to do with any container storage on the
host system.
@cgwalters
cgwalters force-pushed the add-oscontainer-extract branch from b32af4a to 630989f Compare September 24, 2018 14:18
@cgwalters

Copy link
Copy Markdown
Member Author

Respun with typo fix.

@jlebon
jlebon merged commit a9bae0e into coreos:master Sep 24, 2018
cgwalters added a commit to cgwalters/os that referenced this pull request Oct 1, 2018
This was changed in code review in coreos/coreos-assembler#90 (comment)

We need to support both for a while to transition.
cgwalters added a commit to cgwalters/pivot that referenced this pull request Oct 26, 2018
cgwalters added a commit to cgwalters/pivot that referenced this pull request Oct 26, 2018
cgwalters added a commit to cgwalters/pivot that referenced this pull request Oct 26, 2018
jlebon pushed a commit to openshift/pivot that referenced this pull request Oct 26, 2018
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