-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Bwc changes #28505
Bwc changes #28505
Conversation
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 @hub-cap so much for picking this up. I'm on my way to the airport, so have only had time for a quick look.
I left a handful of comments on things that jumped out at me, but haven't had time to think through the changes to the logic and may not do so for another week. The fact that there are now tests around VersionCollection
is great, and makes this whole area less worrying.
I felt it worth noting that ca70ca6 was a PITA - it addressed failures that only occurred during release builds which are waaay down the build pipeline. I think this preserves that fix but it's one that'll need keeping an eye on.
build.gradle
Outdated
addBWCSnapshotSubstitutions(':distribution:bwc:staged-minor-snapshot', versionCollection.stagedMinorSnapshot) | ||
addBWCSnapshotSubstitutions(':distribution:bwc:next-bugfix-snapshot', versionCollection.nextBugfixSnapshot) | ||
addBWCSnapshotSubstitutions(':distribution:bwc:maintenance-bugfix-snapshot', versionCollection.maintenanceBugfixSnapshot) | ||
|
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.
I like this, but now I see it I wonder about the duplication between the Gradle project name and the property on VersionCollection
. Can that be moved entirely into VersionCollection
?
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.
Ill see what I can do. Im not sure I like passing in the project ext to the VC project, which is used in the addBWCSnapshotSubstitutions method.. but it would be nice to be able to (like the bottom comment about the ifs in the bwc/build.gradle) consolidate the mapping between those in some single place. ill eyeball it, I think it can be better.
@@ -34,7 +34,6 @@ public class Version { | |||
final int revision | |||
final int id | |||
final boolean snapshot | |||
final String branch | |||
/** | |||
* Suffix on the version name. Unlike Version.java the build does not | |||
* consider alphas and betas different versions, it just preserves the |
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.
It looks like we now do consider alphas and betas so this comment is out-of-date.
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.
doh ++
@@ -25,159 +25,293 @@ import java.util.regex.Matcher | |||
|
|||
/** | |||
* The collection of version constants declared in Version.java, for use in BWC testing. | |||
* | |||
* if major+1 released: released artifacts from $version down to major-1.highestMinor.highestPatch, none of these should be snapshots, period. |
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.
This seems to relate major+1
to major-1
, which are two major versions apart. I think one of these should just be major
.
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.
Ahh yea i can fix this up. Its because major is current version major, but it does not really say that well so its confusing ++
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.
ahh, ok so this should be as is, since its saying if your next major version is released (IE, im on 5.x currently), then go from $version (some 5.x) down to 2.whatever_the_highest_minor_is, which is the wire compat guarantee. It is slightly confusing tho, and i welcome a rewording help, i just cant think of a better way currently.
Integer.parseInt(match.group(3)), (match.group(4) ?: '').replace('_', '-'), false, null) | ||
|
||
if (versions.size() > 0 && foundVersion.onOrBeforeIncludingSuffix(versions[-1])) { | ||
throw new GradleException("Versions.java contains out of order version constants:" + |
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.
I can't see this check any more, but ISTR it's important. Maybe it's elsewhere, I can't remember right now.
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.
Its a treemap now, so it sorts it. there is not really a way i can check. i think it was important so we didnt have to sort it in the code below where that original check was.
|
||
/** | ||
* Construct a VersionCollection from the lines of the Version.java file. | ||
* Construct a VersionCollection from the lines of the Version.java file. The basic logic for the following is pretty straight forward. |
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.
A bold claim :)
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.
HAHAHAHA ++
@@ -0,0 +1,226 @@ | |||
package org.elasticsearch.gradle | |||
|
|||
class VersionCollectionTest extends GroovyTestCase { |
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.
Hooray! 🎉
distribution/bwc/build.gradle
Outdated
} else if (project.name == 'maintenance-bugfix-snapshot') { | ||
bwcVersion = versionCollection.maintenanceBugfixSnapshot | ||
} else if (project.name == 'next-bugfix-snapshot') { | ||
bwcVersion = versionCollection.nextBugfixSnapshot |
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.
As above, I think it'd be nice to move the logic that relates Gradle project names and the versions all the way into VersionCollection
.
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.
yea i think its a good idea to leave it as a helper method in the VC code
/** | ||
* Helper function for turning a version into a snapshot version, removing and readding it to the tree | ||
*/ | ||
private Version removeAndReaddAsSnapshot(Version 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.
Typo: too many d
s.
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.
thats actually Re-Add, which after re-reading, is a terrible name.
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.
Why not just replaceAsSnapshot
?
I have a feeling Ill be eyeballing the next few of these releases :) And bonus, now you get out of doing it @DaveCTurner !! |
Also, @DaveCTurner when you do review, pls note that the goal of this was to try to keep it consolidated, but more legible than the original way it was done before you had to slog through it to understand it. The projects backing git branches will never change anymore like they used to, so its easier to reason about which of the snapshots is active for a given current branch. EX 6.1 does not have a nextMinor (only currentversion == unreleased major do), nor a staged (cuz its been released), nor a nextBugfix (released), but does have a maint (5.6 snap). EX 6.x could have a staged (if 6.2 is unreleased), def has a nextBugfix (6.1 snap) and maint (5.6 snap) |
@DaveCTurner ive addressed your comments, go-head have a look see while I figure out whats up w/ the CI tests failing :) |
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.
This looks good in general. I left some minor suggestions and thoughts. For the descriptions of the different version terminology, I would have someone look at them who knows nothing about this code.
* Uses basic logic about our releases to determine if this version has been previously released | ||
*/ | ||
private boolean isReleased(Version version) { | ||
return version.revision > 0 || (version.revision > 1 && currentVersion.equals(Version.fromString("5.1.2"))) |
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.
Do we actually need this hack? None of the existing logic should be thinking any 5.x branch is current right? I understand it matters from the theoretical side, but in master 5.x version constants shouldn't even exist?
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.
++. I kept it in there just due to some initial notes I had taken about what released meant.
*/ | ||
Version getBWCSnapshotForCurrentMajor() { | ||
return getLastSnapshotWithMajor(currentVersion.major) | ||
List<Version> getVersionsWireCompatibleWithCurrent() { |
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.
I find these longer names actually harder to read. Can we go back to the old names (circa mid last year) so we could have eg bwcVersions.indexCompatible
and bwcVersions.wireCompatible
? Ie getIndexCompatible()
and getWireCompatible()
methods here.
Version version = getLastSnapshotWithMajor(currentVersion.major - 1) | ||
assert version != null : "getBWCSnapshotForPreviousMajor(): found no versions in the previous major" | ||
return version | ||
List<Version> getSnapshotVersionsWireCompatibleWithCurrent() { |
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.
Similar to the request above, I think this should simply be getSnapshots()
|
||
prevConsideredVersion = currConsideredVersion | ||
// re-add the currentVersion to the set | ||
versionSet.add(currentVersion) |
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.
Why would current be in bwc versions at all?
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.
discussed w/ you in person about the test failures, would love to fix up in another PR
*/ | ||
private Version removeAndReaddAsSnapshot(Version version) { | ||
versionSet.remove(version) | ||
Version snapshotVersion = new Version(version.major, version.minor, version.revision, version.suffix, buildSnapshot) |
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.
I dont think this is correct. Whether we are building a snapshot should not affect whether we expect snapshots from unreleased old branches. Eg if we are running tests of a release version of 6.3.0, 5.6.7 does not suddenly become released; it is still a snapshot we must build.
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.
I assume you are talking about the buildSnapshot being passed in? Id like to discuss that because not doing that breaks the VersionUtilsTests if you pass in the right mojo to simulate a release build. I did this to maintain the compat w/ the last change to the code. If its wrong logic, im ++ for fixing
/** | ||
* Helper function for turning a version into a snapshot version, removing and readding it to the tree | ||
*/ | ||
private Version removeAndReaddAsSnapshot(Version 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.
Why not just replaceAsSnapshot
?
6.x has a failing test. Im going to be working on this shortly, but not tonight!
|
Generalizing BWC building so that there is less code to modify for a release. This ensures we do not need to think about what major or minor version is in the gradle code. It follows the general rules of the elastic release structure. For more information on the rules, see the VersionCollection's javadoc. This also removes the additional bwc snapshots that will never be released, such as 6.0.2, which were being built and tested against every time we ran bwc tests. Additionally, it creates 4 new projects that correspond to the different types of snapshots that may exist for a given version. Its possible to now run those individual tasks to work out bwc logic whereas previously it was impossible and the entire suite of bwc tests had to be run to work out any logic changes in the build tools' bwc project. Please note that if the project does not make sense for the version that is current, that an error will be thrown from that individual project if an attempt is made to run it. This should allow for automating the version bumps as well, since it removes all the hardcoded version logic from the configs.
Version Utils did not previously have logic that removed the last majors minor snapshot if there was a next bugfix and maintenance bugfix release. This adds the logic and fixes some broken assumptions in tests as well. relates elastic#28505
Version Utils did not previously have logic that removed the last majors minor snapshot if there was a next bugfix and maintenance bugfix release. This adds the logic and fixes some broken assumptions in tests as well. relates #28505
Version Utils did not previously have logic that removed the last majors minor snapshot if there was a next bugfix and maintenance bugfix release. This adds the logic and fixes some broken assumptions in tests as well. relates #28505
Generalizing BWC building so that there is less code to modify for a release. This ensures we do not
need to think about what major or minor version is in the gradle code. It follows the general rules of the
elastic release structure. For more information on the rules, see the VersionCollection's javadoc.
This also removes the additional bwc snapshots that will never be released, such as 6.0.2, which were
being built and tested against every time we ran bwc tests.
Additionally, it creates 4 new projects that correspond to the different types of snapshots that may exist
for a given version. Its possible to now run those individual tasks to work out bwc logic whereas
previously it was impossible and the entire suite of bwc tests had to be run to work out any logic changes
in the build tools' bwc project. Please note that if the project does not make sense for the version that is
current, that an error will be thrown from that individual project if an attempt is made to run it.
This should allow for automating the version bumps as well, since it removes all the hardcoded version
logic from the configs.