-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix gradle stack version selection when a release is not yet published #13051
base: main
Are you sure you want to change the base?
Fix gradle stack version selection when a release is not yet published #13051
Conversation
…ildSrc utility class
… the one selected' when exact stack version match is not yet available
…user with the introduction of StackVersion as comparable instances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a full review, just a couple suggestions on wording.
build.gradle
Outdated
def versionSelector = new StackVersionSelector(artifactVersionsApi) | ||
String qualifiedVersion = versionSelector.selectClosestVersion(version) | ||
if (qualifiedVersion != version) { | ||
println "WARN version $version not yet published, swith automatically to $qualifiedVersion" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo: swith
Also, what about this instead:
"WARN version $version does not yet exist or has not been published, switching to $qualifiedVersion "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @roaksoax I like you wording, I go for it
|
||
String qualifiedVersion = selectClosestInList(StackVersion.asVersion(isReleaseBuild ? version : "${version}-SNAPSHOT"), versions) | ||
if (qualifiedVersion == null) { | ||
throw new GradleException("could not find the current artifact from the artifact-api ${artifactVersionsApi} for ${version}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"the current" artifact not a good way to describe an artifact, we should specific why one it is. e.g.:
cloud not find version ${version} in the artifact-api (${artifactVersionApi})
So I guess it would read:
could not find artifact Elasticsearch 8.0.0-alpha1 in the arfifact-api (https://xzy)/
or something like:
could not find Elasticsearch (elasticsearch-8.0.0-alpha1) in the artifact api (https://xxxx)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I would change the error to:
could not find Elastic Stack version (8.0.0-alpha1) in the artifact api (https://xxxx)
because at this point the StackVersionSelector
is only used to select the version of the global stack and not for a specific artifact, the StackVersionSelector
hasn't got that information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern with this approach of choosing a fallback version is that we should actually fail in many scenarios such as:
❯ VERSION_QUALIFIER=alpha1 ./gradlew clean runIntegrationTests -PrubyIntegrationSpecs=qa/integration/specs/beats_input_spec.rb --console=plain
...
WARN version 8.0.0-alpha1 does not yet exist or has not been published, switching to 8.0.0-SNAPSHOT
...
When running the integration test task with 8.0.0-alpha1, it's dangerous to fail silently to 8.0.0-SNAPSHOT. While we see the warn when running locally in the console, in CI it can easily gives us a false sense of security that the tests are passing.
Without that "dowgrading" of the version the first time the |
It doesn't have to fail. Building logstash artifacts should not require integration tests. In fact if we had a jenkins pipeline, we could do:
|
so, for example, doing |
Now I understand what you mean. That problem originate by the fact the gradle script does the download in configuration phase instead of execution phase; I tried to put down a PR for that in #13042. However also with that move the |
It makes sense for the test to fail, and it is the least surprising course of action. Having a build green just for the sake of being green doesn't help. What's important is that our artifact creation and unit testing tasks aren't blocked by the lack of builds in other products. If there comes a time where Logstash requires another Elastic product to be built, this logic needs to be implemented in our internal build manager.
So as long as we safeguard that tasks like |
@andsel is this still something that we need to move forward? |
I've a mixed feeling about this. It's useful only during version bumps, when some artifacts of stack that we use are not yet published, but as @jsvd pointed out it could drive to some surprise during build. So I vote to close it without merging. |
++ on not moving forward with the proposal as is, but we should reopen #13030 if the issue still exists, and it seems it does:
|
In the original issue #13030 we had the problem that the task |
Release notes
[rn:skip]
What does this PR do?
Modifies the logic of stack version's selection. From the "exact version match" passes to the "closest version", this change is useful when new Logstash versions are inserted into
versions.yml
and those versions are not yet published as artifacts.During the build Elasticsearch and Filebeat versions are downloaded, when the bump of a new version is happening and those artifacts aren't yet published the build would fail. To avoid the fail this PR implements a logic of best match, so for example is last published version is
7.14.2
and theversions.yml
is update to build the version7.15.0
which doesn't exists, the build script force the stack version to7.14.2
in this way the integration tests are able to succeed.In particular this PR adds in
buildSrc
a couple of support classes (StackVersionSelector
andStackVersionSelector.StackVersion
) to implement the version selection logic described above.Fixes #13030
Why is it important/What is the impact to the user?
From the developer that's used to build Logstash from sources (and CI) this change fix a problem happening during versions bumps.
Checklist
Author's Checklist
versions.yml
to a future not yet published versionHow to test this PR locally
versions.yml
changing the stack version to something next to be released, for example7.15.0
something not present in the artifacts registrymaster
and it fails, try it in this branch and success, logging the fact the version used is7.14.0
, the previous closest version.Related issues
Use cases
Logs