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

RFC: Follow redirects when downloading assets for cloning #5335

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/OpenQA/Script/CloneJob.pm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ sub clone_job_download_assets ($jobid, $job, $url_handler, $options) {

print STDERR "downloading\n$from\nto\n$dst\n";
my $r = $ua->mirror($from, $dst);
$r = $ua->mirror($r->header('Location'), $dst) if ($r->code == 308);
Copy link
Contributor

Choose a reason for hiding this comment

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

What if Location is undef? What if there's yet another redirection? We should also not follow a location from https to http.

Copy link
Contributor

Choose a reason for hiding this comment

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

But generally a good idea of course.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Martchus FYI in my case it was the redirect from http to https on o3.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know. I pointed that out in the chat. And we should of course allow this case. What we should not allow is the opposite for security reasons.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a comment that this is a temporary fix until LWP 6.48 is available on all our supported platforms?

Copy link
Contributor

Choose a reason for hiding this comment

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

@kalikiana I suppose this is expected you add before merge, right @okurz ?

Copy link
Member

Choose a reason for hiding this comment

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

yes, or anyone else who can add a commit to this PR

Copy link
Member

Choose a reason for hiding this comment

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

Apparently we can't achieve with a reasonable effort to update LWP in SLE/Leap hence we need to keep this workaround in place until eventually we use only more recent versions in newer OS versions

Suggested change
$r = $ua->mirror($r->header('Location'), $dst) if ($r->code == 308);
# Workaround for behaviour LWP < 6.48, see https://github.com/libwww-perl/libwww-perl/pull/349
$r = $ua->mirror($r->header('Location'), $dst) if $r->code == 308;

Copy link
Member Author

Choose a reason for hiding this comment

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

@pevik Maybe it's best if you take over from here? I don't even remember what issue this was addressing.

unless ($r->is_success || $r->code == 304) {
print STDERR "$jobid failed: $file, ", $r->status_line, "\n";
die "Can't clone due to missing assets: ", $r->status_line, " \n"
Expand Down
Loading