chef / chef/chef-cli

"chef update" checks out a non-existent branch from a git repo

Open
#86 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Incomplete Type: Bug
Dominant language
Ruby
Stars
18
Forks
23
Avg merge
5d 17h
Merged PRs (30d)
1

Description

Description

When using a git source with a branch reference in Policyfile.rb, chef update checks out some commit from that git repository even though the upstream branch has been deleted.

ChefDK Version

┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_shared] - [2017-05-17 11:52:16]
└─[0] <git:(3041a1f 3041a1f) > chef --version
Chef Development Kit Version: 1.3.43
chef-client version: 12.19.36
delivery version: master (dd319aa632c2f550c92a2172b9d1226478fea997)
berks version: 5.6.4
kitchen version: 1.16.0

Platform Version

Arch Linux

Replication Case

With the following in Policyfile.rb:

cookbook 'cub_shared',
         git: 'ssh://git@stash.int.colorado.edu:7999/sc/cub_shared.git',
         branch: 'CF-596'

Running chef update succeeds and creates the following entry in Policyfile.lock.json:

    "cub_shared": {
      "version": "0.1.3",
      "identifier": "b413a721af9d7d677c7ff5c0ca71ae5cfe488262",
      "dotted_decimal_identifier": "50687104353541501.29128811626941041.191714426389090",
      "cache_key": "cub_shared-3041a1fbdab4fdbf3e92228c6438c19c7624a617",
      "origin": "ssh://git@stash.int.colorado.edu:7999/sc/cub_shared.git",
      "source_options": {
        "git": "ssh://git@stash.int.colorado.edu:7999/sc/cub_shared.git",
        "revision": "3041a1fbdab4fdbf3e92228c6438c19c7624a617",
        "branch": "CF-596"
      }
    },

However, the referenced branch does not exist:

┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_shared] - [2017-05-17 11:50:45]
└─[0] <git:(3041a1f 3041a1f) > git remote -v show
origin	ssh://git@stash.int.colorado.edu:7999/sc/cub_shared.git (fetch)
origin	ssh://git@stash.int.colorado.edu:7999/sc/cub_shared.git (push)
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_shared] - [2017-05-17 11:52:03]
└─[0] <git:(3041a1f 3041a1f) > git fetch -p
X11 forwarding request failed on channel 0
┌─[jay@bluejay] - [~/Work/git/cookbooks/cub_shared] - [2017-05-17 11:52:09]
└─[0] <git:(3041a1f 3041a1f) > git branch -r
  origin/GREQ0141247
  origin/HEAD -> origin/master
  origin/master

I would expect Chef to emit an error that it couldn't find the CF-596 branch instead of what actually happened.

The branch CF-596 was deleted from upstream some months ago, and the commit that chef checked out, 3041a1f, is not at the tip of master, nor do any other branches or tags point to it. So it seems that Chef is caching repo metadata somewhere.

Stacktrace

n/a

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 with the chef update path that resolves the git source declared in Policyfile.rb and inspect how its metadata is reused when writing Policyfile.lock.json. Reproduce the CF-596 example and verify that a deleted branch produces an error rather than selecting commit 3041a1f.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, ruby
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.