-
Notifications
You must be signed in to change notification settings - Fork 8
feat(inkless:config): disallow setting diskless.enable if diskless storage system is disabled #520
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
Merged
giuseppelillo
merged 1 commit into
main
from
giuseppelillo/no-diskless-if-system-disabled
Mar 3, 2026
+61
−8
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -497,7 +497,8 @@ public static void validateBrokerLogConfigValues(Map<?, ?> props, | |
|
|
||
| private static void validateDiskless(Map<String, String> existingConfigs, | ||
| Map<String, Object> requestedConfigs, | ||
| Map<?, ?> newConfigs) { | ||
| Map<?, ?> newConfigs, | ||
| boolean isDisklessStorageSystemEnabled) { | ||
| final boolean isCreation = existingConfigs.isEmpty(); | ||
| final boolean isDisklessExplicitlySet = requestedConfigs.containsKey(TopicConfig.DISKLESS_ENABLE_CONFIG); | ||
| final boolean isRemoteStorageExplicitlySet = requestedConfigs.containsKey(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG); | ||
|
|
@@ -506,13 +507,29 @@ private static void validateDiskless(Map<String, String> existingConfigs, | |
| final boolean wasDisklessEnabled = Boolean.parseBoolean(existingConfigs.getOrDefault(TopicConfig.DISKLESS_ENABLE_CONFIG, "false")); | ||
| final boolean requestedDisklessEnabled = (Boolean) newConfigs.get(TopicConfig.DISKLESS_ENABLE_CONFIG); | ||
|
|
||
| if (isDisklessExplicitlySet && !isDisklessStorageSystemEnabled) { | ||
| throw new InvalidConfigurationException("It is invalid to set diskless.enable if diskless storage system is not enabled."); | ||
| } | ||
|
|
||
| final boolean isDisklessEnabled; | ||
| if (isDisklessExplicitlySet) { | ||
| isDisklessEnabled = requestedDisklessEnabled; | ||
| } else { | ||
| isDisklessEnabled = wasDisklessEnabled; | ||
| } | ||
|
|
||
| validateDisklessTransition(isCreation, isDisklessExplicitlySet, isDisklessEnabled, wasDisklessEnabled); | ||
|
|
||
| // Only one between diskless.enable and remote.storage.enable can be set, no matter the value. | ||
| final boolean hasExplicitDiskless = isDisklessExplicitlySet || wasDisklessExplicitlySet; | ||
| final boolean hasExplicitRemoteStorage = isRemoteStorageExplicitlySet || wasRemoteStorageExplicitlySet; | ||
| validateDisklessAndRemoteStorageMutualExclusion(isDisklessExplicitlySet, isRemoteStorageExplicitlySet, hasExplicitDiskless, hasExplicitRemoteStorage); | ||
| } | ||
|
|
||
| private static void validateDisklessTransition(boolean isCreation, | ||
| boolean isDisklessExplicitlySet, | ||
| boolean isDisklessEnabled, | ||
| boolean wasDisklessEnabled) { | ||
| // Diskless can be enabled only at creation | ||
| if (!isCreation && isDisklessExplicitlySet && isDisklessEnabled && !wasDisklessEnabled) { | ||
| throw new InvalidConfigurationException("It is invalid to enable diskless on an already existing topic."); | ||
|
|
@@ -522,10 +539,12 @@ private static void validateDiskless(Map<String, String> existingConfigs, | |
| if (!isCreation && isDisklessExplicitlySet && !isDisklessEnabled && wasDisklessEnabled) { | ||
| throw new InvalidConfigurationException("It is invalid to disable diskless."); | ||
| } | ||
| } | ||
|
|
||
| // Only one between diskless.enable and remote.storage.enable can be set, no matter the value. | ||
| final boolean hasExplicitDiskless = isDisklessExplicitlySet || wasDisklessExplicitlySet; | ||
| final boolean hasExplicitRemoteStorage = isRemoteStorageExplicitlySet || wasRemoteStorageExplicitlySet; | ||
| private static void validateDisklessAndRemoteStorageMutualExclusion(boolean isDisklessExplicitlySet, | ||
| boolean isRemoteStorageExplicitlySet, | ||
| boolean hasExplicitDiskless, | ||
| boolean hasExplicitRemoteStorage) { | ||
| if ((isDisklessExplicitlySet && hasExplicitRemoteStorage) || | ||
| (isRemoteStorageExplicitlySet && hasExplicitDiskless)) { | ||
| throw new InvalidConfigurationException("It is not valid to set a value for both diskless.enable and remote.storage.enable."); | ||
|
|
@@ -545,9 +564,10 @@ private static void validateDiskless(Map<String, String> existingConfigs, | |
| private static void validateTopicLogConfigValues(Map<String, String> existingConfigs, | ||
| Map<String, Object> requestedConfigs, | ||
| Map<?, ?> newConfigs, | ||
| boolean isRemoteLogStorageSystemEnabled) { | ||
| boolean isRemoteLogStorageSystemEnabled, | ||
| boolean isDisklessStorageSystemEnabled) { | ||
| validateValues(newConfigs); | ||
| validateDiskless(existingConfigs, requestedConfigs, newConfigs); | ||
| validateDiskless(existingConfigs, requestedConfigs, newConfigs, isDisklessStorageSystemEnabled); | ||
|
|
||
| boolean isRemoteLogStorageEnabled = (Boolean) newConfigs.get(TopicConfig.REMOTE_LOG_STORAGE_ENABLE_CONFIG); | ||
| if (isRemoteLogStorageEnabled) { | ||
|
|
@@ -663,6 +683,16 @@ public static void validate(Map<String, String> existingConfigs, | |
| Map<?, ?> configuredProps, | ||
| boolean isRemoteLogStorageSystemEnabled, | ||
| boolean isDisklessAllowFromClassicEnabled) { | ||
| validate(existingConfigs, props, configuredProps, isRemoteLogStorageSystemEnabled, | ||
| isDisklessAllowFromClassicEnabled, true); | ||
| } | ||
|
|
||
| public static void validate(Map<String, String> existingConfigs, | ||
| Properties props, | ||
| Map<?, ?> configuredProps, | ||
| boolean isRemoteLogStorageSystemEnabled, | ||
| boolean isDisklessAllowFromClassicEnabled, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: dead argument. Can be fixed in a follow-up. |
||
| boolean isDisklessStorageSystemEnabled) { | ||
| validateNames(props); | ||
| if (configuredProps == null || configuredProps.isEmpty()) { | ||
| Map<?, ?> valueMaps = CONFIG.parse(props); | ||
|
|
@@ -671,7 +701,8 @@ public static void validate(Map<String, String> existingConfigs, | |
| Map<Object, Object> combinedConfigs = new HashMap<>(configuredProps); | ||
| combinedConfigs.putAll(props); | ||
| Map<?, ?> valueMaps = CONFIG.parse(combinedConfigs); | ||
| validateTopicLogConfigValues(existingConfigs, Utils.castToStringObjectMap(props), valueMaps, isRemoteLogStorageSystemEnabled); | ||
| validateTopicLogConfigValues(existingConfigs, Utils.castToStringObjectMap(props), valueMaps, | ||
| isRemoteLogStorageSystemEnabled, isDisklessStorageSystemEnabled); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Extracted to specific methods because
validateDisklesswas exceeding the limit on cyclomatic complexity.