mirror of https://github.com/apache/kafka.git
MINOR; Improve error message for the storage format command (#19210)
Minor improvement on the error output for the storage format command. Suggests changes for a valid storage format command. Reviewers: Justine Olshan <jolshan@confluent.io>
This commit is contained in:
parent
a524fc64b4
commit
82de719fff
|
@ -347,15 +347,22 @@ public class Formatter {
|
|||
if (configuredKRaftVersionLevel.isPresent()) {
|
||||
if (configuredKRaftVersionLevel.get() == 0) {
|
||||
if (hasDynamicQuorum()) {
|
||||
throw new FormatterException("Cannot set kraft.version to " +
|
||||
configuredKRaftVersionLevel.get() + " if KIP-853 configuration is present. " +
|
||||
"Try removing the --feature flag for kraft.version.");
|
||||
throw new FormatterException(
|
||||
"Cannot set kraft.version to " +
|
||||
configuredKRaftVersionLevel.get() +
|
||||
" if one of the flags --standalone, --initial-controllers, or --no-initial-controllers is used. " +
|
||||
"For dynamic controllers support, try removing the --feature flag for kraft.version."
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!hasDynamicQuorum()) {
|
||||
throw new FormatterException("Cannot set kraft.version to " +
|
||||
configuredKRaftVersionLevel.get() + " unless KIP-853 configuration is present. " +
|
||||
"Try removing the --feature flag for kraft.version.");
|
||||
throw new FormatterException(
|
||||
"Cannot set kraft.version to " +
|
||||
configuredKRaftVersionLevel.get() +
|
||||
" unless one of the flags --standalone, --initial-controllers, or --no-initial-controllers is used. " +
|
||||
"For dynamic controllers support, try using one of --standalone, --initial-controllers, or " +
|
||||
"--no-initial-controllers."
|
||||
);
|
||||
}
|
||||
}
|
||||
return configuredKRaftVersionLevel.get();
|
||||
|
|
|
@ -419,10 +419,12 @@ public class FormatterTest {
|
|||
formatter1.formatter.setInitialControllers(DynamicVoters.
|
||||
parse("1@localhost:8020:4znU-ou9Taa06bmEJxsjnw"));
|
||||
assertTrue(formatter1.formatter.hasDynamicQuorum());
|
||||
assertEquals("Cannot set kraft.version to 0 if KIP-853 configuration is present. " +
|
||||
"Try removing the --feature flag for kraft.version.",
|
||||
assertThrows(FormatterException.class,
|
||||
() -> formatter1.formatter.run()).getMessage());
|
||||
assertEquals(
|
||||
"Cannot set kraft.version to 0 if one of the flags --standalone, --initial-controllers, or " +
|
||||
"--no-initial-controllers is used. For dynamic controllers support, try removing the " +
|
||||
"--feature flag for kraft.version.",
|
||||
assertThrows(FormatterException.class, () -> formatter1.formatter.run()).getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -433,10 +435,12 @@ public class FormatterTest {
|
|||
formatter1.formatter.setFeatureLevel("kraft.version", (short) 1);
|
||||
formatter1.formatter.setUnstableFeatureVersionsEnabled(true);
|
||||
assertFalse(formatter1.formatter.hasDynamicQuorum());
|
||||
assertEquals("Cannot set kraft.version to 1 unless KIP-853 configuration is present. " +
|
||||
"Try removing the --feature flag for kraft.version.",
|
||||
assertThrows(FormatterException.class,
|
||||
() -> formatter1.formatter.run()).getMessage());
|
||||
assertEquals(
|
||||
"Cannot set kraft.version to 1 unless one of the flags --standalone, --initial-controllers, or " +
|
||||
"--no-initial-controllers is used. For dynamic controllers support, try using one of " +
|
||||
"--standalone, --initial-controllers, or --no-initial-controllers.",
|
||||
assertThrows(FormatterException.class, () -> formatter1.formatter.run()).getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,10 +530,12 @@ public class FormatterTest {
|
|||
formatter1.formatter.setUnstableFeatureVersionsEnabled(true);
|
||||
formatter1.formatter.setNoInitialControllersFlag(false);
|
||||
assertFalse(formatter1.formatter.hasDynamicQuorum());
|
||||
assertEquals("Cannot set kraft.version to 1 unless KIP-853 configuration is present. " +
|
||||
"Try removing the --feature flag for kraft.version.",
|
||||
assertThrows(FormatterException.class,
|
||||
formatter1.formatter::run).getMessage());
|
||||
assertEquals(
|
||||
"Cannot set kraft.version to 1 unless one of the flags --standalone, --initial-controllers, or " +
|
||||
"--no-initial-controllers is used. For dynamic controllers support, try using one of " +
|
||||
"--standalone, --initial-controllers, or --no-initial-controllers.",
|
||||
assertThrows(FormatterException.class, formatter1.formatter::run).getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -541,10 +547,12 @@ public class FormatterTest {
|
|||
formatter1.formatter.setUnstableFeatureVersionsEnabled(true);
|
||||
formatter1.formatter.setNoInitialControllersFlag(true);
|
||||
assertTrue(formatter1.formatter.hasDynamicQuorum());
|
||||
assertEquals("Cannot set kraft.version to 0 if KIP-853 configuration is present. " +
|
||||
"Try removing the --feature flag for kraft.version.",
|
||||
assertThrows(FormatterException.class,
|
||||
formatter1.formatter::run).getMessage());
|
||||
assertEquals(
|
||||
"Cannot set kraft.version to 0 if one of the flags --standalone, --initial-controllers, or " +
|
||||
"--no-initial-controllers is used. For dynamic controllers support, try removing the " +
|
||||
"--feature flag for kraft.version.",
|
||||
assertThrows(FormatterException.class, formatter1.formatter::run).getMessage()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue