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

sdk: Trim away lots of CL stuff #1195

Merged
merged 1 commit into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions mantle/cmd/plume/prerelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ func getImageTypeURI() string {
}

func getFedoraImageFile(client *http.Client, spec *channelSpec, src *storage.Bucket, fileName string) (string, error) {
cacheDir := filepath.Join(sdk.RepoCache(), "images", specChannel, specVersion)
rawxzPath := filepath.Join(cacheDir, fileName)
imagePath := strings.TrimSuffix(rawxzPath, ".xz")
imagePath := strings.TrimSuffix(fileName, ".xz")
Comment on lines 183 to +184
Copy link
Member

Choose a reason for hiding this comment

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

I think this might be problematic. It looks like sdk.UpdateFile() wants a full local file path where the user wants the file to be downloaded to. I believe you changed this because sdk.RepoCache() is changing. Maybe we create our own temporary directory here and use that?

The only drawback I see of that is that I think the sdk download logic would resume downloads if one had failed for whatever reason and if we don't use the same directory each time we'll be throwing away that logic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me ask a higher level question: Is this code actually used today or is it still just a PoC?

Second question related to that - is that code setting REPO_PATH, or was it manually doing mkdir?

Actually, where is the Fedora infra code that runs this located?

Copy link
Member Author

Choose a reason for hiding this comment

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

Backing up what I'd like to get to is where this sdk parses coreos-assembler schema and that's it.

So one thing non-CoreOS systems could do is "fake it" and create a builds/version/x86_64/meta.json that has a vmdk image etc. That shouldn't be too hard to do.

Copy link
Member

Choose a reason for hiding this comment

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

The code is not currently used today. There is an example of how to use it in the README. There is also the joystick app that is what sayan was working on to actually use it before he left.

This code seems to be building up a URL to a disk image using all of the information (composeID, image type, arch, filename, etc) and then downloading it using sdk.UpdateFile(). Previously we were calling sdk.UpdateFile() with rawxzPath with is a path we had constructed using filepath.Join(sdk.RepoCache(), "images", specChannel, specVersion). I don't know how important that was or not. We can probably just choose our own temporary directory and use that.

Copy link
Member Author

Choose a reason for hiding this comment

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

This path is just an optimization to reuse a local image if it exists. As far as I can tell joystick isn't doing that.

So I think this is fine to ship.

Copy link
Member Author

Choose a reason for hiding this comment

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

So can you /lgtm ?

Copy link
Member

Choose a reason for hiding this comment

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

yep. sorry for the delay


if _, err := os.Stat(imagePath); err == nil {
plog.Printf("Reusing existing image %q", imagePath)
Expand All @@ -195,15 +193,15 @@ func getFedoraImageFile(client *http.Client, spec *channelSpec, src *storage.Buc
return "", err
}

plog.Printf("Downloading image %q to %q", rawxzURI, rawxzPath)
plog.Printf("Downloading image %q to %q", rawxzURI, fileName)

if err := sdk.UpdateFile(rawxzPath, rawxzURI.String(), client); err != nil {
if err := sdk.UpdateFile(fileName, rawxzURI.String(), client); err != nil {
return "", err
}

// decompress it
plog.Printf("Decompressing %q...", rawxzPath)
if err := util.XzDecompressFile(imagePath, rawxzPath); err != nil {
plog.Printf("Decompressing %q...", fileName)
if err := util.XzDecompressFile(imagePath, fileName); err != nil {
return "", err
}
return imagePath, nil
Expand Down
47 changes: 0 additions & 47 deletions mantle/sdk/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package sdk

import (
"bytes"
"fmt"
"os"
"path/filepath"
"text/template"
Expand Down Expand Up @@ -217,49 +216,3 @@ func extract(tar, dir string) error {

return nil
}

func Unpack(version, name string) error {
chroot := filepath.Join(RepoRoot(), name)
if _, err := os.Stat(chroot); !os.IsNotExist(err) {
if err == nil {
err = fmt.Errorf("Path already exists: %s", chroot)
}
return err
}

plog.Noticef("Unpacking SDK into %s", chroot)
if err := os.MkdirAll(chroot, 0777); err != nil {
return err
}

tar := filepath.Join(RepoCache(), "sdks", TarballName(version))
plog.Infof("Using %s", tar)
if err := extract(tar, chroot); err != nil {
plog.Errorf("Extracting %s to %s failed: %v", tar, chroot, err)
return err
}
plog.Notice("Unpacked")

return nil
}

func Delete(name string) error {
chroot := filepath.Join(RepoRoot(), name)
if _, err := os.Stat(chroot); err != nil {
if os.IsNotExist(err) {
plog.Infof("Path does not exist: %s", chroot)
return nil
}
return err
}

plog.Noticef("Removing SDK at %s", chroot)
rm := exec.Command("sudo", "-p", sudoPrompt, "rm", "-rf", chroot)
rm.Stderr = os.Stderr
if err := rm.Run(); err != nil {
return err
}
plog.Notice("Removed")

return nil
}
6 changes: 0 additions & 6 deletions mantle/sdk/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,6 @@ func DownloadCompressedSignedFile(file, url string, client *http.Client, verifyK
return err
}

func DownloadSDK(version, verifyKeyFile string) error {
tarFile := filepath.Join(RepoCache(), "sdks", TarballName(version))
tarURL := TarballURL(version)
return DownloadSignedFile(tarFile, tarURL, nil, verifyKeyFile)
}

// false if both files do not exist
func cmpFileBytes(file1, file2 string) (bool, error) {
info1, err := os.Stat(file1)
Expand Down
Loading