Skip to content

Commit c84607a

Browse files
committed
Fix
1 parent 2659681 commit c84607a

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

ydb/public/lib/ydb_cli/commands/ydb_service_topic.cpp

+33-24
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ namespace {
184184
return MeteringMode_;
185185
}
186186

187-
void TCommandWithAutoscaling::AddAutoscaling(TClientCommand::TConfig& config, bool withDefault) {
187+
void TCommandWithAutoscaling::AddAutoscaling(TClientCommand::TConfig& config, bool isAlter) {
188188
TStringStream description;
189189
description << "A strategy to automatically change the number of partitions depending on the load. Available strategies: ";
190190
NColorizer::TColors colors = NColorizer::AutoColors(Cout);
@@ -194,29 +194,38 @@ namespace {
194194
"Couldn't find description for %s autoscale strategy", (TStringBuilder() << strategy.second).c_str());
195195
description << "\n " << colors.BoldColor() << strategy.first << colors.OldColor()
196196
<< "\n " << findResult->second;
197-
if (strategy.second == NTopic::EAutoscalingStrategy::Disabled) {
198-
description << colors.CyanColor() << " (default)" << colors.OldColor();
199-
}
200197
}
201198

202-
auto straregy = config.Opts->AddLongOption("autoscale-strategy", description.Str())
203-
.Optional()
204-
.StoreResult(&AutoscaleStrategy_);
205-
auto thresholdTime = config.Opts->AddLongOption("autoscale-threshold-time", "Duration in seconds of high or low load before automatically scale the number of partitions")
206-
.Optional()
207-
.StoreResult(&ScaleThresholdTime_);
208-
auto upThresholdPercent = config.Opts->AddLongOption("autoscale-scale-up-threshold-percent", "The load percentage at which the number of partitions will increase.")
209-
.Optional()
210-
.StoreResult(&ScaleUpThresholdPercent_);
211-
auto downThresholdPercent = config.Opts->AddLongOption("autoscale-scale-down-threshold-percent", "The load percentage at which the number of partitions will decrease.")
212-
.Optional()
213-
.StoreResult(&ScaleDownThresholdPercent_);
214-
215-
if (withDefault) {
216-
straregy.DefaultValue("disabled");
217-
thresholdTime.DefaultValue(300);
218-
upThresholdPercent.DefaultValue(90);
219-
downThresholdPercent.DefaultValue(30);
199+
if (isAlter) {
200+
config.Opts->AddLongOption("autoscale-strategy", description.Str())
201+
.Optional()
202+
.StoreResult(&AutoscaleStrategy_);
203+
config.Opts->AddLongOption("autoscale-threshold-time", "Duration in seconds of high or low load before automatically scale the number of partitions")
204+
.Optional()
205+
.StoreResult(&ScaleThresholdTime_);
206+
config.Opts->AddLongOption("autoscale-scale-up-threshold-percent", "The load percentage at which the number of partitions will increase")
207+
.Optional()
208+
.StoreResult(&ScaleUpThresholdPercent_);
209+
config.Opts->AddLongOption("autoscale-scale-down-threshold-percent", "The load percentage at which the number of partitions will decrease")
210+
.Optional()
211+
.StoreResult(&ScaleDownThresholdPercent_);
212+
} else {
213+
config.Opts->AddLongOption("autoscale-strategy", description.Str())
214+
.Optional()
215+
.DefaultValue("disabled")
216+
.StoreResult(&AutoscaleStrategy_);
217+
config.Opts->AddLongOption("autoscale-threshold-time", "Duration in seconds of high or low load before automatically scale the number of partitions")
218+
.Optional()
219+
.DefaultValue(300)
220+
.StoreResult(&ScaleThresholdTime_);
221+
config.Opts->AddLongOption("autoscale-scale-up-threshold-percent", "The load percentage at which the number of partitions will increase")
222+
.Optional()
223+
.DefaultValue(90)
224+
.StoreResult(&ScaleUpThresholdPercent_);
225+
config.Opts->AddLongOption("autoscale-scale-down-threshold-percent", "The load percentage at which the number of partitions will decrease")
226+
.Optional()
227+
.DefaultValue(30)
228+
.StoreResult(&ScaleDownThresholdPercent_);
220229
}
221230
}
222231

@@ -289,7 +298,7 @@ namespace {
289298
SetFreeArgTitle(0, "<topic-path>", "Topic path");
290299
AddAllowedCodecs(config, AllowedCodecs);
291300
AddAllowedMeteringModes(config);
292-
AddAutoscaling(config, true);
301+
AddAutoscaling(config, false);
293302
}
294303

295304
void TCommandTopicCreate::Parse(TConfig& config) {
@@ -358,7 +367,7 @@ namespace {
358367
SetFreeArgTitle(0, "<topic-path>", "Topic path");
359368
AddAllowedCodecs(config, AllowedCodecs);
360369
AddAllowedMeteringModes(config);
361-
AddAutoscaling(config, false);
370+
AddAutoscaling(config, true);
362371
}
363372

364373
void TCommandTopicAlter::Parse(TConfig& config) {

0 commit comments

Comments
 (0)