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

Make git revision loading lazy #45358

Merged
merged 1 commit into from
Aug 9, 2019
Merged

Make git revision loading lazy #45358

merged 1 commit into from
Aug 9, 2019

Conversation

rjernst
Copy link
Member

@rjernst rjernst commented Aug 8, 2019

This commit makes the gitRevision property a lazy loaded value by
returning an Object implementing toString(). The Dockerfile template is
also changed to use groovy templates instead of the mavenfilter hack, so
converting to String will not happen until runtime.

This commit makes the gitRevision property a lazy loaded value by
returning an Object implementing toString(). The Dockerfile template is
also changed to use groovy templates instead of the mavenfilter hack, so
converting to String will not happen until runtime.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

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.

One comment otherwise the LGTM 👍

});
private Object createGitRevisionResolver(final Project project) {
return new Object() {
private final AtomicReference<String> gitRevision = new AtomicReference<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better instead of making this an AtomicReference to simply synchronize these calls so we can avoid to possibility shelling to git multiple times if this is called concurrently? I think as it is we could do that and simply the first one would win.

Copy link
Member Author

Choose a reason for hiding this comment

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

While this is a possibility, I wasn't sure it was necessary to avoid. I figured it was better to make concurrent calls fast, if they happen (but it seems unlikely?). By synchronizing the method, we would still be single threading the method even after we've retrieved the hash.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's hard to say either way. I'm fine with leaving as is.

@rjernst rjernst merged commit 30a9a76 into elastic:master Aug 9, 2019
@rjernst rjernst deleted the docker1 branch August 9, 2019 00:07
rjernst added a commit that referenced this pull request Aug 9, 2019
This commit makes the gitRevision property a lazy loaded value by
returning an Object implementing toString(). The Dockerfile template is
also changed to use groovy templates instead of the mavenfilter hack, so
converting to String will not happen until runtime.
rjernst added a commit that referenced this pull request Aug 9, 2019
This commit makes the gitRevision property a lazy loaded value by
returning an Object implementing toString(). The Dockerfile template is
also changed to use groovy templates instead of the mavenfilter hack, so
converting to String will not happen until runtime.
@rjernst rjernst removed the v6.8.3 label Aug 9, 2019
@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 >refactoring Team:Delivery Meta label for Delivery team v7.3.1 v7.4.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants