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

charm-build --write-lock-file fails to pick up master branch for interface:ceph-mds #604

Open
3 tasks done
ajkavanagh opened this issue Apr 7, 2021 · 1 comment
Open
3 tasks done
Assignees

Comments

@ajkavanagh
Copy link
Contributor

Checklist

  • Confirmed this is an issue with charm-tools, not charmstore-client
  • Provide versions of tools used
  • Described the feature or ways to replicate the issue

What version am I running?

I ran the following command: snap info charm and got the following ouput:

charm-tools 2.8.3 from PyPi

I am using: Ubuntu 20.04

Issue/Feature

Adding a build.lock file is done with charm-build --log-level DEBUG --write-lock-file …

This creates the build.lock file and records the branch against the git hash for the repository for the layer/interface. However, it's doesn't seem to record a branch for interface:ceph-mds which results in bug #603 if the build.lock is attempted to be build using branches.

I expect/expected the following

I expected the branch refs/heads/master to be recorded against interface:ceph-mds

What I got

    {
      "type": "layer",
      "item": "interface:ceph-mds",
      "url": "https://opendev.org/openstack/charm-interface-ceph-client.git",
      "vcs": null,
      "branch": null,
      "commit": "72245e1d002fb9c65c9574d65b5952275b3411fb"
    },

Contrast with:

    {
      "type": "layer",
      "item": "layer:ceph",
      "url": "https://github.com/openstack/charm-layer-ceph.git",
      "vcs": null,
      "branch": "refs/heads/master",
      "commit": "17d40abd8d9ec3b8c32756ca981c80c4733c016f"
    },
@ajkavanagh ajkavanagh self-assigned this Apr 7, 2021
@ajkavanagh
Copy link
Contributor Author

The reason is fails to pick up the branch is due to interface:ceph-mds being a sub-directory-of-a-git-repository interface/layer which means that when it is copied the .git directory is not copied and so the branch can't be found. A bit of debug gives:

get_branch_for_revision: /home/alex/.cache/charm/2429380/interface/ceph-mds
... got error:  fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

where get_branch_for_revision is (with some added debug):

    def get_branch_for_revision(self, dir_, revision=None):
        """Returns None if the revision doesn't match the actual branch name"""
        print("get_branch_for_revision:", dir_)
        if revision is None:
            revision = self.revision
        if not revision:
            print("... no revision?", revision)
            return None
        for cmd in ("git branch --contains {} --format=\"%(refname)\""
                    .format(revision), ):
            try:
                branch = check_output(cmd, cwd=dir_).decode('UTF-8').strip()
                return branch
            except FetchError as e:
                print("... got error: ", e)
                continue
        return None

The fix will have to be to call get_branch_for_revision on the uncopied repository rather than the copied interface/layer. Might be tricky to organise that in the code.

openstack-mirroring pushed a commit to openstack/charm-gnocchi that referenced this issue Oct 18, 2021
The python lib pins are for py35 compatability.  The branch issue is due
to bug juju/charm-tools#604

* Also add cffi pin for py35 for charm-tools build support.

Change-Id: I2ac189816b1e133ff8468d4722ce87da48b85c0b
openstack-mirroring pushed a commit to openstack/charm-ceph-fs that referenced this issue Oct 19, 2021
Due to juju/charm-tools#604 writing the
build.lock fails when the interface:ceph-mds file is in the build.
Update the build.lock with the commit as the branch.

Change-Id: I4ad693c87e2dbcdcec2eba316ababdd5449e5e67
openstack-mirroring pushed a commit to openstack/charm-manila-ganesha that referenced this issue Oct 21, 2021
* Also add cffi pin for py35 for charm-tools build support.
* This charm is broken at this state (as a 21.10 candidate), but will be
  fixed via a cherry pick of I4e63e64612554d74ffaca5c4e07b90f7ceb88d59
  which resolves the hacluster 'common.py' import and also restarting
  services after config-changed.

This is juju/charm-tools#604.

Change-Id: I00f4bc8251d9dc5e8f082539dfff96b972e115d2
lmlg pushed a commit to lmlg/charm-ceph-fs that referenced this issue May 23, 2024
Due to juju/charm-tools#604 writing the
build.lock fails when the interface:ceph-mds file is in the build.
Update the build.lock with the commit as the branch.

Change-Id: I4ad693c87e2dbcdcec2eba316ababdd5449e5e67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant