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

GlobalBuildInfo plugin should search packed references for commit IDs #47464

Merged

Conversation

williamrandolph
Copy link
Contributor

@williamrandolph williamrandolph commented Oct 2, 2019

After a git garbage collection, I was unable to run ./gradlew commands.

My failures were as follows:


FAILURE: Build failed with an exception.

* Where:
Build file '/Users/wbrafford/work/repos/elasticsearch/build.gradle' line: 37

* What went wrong:
An exception occurred applying plugin request [id: 'elasticsearch.global-build-info']
> Failed to apply plugin [id 'elasticsearch.global-build-info']
   > unable to read the git revision

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

If you have version 2.23.0 of git, you should be able to reproduce after running:

git pack-refs --all

Documentation on git-pack-refs is here: https://git-scm.com/docs/git-pack-refs

This code needs a couple of improvements (for example, there's no check for the existence of the packed-refs file), but I'm going ahead and posting the PR for discussion.

In recent versions of Git, references may be packed in a packed-refs
file. If this happens, Gradle will need to look in that file to find
build information.
@williamrandolph williamrandolph added the :Delivery/Build Build or test infrastructure label Oct 2, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Build)

Copy link
Contributor

@mark-vieira mark-vieira left a comment

Choose a reason for hiding this comment

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

Couple of comments, otherwise LGTM. Thanks for catching this @williamrandolph.

revision = readFirstLine(refFile);
} else {
// Check packed references for commit ID
Pattern p = Pattern.compile("^([a-f0-9]+) " + branchname + "$");
Copy link
Contributor

Choose a reason for hiding this comment

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

We could make this even more strict since we know a sha1 hash is 40 characters with [a-f0-9]{40}.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, do we know what the entries that look like ^6d5d330548f66c1ba6d2913737ba93c5d5a39de9 mean? I couldn't find any documentation describing the actual format of this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the last lines of my .git/packed-refs file…

d7d5b3fbc408e3b4060d9df33dec9c43e29e9cbb refs/tags/v7.4.0
^22e1767283e61a198cb4db791ea66e3f11ab9910

It looks like we get that carrot notation when Elasticmachine tags a release. I'm not sure what the specific terminology is, but 22e17672 is the commit that's tagged for 7.4 and git show d7d5b3fbc shows the tag. Perhaps the first line represents the "annotated tag object"? I wouldn't want to try to get any more definitive without finding the format documentation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious mostly. Seems we can safely ignore those entries.

The Files.readLines method needs to be used in a try-with-resources
block. Also, we can be more specific in the regex, and what was the
"branchname" variable should really be called "refName".
@williamrandolph
Copy link
Contributor Author

@elasticmachine Please run elasticsearch-ci/2

@mark-vieira
Copy link
Contributor

@williamrandolph I think this is in a state where it can be merged once the conflicts are resolved. Let's not let this branch get any more stale than it is.

@williamrandolph
Copy link
Contributor Author

@elasticmachine please run elasticsearch-ci/packaging-sample-matrix

@williamrandolph
Copy link
Contributor Author

@elasticmachine please run elasticsearch-ci/2

@williamrandolph williamrandolph changed the title WIP: GlobalBuildInfo plugin should search packed references for commit IDs GlobalBuildInfo plugin should search packed references for commit IDs Oct 10, 2019
@williamrandolph williamrandolph merged commit 2488214 into elastic:master Oct 10, 2019
@williamrandolph williamrandolph deleted the buildinfo-with-packed-refs branch October 11, 2019 16:03
williamrandolph added a commit to williamrandolph/elasticsearch that referenced this pull request Oct 11, 2019
…elastic#47464)

* GlobalBuildInfo plugin searches packed references

In recent versions of Git, references may be packed in a packed-refs
file. If this happens, Gradle will need to look in that file to find
build information.
williamrandolph added a commit to williamrandolph/elasticsearch that referenced this pull request Oct 11, 2019
…elastic#47464)

* GlobalBuildInfo plugin searches packed references

In recent versions of Git, references may be packed in a packed-refs
file. If this happens, Gradle will need to look in that file to find
build information.
williamrandolph added a commit to williamrandolph/elasticsearch that referenced this pull request Oct 11, 2019
…elastic#47464)

* GlobalBuildInfo plugin searches packed references

In recent versions of Git, references may be packed in a packed-refs
file. If this happens, Gradle will need to look in that file to find
build information.
williamrandolph added a commit that referenced this pull request Oct 11, 2019
…#47464) (#47936)

* GlobalBuildInfo plugin searches packed references

In recent versions of Git, references may be packed in a packed-refs
file. If this happens, Gradle will need to look in that file to find
build information.
williamrandolph added a commit that referenced this pull request Oct 11, 2019
…#47464) (#47938)

* GlobalBuildInfo plugin searches packed references

In recent versions of Git, references may be packed in a packed-refs
file. If this happens, Gradle will need to look in that file to find
build information.
williamrandolph added a commit that referenced this pull request Oct 14, 2019
…#47464) (#47942)

* GlobalBuildInfo plugin searches packed references

In recent versions of Git, references may be packed in a packed-refs
file. If this happens, Gradle will need to look in that file to find
build information.
henningandersen added a commit to henningandersen/elasticsearch that referenced this pull request Jan 9, 2020
The packed-refs support was using the original .git path, changed to use
the real .git directory after reference from worktree has been followed.

Relates elastic#47464
henningandersen added a commit that referenced this pull request Jan 10, 2020
The packed-refs support was using the original .git path, changed to use
the real .git directory after reference from worktree has been followed.

Relates #47464
henningandersen added a commit that referenced this pull request Jan 10, 2020
The packed-refs support was using the original .git path, changed to use
the real .git directory after reference from worktree has been followed.

Relates #47464
henningandersen added a commit that referenced this pull request Jan 10, 2020
The packed-refs support was using the original .git path, changed to use
the real .git directory after reference from worktree has been followed.

Relates #47464
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
The packed-refs support was using the original .git path, changed to use
the real .git directory after reference from worktree has been followed.

Relates elastic#47464
henningandersen added a commit that referenced this pull request Jan 23, 2020
The packed-refs support was using the original .git path, changed to use
the real .git directory after reference from worktree has been followed.

Relates #47464
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Build Build or test infrastructure Team:Delivery Meta label for Delivery team v6.8.4 v7.4.1 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants