Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

fix: cdn-source pattern supports range task #1259

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

lowzj
Copy link
Member

@lowzj lowzj commented Mar 24, 2020

Signed-off-by: lowzj [email protected]

Ⅰ. Describe what this PR did

#1213 has support cdn source pattern. The download behavior is different when user wants to download a part of the source file, just like:

dfget -u $url -o /tmp/a.test --header "Range:bytes=1-9000000"
  1. download piece from source: the range of piece get from supernode is not the real range of the source file, so dfget should correct it based on the Range header passed by user.
  2. download from peer: the range of piece get from supernode is the range of file stored on the other peers, so dfget can directly use it.

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@pouchrobot pouchrobot added kind/bug This is bug report for project size/M labels Mar 24, 2020
@lowzj lowzj force-pushed the cdnPattern-support-range branch from 4127cbe to 8b0ad1a Compare March 24, 2020 08:55

return httputils.HTTPGetTimeout(url, headers, timeout)
}

func isFromSource(req *DownloadRequest) bool {
return req != nil && strings.Contains(req.Path, "://")
Copy link
Contributor

Choose a reason for hiding this comment

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

It is not enough to judge that req is not nil here.

// pieceRange: "start-end"
// rangeHeaderValue: "bytes=sourceStart-sourceEnd"
// return: "bytes=realStart-realEnd"
func getRealRange(pieceRange string, rangeHeaderValue string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

How about adding a unit test for this function. 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@starnop
Copy link
Contributor

starnop commented Mar 24, 2020

Please add a description for this PR, such as:

  1. why did you submit the PR
  2. how to use it with range task and the related scenarios

return httputils.ConstructRangeStr(fmt.Sprintf("%d-%d", realStart, realEnd))
}

func parseRange(rangeStr string) (int64, int64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@lowzj lowzj force-pushed the cdnPattern-support-range branch from 8b0ad1a to 461f258 Compare March 24, 2020 09:57
@pouchrobot pouchrobot added size/L and removed size/M labels Mar 24, 2020
@lowzj lowzj force-pushed the cdnPattern-support-range branch from 461f258 to 2e118bf Compare March 24, 2020 10:07
@pouchrobot pouchrobot added size/XL and removed size/L labels Mar 24, 2020
@lowzj lowzj force-pushed the cdnPattern-support-range branch from 2e118bf to 7719400 Compare March 24, 2020 10:25
@pouchrobot pouchrobot added size/L and removed size/XL labels Mar 24, 2020
@codecov-io
Copy link

codecov-io commented Mar 24, 2020

Codecov Report

Merging #1259 into master will increase coverage by 0.24%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1259      +/-   ##
==========================================
+ Coverage   48.51%   48.75%   +0.24%     
==========================================
  Files         121      119       -2     
  Lines        7788     7763      -25     
==========================================
+ Hits         3778     3785       +7     
+ Misses       3698     3663      -35     
- Partials      312      315       +3     
Impacted Files Coverage Δ
supernode/daemon/mgr/cdn/manager.go 20.86% <0.00%> (ø)
supernode/daemon/mgr/task/manager.go 28.57% <0.00%> (ø)
supernode/daemon/mgr/task/manager_util.go 22.82% <0.00%> (ø)
supernode/server/0.3_bridge.go 0.00% <0.00%> (ø)
dfget/core/api/download_api.go 25.58% <37.93%> (+25.58%) ⬆️
pkg/rangeutils/range_util.go 100.00% <100.00%> (ø)
supernode/daemon/mgr/cdn/downloader.go 78.94% <100.00%> (ø)
supernode/daemon/mgr/scheduler/manager.go 21.91% <0.00%> (-0.69%) ⬇️
supernode/util/count_rw_mutex.go
supernode/util/locker.go

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a4e7b0...ef57720. Read the comment docs.

@lowzj lowzj force-pushed the cdnPattern-support-range branch from 7719400 to e7b6c69 Compare March 24, 2020 10:41
@pouchrobot pouchrobot added size/XL and removed size/L labels Mar 24, 2020
@lowzj lowzj force-pushed the cdnPattern-support-range branch from e7b6c69 to 96e66ff Compare March 24, 2020 14:41
@lowzj
Copy link
Member Author

lowzj commented Mar 25, 2020

@starnop PTAL

{"0-1", "", "0-1"},
{"0-1", "1-100", "1-2"},
{"0-100", "1-100", "1-100"},
{"100-100", "1-100", "101-100"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Is end less than start as expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this function just do compute the real range the user want to download but not do verify. The verification is done by the remote server.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

@lowzj lowzj force-pushed the cdnPattern-support-range branch from 96e66ff to 6673cc6 Compare March 30, 2020 03:53
@starnop
Copy link
Contributor

starnop commented Mar 30, 2020

LGTM.

@starnop
Copy link
Contributor

starnop commented Mar 31, 2020

@lowzj In additional, should we support range task for non-cdn-source pattern?

@lowzj
Copy link
Member Author

lowzj commented Apr 7, 2020

@lowzj In additional, should we support range task for non-cdn-source pattern?

It has already supported.

@lowzj lowzj force-pushed the cdnPattern-support-range branch from 6673cc6 to ef57720 Compare April 7, 2020 01:23
@starnop
Copy link
Contributor

starnop commented Apr 8, 2020

@lowzj In additional, should we support range task for non-cdn-source pattern?

It has already supported.

👍 Merging......

@starnop starnop merged commit 3d28168 into dragonflyoss:master Apr 8, 2020
@lowzj lowzj deleted the cdnPattern-support-range branch April 9, 2020 00:09
sungjunyoung pushed a commit to sungjunyoung/Dragonfly that referenced this pull request May 8, 2022
…easer (dragonflyoss#1259)

add goreleaser dfcache rpm/deb packages and man pages

Note that dfcache*.md files are generated by `dfcache doc` command.

Signed-off-by: Eryu Guan <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug This is bug report for project size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants