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

Add sonobuoy images list command #1639

Merged
merged 2 commits into from
Mar 18, 2022
Merged

Conversation

sathieu
Copy link
Contributor

@sathieu sathieu commented Mar 9, 2022

What this PR does / why we need it:

sonobuoy images prints the image list, but there is no dry-run. This PR adds a sonobuoy images list command with dry-run flag.

Which issue(s) this PR fixes

Special notes for your reviewer:

Release note:

Add sonobuoy images list command

Copy link
Contributor

@johnSchnake johnSchnake left a comment

Choose a reason for hiding this comment

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

Thanks for the submission!

Just a small change requested.

I'm curious what your use case is though; the dryrun client for list doesn't do anything particularly useful since its just hardcoded values for a hardcoded version.

We could add other versions and make that work but the concern is that it can get out of sync with the actual values and creates another dependency between us and the k8s releases.

In addition, the point of the images commands in general are to pull/push them to your airgapped registry; so if you can't reach the repos to pull/list them why list them in dry-run mode at all?

Comment on lines 102 to 116
var client image.Client
if flags.dryRun {
client = image.DryRunClient{}
} else {
client = image.NewDockerClient()
}
version, err := getClusterVersion(flags.k8sVersion, flags.kubeconfig)
if err != nil {
errlog.LogError(err)
os.Exit(1)
}
if err := listImages(flags.plugins, version, client); err != nil {
errlog.LogError(err)
os.Exit(1)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets extract that logic (since its ~15 lines repeated exactly) and use it as the run method. Just have the function take the imageFlags as an argument so that you can still make it a closure around the specific set of flag values:

Run: func(cmd *cobra.Command, args []string) {
    listImgs(flags)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

cmd/sonobuoy/app/images.go Show resolved Hide resolved
@sathieu
Copy link
Contributor Author

sathieu commented Mar 16, 2022

@johnSchnake I want to automate as much as possible. The script will do like this:

  1. get the sonobuoy version from a var
  2. sync the sonobuoy version to an offline registry
  3. run sonobuoy to get the systemd-logs image and the conformance image
  4. sync those two images
  5. run the conformance image to list e2e images
  6. sync those few images

The only missing part is step 3. This PR doesn't fill this need. Another flag should be added, or maybe the dry-run should not return e2e images at all. WDYT?

@sathieu
Copy link
Contributor Author

sathieu commented Mar 16, 2022

@johnSchnake I've pushed a newer commit with a new --e2e-images flag, defaulting to true. Please launch the CI and review 🙏.

@johnSchnake
Copy link
Contributor

For the systemd-logs image (and sonobuoy) you can run:

sonobuoy images -p systemd-logs

I would think the dry-run flag for the e2e plugin should just cause it to not run docker at all. So for e2e it should just figure out the image location and print that (and it seems the sonobuoy image is listed as well by default too).

Right now it seems to be hardcoded for the v1.19 version. As my previous comment mentioned, I dont think that provides much value.

I'm just not sure why step (5) is separated out from the e2e image itself. When you run sonobuoy images it also lists the conformance image itself.

So you can get all the images you need from:
sonobuoy images -p systemd-logs && sonobuoy images -p e2e

Either way, adding the dryrun flag and an explicit list command is fine with me though 👍 We can work out the proper behavior of dry-run in a follow-up.

And add --druy-run flag to sonobuoy images command

Signed-off-by: Mathieu Parent <[email protected]>
@sathieu
Copy link
Contributor Author

sathieu commented Mar 18, 2022

@johnSchnake Good catch, I've improved the PR to only change two things:

  • Add sonobuoy images list command (And add --druy-run flag to sonobuoy images command)
  • Return no e2e images instead of outdated info

So, the script would look like this:

  1. get the sonobuoy version from a var
  2. download the sonobuoy binary
  3. run sonobuoy images list --dry-run to get the sonobuoy, systemd-logs and conformance images
  4. sync those 3 images
  5. kubectl exec with command e2e.test --list-images on the conformance image to list e2e images
  6. sync those few images

Please retrigger the CI and review 🙏 .

NB: Some context here.

@johnSchnake
Copy link
Contributor

Just a bad import to fix; once that is done it looks great. Ran some manual checks locally.

I'll keep an eye out for the next fixup and if everything is green I'll merge. Thanks for the submission, I think this is great.

@sathieu
Copy link
Contributor Author

sathieu commented Mar 18, 2022

@johnSchnake Fixed the import error. Thanks!

@johnSchnake johnSchnake merged commit e8507f2 into vmware-tanzu:main Mar 18, 2022
@sathieu sathieu deleted the images_list branch March 18, 2022 19:00
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.

2 participants