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 new DV reason: ImagePullFailed #3194

Merged
merged 1 commit into from
Apr 18, 2024

Conversation

nunnatsa
Copy link
Contributor

@nunnatsa nunnatsa commented Apr 14, 2024

What this PR does / why we need it

When the image pull fails, the DataVolume Running condition, will have the Reason field of ImagePullFailed, to allow better error handling in code that uses it.

Also, moved the StreamDataToFile function from the util package to the importer package, and made to non-exported. This is done to allow calling the new NewErrImagePullFailed function from within streamDataToFile, and to avoid import cycle. In addition, the streamDataToFile is only used in the importer package and so it's better to define it there.

Release note

When the image pull fails, the DataVolume Running condition, will have the Reason field of "ImagePullFailed"
https://issues.redhat.com/browse/CNV-39603

@kubevirt-bot kubevirt-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Apr 14, 2024
@nunnatsa nunnatsa force-pushed the image-pull-failed branch 2 times, most recently from 0174c9a to 82814e2 Compare April 14, 2024 10:25
@nunnatsa
Copy link
Contributor Author

/test pull-containerized-data-importer-e2e-ceph-wffc

@nunnatsa nunnatsa changed the title WIP: Add new DV reason: ImagePullFailed Add new DV reason: ImagePullFailed Apr 14, 2024
@kubevirt-bot kubevirt-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 14, 2024
Copy link
Member

@awels awels left a comment

Choose a reason for hiding this comment

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

Looks like most of this PR is not actually related to returning the error message, but in moving the StreamDataToFile function. Other than that some minor comments.


ipfErr := &importer.ErrImagePullFailed{}
isImagePullFailure := errors.As(err, &ipfErr)
if isImagePullFailure {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just do

if errors.As(err, &ipfErr) {
  err = ipfErr
}

Also if the As is true, isn't err already the right type? I am not entirely I understand what is going on here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't need the boolean here. leftover from another implementation during the development. Will fix.

The As function does not change err but only populate ipfErr

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In 2nd thought, I don't need this code at all. I was trying to write a new field in the TerminationMessage object, but this is not working anyway for other reasons.

I'm now relaying on the error text, that is still there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed this code


},
Entry("insecure registry", "registry:5000/myimage:latest"),
Entry("non exists image", "quay.io/capk/ubuntu-2004-container-disk:wrong"),
Copy link
Member

Choose a reason for hiding this comment

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

Should not be a real issue, but maybe reference the internal registry here with an invalid image. This now assumes you have access to the internet, which may not always be valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any other idea?

Copy link
Collaborator

@akalenyu akalenyu left a comment

Choose a reason for hiding this comment

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

Thanks!
Had some minor comments but what's more interesting to me is why we can't use the termination message API in case of failures.
Is there something missing in it's implementation? I won't ofcourse block over this

tests/import_test.go Outdated Show resolved Hide resolved
tests/import_test.go Outdated Show resolved Hide resolved
@nunnatsa
Copy link
Contributor Author

Thanks! Had some minor comments but what's more interesting to me is why we can't use the termination message API in case of failures. Is there something missing in it's implementation? I won't ofcourse block over this

the termination message API (object) is only available for pod that was terminated with no error. For error cases, the pod write unstructed text, and I didn't want to change this behavior because it's way out of the scope of this PR.

@nunnatsa
Copy link
Contributor Author

nunnatsa commented Apr 16, 2024

e, but in moving the StreamDataToFile function. Other than that some minor comments.

Eventually, yes. But this is not the "why". I moved the function because I wanted to call the NewErrImagePullFailed function from it, and this function is defined in the importer package. Then I found out that the StreamDataToFile function only called from the importer package. So to avoid import cycle, I moved the function, but this is not the reason for this change.

Updated PR description to include this info.

@nunnatsa
Copy link
Contributor Author

/retest

Copy link
Collaborator

@akalenyu akalenyu left a comment

Choose a reason for hiding this comment

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

Looks good! thanks

Correct me if I'm wrong but this PR does not handle pullMethod: node (this is fine),
which I thought is quite common on OpenShift. Are you okay with that?

When the image pull fails, the DataVolume Running condition, will have
the Reason field of `ImagePullFailed`, to allow better error handling in
code taht uses it.

Signed-off-by: Nahshon Unna-Tsameret <nunnatsa@redhat.com>
@nunnatsa
Copy link
Contributor Author

^^^ fixed new linter warning

@nunnatsa
Copy link
Contributor Author

/retest

Copy link
Collaborator

@akalenyu akalenyu left a comment

Choose a reason for hiding this comment

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

/approve


},
Entry("pull method = pod", "myregistry/myorg/myimage:wrongtag", cdiv1.RegistryPullPod),
Entry("pull method = node", "myregistry/myorg/myimage:wrongtag", cdiv1.RegistryPullNode),
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 18, 2024
@nunnatsa
Copy link
Contributor Author

/test pull-containerized-data-importer-e2e-upg

@awels
Copy link
Member

awels commented Apr 18, 2024

/lgtm
/approve
/cherrypick release-v1.59

@kubevirt-bot
Copy link
Contributor

@awels: once the present PR merges, I will cherry-pick it on top of release-v1.59 in a new PR and assign it to you.

In response to this:

/lgtm
/approve
/cherrypick release-v1.59

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akalenyu, awels

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

@nunnatsa
Copy link
Contributor Author

/test pull-containerized-data-importer-e2e-upg

@kubevirt-bot kubevirt-bot merged commit 475a70c into kubevirt:main Apr 18, 2024
17 of 18 checks passed
@kubevirt-bot
Copy link
Contributor

@awels: new pull request created: #3210

In response to this:

/lgtm
/approve
/cherrypick release-v1.59

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@nunnatsa nunnatsa deleted the image-pull-failed branch April 18, 2024 19:20
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/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants