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

[WSL-369] Cache rootfs every night #345

Merged
merged 16 commits into from
Jan 30, 2023
Merged

[WSL-369] Cache rootfs every night #345

merged 16 commits into from
Jan 30, 2023

Conversation

EduardGomezEscandell
Copy link
Collaborator

@EduardGomezEscandell EduardGomezEscandell commented Jan 13, 2023

Rootfs download is an expensive part of the E2E CI run. This PR sets a cron job that will download the rootfs every night. e2e workflows will be able to use this.

To avoid having yet another place that we need to update every time a new release comes out, some parts of wsl-builder/prepare-build/buildGHMatrix.go were extracted into the common package, and a new executable release-info is built to access this data:

PS> release-info.exe --help
This tool shows information about any WSL release. Write no distro to see all of them.
Fields are always in the same order, regardless of the order the flags are passed in.

Usage:
  release-info CSV_FILE [DISTRO...] [--app-id] [--full-name] [--code-name] [--launcher] [--rootfs Arch] [--short] [flags]

Flags:
      --app-id          Display the App ID as shown in the store.
      --code-name       Display the code name, i.e. the distro's adjective.
      --full-name       Display the App FullName as shown in your machine.
  -h, --help            help for release-info
      --launcher        Display the launcher executable name.
      --rootfs string   Display the URL where the rootfs can be downloaded.
  -s, --short           Don't display the table header.

Example output:

PS > .\release-info.exe .\ubuntu-releases.csv Ubuntu Ubuntu-Preview Ubuntu-18.04 --rootfs amd64 --launcher --full-name
WslID           FullName            Launcher           Rootfs
Ubuntu-Preview  Ubuntu (Preview)    ubuntupreview.exe  https://cloud-images.ubuntu.com/wsl/lunar/current/ubuntu-lunar-wsl-amd64-wsl.rootfs.tar.gz
Ubuntu-18.04    Ubuntu 18.04.5 LTS  ubuntu1804.exe     https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64-wsl.rootfs.tar.gz
Ubuntu          Ubuntu              ubuntu.exe         https://cloud-images.ubuntu.com/wsl/jammy/current/ubuntu-jammy-wsl-amd64-wsl.rootfs.tar.gz

@EduardGomezEscandell EduardGomezEscandell added e2e automation RElating to CI/CD or other automated tasks labels Jan 13, 2023
@EduardGomezEscandell EduardGomezEscandell self-assigned this Jan 13, 2023
@EduardGomezEscandell EduardGomezEscandell changed the title Cache rootfs every night [WSL-369] Cache rootfs every night Jan 13, 2023
"errors"
"os"

"github.com/0xrawsec/golang-utils/log"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This import seems suspicious. Are you sure it is what you intended it to be? I don't see a lot of activity in that repository.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair enough, I replaced it with Fprintf since we don't really need a log for such small executable.

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 think we don’t really need log here. Once this proposal is settled (https://go.googlesource.com/proposal/+/master/design/56345-structured-logging.md), we will be able to standardize around it for all our packages and binaries.

Copy link
Member

@didrocks didrocks left a comment

Choose a reason for hiding this comment

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

I think this is it for a first round. There will need to be another review as I think the code is going to change a bit with those suggestions :)

wsl-builder/release-info/main.go Outdated Show resolved Hide resolved
wsl-builder/release-info/main.go Outdated Show resolved Hide resolved
wsl-builder/release-info/main.go Show resolved Hide resolved
wsl-builder/release-info/release-info.go Outdated Show resolved Hide resolved
wsl-builder/release-info/release-info.go Outdated Show resolved Hide resolved
wsl-builder/release-info/release-info.go Outdated Show resolved Hide resolved
wsl-builder/release-info/release-info.go Outdated Show resolved Hide resolved
wsl-builder/release-info/release-info.go Outdated Show resolved Hide resolved
wsl-builder/release-info/release-info.go Outdated Show resolved Hide resolved
wsl-builder/common/releasesinfo.go Outdated Show resolved Hide resolved
@EduardGomezEscandell
Copy link
Collaborator Author

Quite the review haha. I applied most of the changes you suggested and made the rest obsolete by simplifying the program.

I was being fancy with a degraded output but there really is no need for that complexity.

Copy link
Collaborator

@CarlosNihelton CarlosNihelton left a comment

Choose a reason for hiding this comment

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

One minor concern about the imports.

wsl-builder/release-info/go.mod Show resolved Hide resolved
wsl-builder/release-info/release-info.go Show resolved Hide resolved
Piping on Windows doesn't work because .\lp-distro-info > $file
stores it UTF-16 encoded with the BOM. This breaks the csv package in
Go, which is used to parse this program's output. The solution is to
implement:
    lp-distro-info -o $file
where the default output is stdout to maintain backwards-compatibility.
Some code had to be factored out of prepare-build so as to have a single
implementation of the rootfs URL generator.
@EduardGomezEscandell EduardGomezEscandell merged commit 69e8702 into main Jan 30, 2023
@EduardGomezEscandell EduardGomezEscandell deleted the cache-rootfs branch January 30, 2023 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation RElating to CI/CD or other automated tasks e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants