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

KAFKA-18052: Decouple the dependency of feature stable version to the metadata version #17886

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public enum Features {
*
* See {@link TestFeatureVersion} as an example. See {@link FeatureVersion} when implementing a new feature.
*/
TEST_VERSION("test.feature.version", TestFeatureVersion.values()),
KRAFT_VERSION("kraft.version", KRaftVersion.values()),
TRANSACTION_VERSION("transaction.version", TransactionVersion.values()),
GROUP_VERSION("group.version", GroupVersion.values());
TEST_VERSION("test.feature.version", TestFeatureVersion.values(), TestFeatureVersion.LATEST_PRODUCTION),
KRAFT_VERSION("kraft.version", KRaftVersion.values(), KRaftVersion.LATEST_PRODUCTION),
TRANSACTION_VERSION("transaction.version", TransactionVersion.values(), TransactionVersion.LATEST_PRODUCTION),
GROUP_VERSION("group.version", GroupVersion.values(), GroupVersion.LATEST_PRODUCTION);

public static final Features[] FEATURES;
public static final List<Features> PRODUCTION_FEATURES;
Expand All @@ -53,10 +53,21 @@ public enum Features {
private final String name;
private final FeatureVersion[] featureVersions;

// The latest production version of the feature, owned and updated by the feature owner
// in the respective feature definition. The value should not be smaller than the default
// value calculated with {@link #defaultValue(MetadataVersion)}.
private final FeatureVersion latestProduction;

Features(String name,
FeatureVersion[] featureVersions) {
FeatureVersion[] featureVersions,
FeatureVersion latestProduction) {
this.name = name;
this.featureVersions = featureVersions;
this.latestProduction = latestProduction;

if (defaultValue(MetadataVersion.LATEST_PRODUCTION) > latestProduction.featureLevel()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to further validate the following?

  1. The dependencies of the latestProduction is in production.
  2. The dependencies of the default feature is in production and have a level <= the default level of the dependency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a validation for

  • The latest production value >= the default value.
  • The dependencies of the latest production value <= their latest production values.
  • The dependencies of the default value <= their default values.

The dependencies of the default feature is in production

This is guaranteed when checking The latest production value >= the default value

throw new IllegalArgumentException("The latest production value should be no smaller than the default value.");
}
}

static {
Expand All @@ -78,7 +89,7 @@ public FeatureVersion[] featureVersions() {
}

public short latestProduction() {
return defaultValue(MetadataVersion.LATEST_PRODUCTION);
return latestProduction.featureLevel();
}

public short minimumProduction() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public enum GroupVersion implements FeatureVersion {

public static final String FEATURE_NAME = "group.version";

public static final GroupVersion LATEST_PRODUCTION = GV_1;

private final short featureLevel;
private final MetadataVersion bootstrapMetadataVersion;
private final Map<String, Short> dependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public enum KRaftVersion implements FeatureVersion {

public static final String FEATURE_NAME = "kraft.version";

public static final KRaftVersion LATEST_PRODUCTION = KRAFT_VERSION_1;

private final short featureLevel;
private final MetadataVersion bootstrapMetadataVersion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public enum TestFeatureVersion implements FeatureVersion {

public static final String FEATURE_NAME = "test.feature.version";

public static final TestFeatureVersion LATEST_PRODUCTION = TEST_1;
dongnuo123 marked this conversation as resolved.
Show resolved Hide resolved

TestFeatureVersion(int featureLevel, MetadataVersion metadataVersionMapping, Map<String, Short> dependencies) {
this.featureLevel = (short) featureLevel;
this.metadataVersionMapping = metadataVersionMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public enum TransactionVersion implements FeatureVersion {

public static final String FEATURE_NAME = "transaction.version";

public static final TransactionVersion LATEST_PRODUCTION = TV_0;

private final short featureLevel;
private final MetadataVersion bootstrapMetadataVersion;
private final Map<String, Short> dependencies;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public void testDefaultValueAllFeatures(Features feature) {

@ParameterizedTest
@EnumSource(Features.class)
public void testLatestProductionMapsToLatestMetadataVersion(Features features) {
assertEquals(features.latestProduction(), features.defaultValue(MetadataVersion.LATEST_PRODUCTION));
public void testLatestProductionIsNotBehindLatestMetadataVersion(Features features) {
assertTrue(features.latestProduction() >= features.defaultValue(MetadataVersion.latestProduction()));
}

@ParameterizedTest
Expand Down
Loading