sous-chefs / sous-chefs/github

Download failure leaves invalid file

Open
#9 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Ruby
Stars
25
Forks
25
Avg merge
5h 40m
Merged PRs (30d)
1

Description

I just ran into an issue where Github failed to serve up a file properly, and that prevented all future runs of my cookbook from converging successfully.

The github_asset resource downloads directly into the destination file (/var/chef/cache/github_assets/org/repo/version/foo-version.tar.gz). If the download fails it leaves a zero-length archive behind with that name, and future cookbook runs don't re-download the file because the zero-length file exists. See https://github.com/reset/github-cookbook/blob/master/libraries/github_asset.rb#L94.

Suggested solution: download to a temporary file and rename it if the download completes successfully. I suggest downloading to a temporary name in the same directory so that the rename step doesn't also require a copy, if (for example) the /tmp directory is on a different volume than the /var/chef/cache/github_assets directory.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading libraries/github_asset.rb around line 94, where the download writes to the destination path. Verify the failure behavior and the existing resource flow, then ensure a failed download does not leave the destination archive while a successful download produces it through the temporary-file flow described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
github, ruby
Domain
devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.