Skip to content

Add images verify cmd #18

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

Merged
merged 14 commits into from
Apr 21, 2022
Merged

Add images verify cmd #18

merged 14 commits into from
Apr 21, 2022

Conversation

0xFelix
Copy link
Member

@0xFelix 0xFelix commented Mar 29, 2022

What this PR does / why we need it:

This adds the cmd 'images verify', which verifies that previously built
and pushed containerdisks are bootable and that guests are working.

The example definitions of the docs are used to test containerdisks by
creating VMs with the respective containerdisk set as the boot source.
After waiting for a VM to become ready, a defined set of tests is run on
the corresponding VMI. If all tests succeed, the value of the containerdisk
annotation 'verified' is set to 'true' and the updated image manifest is
pushed to the registry.

Which issue(s) this PR fixes:

Fixes #2

Special notes for your reviewer:

Merge after #17

Release note:

Add cmd to verify freshly built containerdisks

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Mar 29, 2022
@0xFelix
Copy link
Member Author

0xFelix commented Mar 29, 2022

/cc @akrejcir

@kubevirt-bot kubevirt-bot added dco-signoff: no Indicates the PR's author has not DCO signed all their commits. and removed dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Mar 30, 2022
@0xFelix 0xFelix force-pushed the images-verify branch 3 times, most recently from 28911f1 to 86d7f7d Compare March 31, 2022 14:27
@kubevirt-bot kubevirt-bot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. and removed dco-signoff: no Indicates the PR's author has not DCO signed all their commits. labels Mar 31, 2022
@0xFelix 0xFelix force-pushed the images-verify branch 2 times, most recently from 21097ee to caa7c30 Compare March 31, 2022 14:33
@0xFelix
Copy link
Member Author

0xFelix commented Mar 31, 2022

@rmohr Can you please have a look again? I addressed your comments.

@0xFelix 0xFelix requested a review from rmohr March 31, 2022 14:37
@kubevirt-bot kubevirt-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 31, 2022
0xFelix added 3 commits April 1, 2022 08:27
This prevents a segfault when an unexpected error occurs, which cannot
be unwrapped (e.g. tls verification error on insecure registry).

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Do not always log 'Pushing' and let the user know what is really
happening instead.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Copy link
Member

@rmohr rmohr left a comment

Choose a reason for hiding this comment

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

Overall pretty nice, I have one conceptual question.

0xFelix added 6 commits April 12, 2022 13:06
This moves the worker logic for image cmds into a separate file, so it
can be used in multiple image cmds. The logic was also refactored, so it
is easier to use, supports contexts and duplicated code during use is prevented.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
This moves the PushImage function into the repository package to make it
available for use in other image cmds. Also use the uniform identifier
'imgRef' for images.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
The function tarball.LayerFromReader internally uses iotuil.ReadAll, which
buffers all data in memory and can lead to problems with large files.
Replace it with tarball.LayerFromOpener and implement a StreamLayerOpener,
that does not return an error chan and can be opened multiple times.

Thanks to akrejcir for the idea and proposal.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
The methods for creating example VM definitons are added to the artifact
interface so correct definitions for each type of guest can be created.
This also allows to test the example definitions in another command
(e.g. images verify).

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
The removed code added the main version of the CentOS Stream artifact to
AdditionalUniqueTags which is not an additional unique tag.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
Copy link
Member

@rmohr rmohr left a comment

Choose a reason for hiding this comment

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

Pretty close. Not sure if you agree, but looks much simpler now than before to me. One recommendation regarding to the result handing which I would love to see.

@0xFelix
Copy link
Member Author

0xFelix commented Apr 13, 2022

@rmohr I agree, it is simpler now. The commit changing to OCIv1 could be useful in the future perhaps. I addressed your change request. Does it look good now?

@0xFelix
Copy link
Member Author

0xFelix commented Apr 13, 2022

@rmohr I just noticed I could move the --workers and --results-file flags to the imagesCmd. Do you agree?

@rmohr
Copy link
Member

rmohr commented Apr 13, 2022

@rmohr I just noticed I could move the --workers and --results-file flags to the imagesCmd. Do you agree?

sounds good. 👍

0xFelix added 2 commits April 14, 2022 08:54
Flags that can be shared by image cmds are refactored into ImagesOptions
and moved to imagesCmd.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
With this change the 'images push' command writes a results file after
building and pushing containerdisks. The results file contains all built
images, their sha256 sum and the pushed tags.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
0xFelix added 3 commits April 14, 2022 09:39
This adds the cmd 'images verify', which verifies that previously built
and pushed containerdisks are bootable and that guests are working.

The example definitions of the docs are used to test containerdisks by
creating VMs with the respective containerdisk set as the boot source.
After waiting for a VM to become ready, a defined set of tests is run on
the corresponding VMI. If all tests succeed, the verified value of the
containerdisk is set to 'true' in the results file.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
The test checks if the agent is running on the guest by attempting to
get the guest os info from the agent.

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
The test checks if ssh is working on the guest by attempting to use the
credentials generated by images verify to login into the guest and to
run a simple command (e.g. 'echo hello').

Signed-off-by: Felix Matouschek <fmatouschek@redhat.com>
@0xFelix
Copy link
Member Author

0xFelix commented Apr 14, 2022

@rmohr Mind giving it a look again?

@0xFelix 0xFelix requested review from rmohr and akrejcir April 20, 2022 07:50
Copy link
Member

@rmohr rmohr left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

I think this is good enough to take it in. If we want to improve stuff or detect issues we can follow up on it.

Great work!

PrivateKey interface{}
}

type ArtifactResult struct {
Copy link
Member

Choose a reason for hiding this comment

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

Since we kind of build a pipeline with the new commands, we probably want to add an indicator if something should have been created/verified but failed. We can do that in a follow up.

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 21, 2022
@kubevirt-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rmohr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 21, 2022
@kubevirt-bot kubevirt-bot merged commit 2b2810e into kubevirt:main Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add e2e tests to the images
4 participants