-
Notifications
You must be signed in to change notification settings - Fork 258
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
Check content-type in importer to warn against unexpected kubevirt imports #2909
Conversation
a1fff18
to
951735b
Compare
So IIUC the tests fail because our local test servers return |
That's it, still have to check if it's our proxy who's behaving badly or just something we should allow (maybe just avoid text/html type). |
951735b
to
6933239
Compare
Following some offline discussions, I've been toying with the idea of having a Prometheus metric to get important import information into the PVC or DataVolume (like this specific case). However, I think this might be outside the scope of the PR so we can merge this and groom the idea a bit further. Rejecting the import seems overkill, I think CDI is functioning as expected right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
pkg/importer/http-datasource.go
Outdated
nbdkitSocket = "/tmp/nbdkit.sock" | ||
defaultUserAgent = "cdi-golang-importer" | ||
httpContentType = "Content-Type" | ||
httpContentLenght = "Content-Length" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lenght typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fixed!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: akalenyu 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 |
…t imports This commit adds a check in the http-datasource format reader to trigger a warning when importing unexpected content-types. Signed-off-by: Alvaro Romero <alromero@redhat.com>
6933239
to
5a3de5a
Compare
/retest-required |
/test pull-containerized-data-importer-e2e-nfs |
/hold |
/unhold |
/test pull-cdi-linter |
This commit adds a test to cover a import with unexpected content-type. It also updates the badserver to allow mocking this behavior. Signed-off-by: Alvaro Romero <alromero@redhat.com>
4445174
to
4fe9f7d
Compare
/retest-required |
/lgtm |
/cherrypick release-v1.58 |
@awels: once the present PR merges, I will cherry-pick it on top of release-v1.58 in a new PR and assign it to you. In response to this:
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. |
@awels: new pull request created: #2975 In response to this:
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. |
What this PR does / why we need it:
In some network environments, proxy servers or firewalls may block access to certain external resources. Although we'd expect them to return a 4xx (Forbidden/Unauthorized) error code, some of these servers return an HTML error page and a 200 error code. Currently, CDI checks if the content is compressed or a qcow2 image. If neither of these are detected it assumes it is a raw disk image.
Even though these servers are misbehaving we can provide a better experience. When importing an kubevirt disk image using a DataVolume, we can also check the HTTP content-type header. If the media type is reported as 'text/html' (or text/*) we can assume that the server has sent a notice page instead of the requested content.
This pull request adds a log message to warn against the described behavior.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Release note: