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

adapt to new ostree-container ociarchive #145

Closed
cgwalters opened this issue Oct 7, 2021 · 7 comments · Fixed by #146
Closed

adapt to new ostree-container ociarchive #145

cgwalters opened this issue Oct 7, 2021 · 7 comments · Fixed by #146

Comments

@cgwalters
Copy link
Member

For coreos/fedora-coreos-tracker#812

https://jenkins-fedora-coreos.apps.ocp.ci.centos.org/job/fedora-coreos/job/fedora-coreos-fedora-coreos-pipeline/2919/

Exception: Importing failed: Command '['ostree', '--repo=/tmp/tmp6cohmf6g', 'show', '469e3824769141206cd483e351661a53855c60102c4ef04a34b1de7cb20b0089', '--print-metadata-key=version']' returned non-zero exit status 1.

This is another copy of code like coreos/coreos-assembler#2487

@dustymabe
Copy link
Member

Options I can think of:

  • update the function in place (i.e. copy/paste code)
  • hoist the function into a library that we could use in both places
  • use the COSA container for the ostree importer
    • I'm not a fan of this because it's copying around a 6G container image that changes often for a few K of code
  • change the dockerfile to pull down the code directly from COSA github repo and put it in the container image

@jlebon
Copy link
Member

jlebon commented Oct 7, 2021

The semantics in this repo are slightly stricter, so I wouldn't just call the import function directly. Seems like the only shareable bit is the switch on the extension and using rpm-ostree ex-container import? So not sure if it's worth trying to share code for this.

@jlebon
Copy link
Member

jlebon commented Oct 7, 2021

Something like

diff --git a/coreos-ostree-importer/Dockerfile b/coreos-ostree-importer/Dockerfile
index 23b13c1..8c1a18f 100644
--- a/coreos-ostree-importer/Dockerfile
+++ b/coreos-ostree-importer/Dockerfile
@@ -11,7 +11,7 @@ RUN dnf update -y
 RUN dnf -y install \
         fedora-messaging \
         python-requests  \
-        ostree           \
+        rpm-ostree       \
         strace

 # Configure a umask of 0002 which will allow for the group permissions
diff --git a/coreos-ostree-importer/coreos_ostree_importer.py b/coreos-ostree-importer/coreos_ostree_importer.py
index e80d7e8..15d3805 100755
--- a/coreos-ostree-importer/coreos_ostree_importer.py
+++ b/coreos-ostree-importer/coreos_ostree_importer.py
@@ -284,9 +284,14 @@ def untar_file_from_url(url: str, tmpdir: str, sha256sum: str):
     if sha256sum != calcuatedsum:
         raise Exception("Checksums do not match: " f"{sha256sum} != {calcuatedsum}")

-    # Untar the file into the temporary directory
-    with tarfile.open(filepath) as tar:
-        tar.extractall(path=tmpdir)
+    if url.endswith(".ociarchive"):
+        runcmd(["ostree", "init", "--repo", tmpdir, "--mode=bare-user"])
+        runcmd(["rpm-ostree", "ex-container", "import", "--repo", tmpdir,
+                f"ostree-unverified-image:oci-archive:{filepath}"])
+    else:
+        # Assume tar and untar the file into the temporary directory
+        with tarfile.open(filepath) as tar:
+            tar.extractall(path=tmpdir)


 def ostree_pull_local(srcrepo: str, dstrepo: str, branch: str, commit: str):

?

@dustymabe
Copy link
Member

seems reasonable to me

@dustymabe
Copy link
Member

hmm is --mode=bare-user right? the tarballs we have today are mode=archive-z2

jlebon added a commit to jlebon/fedora-coreos-releng-automation that referenced this issue Oct 7, 2021
FCOS rawhide is now producing archives in the new OCI format. We have to
use `rpm-ostree ex-container import` to extract those.

Closes: coreos#145
@jlebon
Copy link
Member

jlebon commented Oct 7, 2021

OK, threw it up in #146, though haven't tested it.

hmm is --mode=bare-user right? the tarballs we have today are mode=archive-z2

I based this off of https://github.com/coreos/coreos-assembler/blob/f5d003d2ebb81283c3e071ce2ac268884aa7232b/src/cosalib/cmdlib.py#L272-L275. There's a comment above about ex-container only writing to non-archive repos.

@dustymabe
Copy link
Member

OK, threw it up in #146, though haven't tested it.

hmm is --mode=bare-user right? the tarballs we have today are mode=archive-z2

I based this off of https://github.com/coreos/coreos-assembler/blob/f5d003d2ebb81283c3e071ce2ac268884aa7232b/src/cosalib/cmdlib.py#L272-L275. There's a comment above about ex-container only writing to non-archive repos.

ahh ok and pull-local between repos of different type works fine 👍

jlebon added a commit to jlebon/fedora-coreos-releng-automation that referenced this issue Oct 7, 2021
FCOS rawhide is now producing archives in the new OCI format. We have to
use `rpm-ostree ex-container import` to extract those.

Closes: coreos#145
jlebon added a commit to jlebon/fedora-coreos-releng-automation that referenced this issue Oct 7, 2021
FCOS rawhide is now producing archives in the new OCI format. We have to
use `rpm-ostree ex-container import` to extract those.

Closes: coreos#145
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 a pull request may close this issue.

3 participants