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

*: try to fix download racing bugs #2458

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/integrate-dm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
- name: Upload component log
if: ${{ failure() }}
# if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v3
with:
name: dm_logs
path: ${{ env.working-directory }}/dm.logs.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integrate-playground.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Upload component log
if: ${{ failure() }}
# if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v3
with:
name: playground_logs
path: ${{ env.working-directory }}/playground.logs.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/operation/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func Download(component, nodeOS, arch string, version string) error {
if err := repo.DownloadComponent(component, version, targetPath); err != nil {
return err
}
} else {
} else if version != "nightly" {
if err := repo.VerifyComponent(component, version, targetPath); err != nil {
os.Remove(targetPath)
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/repository/v1_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,16 @@ func (r *V1Repository) updateComponentManifest(id string, withYanked bool) (*v1m
// DownloadComponent downloads the component specified by item into local file,
// the component will be removed if hash is not correct
func (r *V1Repository) DownloadComponent(item *v1manifest.VersionItem, target string) error {
targetDir := filepath.Dir(target)
err := r.mirror.Download(item.URL, targetDir)
// make a tempdir such that every download will not inference each other
targetDir, err := os.MkdirTemp(filepath.Dir(target), "download")
if err != nil {
return err
}

if err := r.mirror.Download(item.URL, targetDir); err != nil {
return err
}

// the downloaded file is named by item.URL, which maybe differ to target name
if downloaded := path.Join(targetDir, item.URL); downloaded != target {
err := os.Rename(downloaded, target)
Expand Down
Loading