Skip to content

Commit 93a0665

Browse files
committed
polish review
Signed-off-by: Jared Tan <[email protected]>
1 parent 9f78f37 commit 93a0665

File tree

5 files changed

+110
-403
lines changed

5 files changed

+110
-403
lines changed

cmd/es-rollover/app/init/flags.go

Lines changed: 26 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package init
1616

1717
import (
1818
"flag"
19-
"log"
2019

2120
"github.com/spf13/viper"
2221

@@ -25,10 +24,12 @@ import (
2524
)
2625

2726
const (
28-
shards = "shards"
29-
replicas = "replicas"
30-
prioritySpanTemplate = "priority-span-template"
31-
priorityServiceTemplate = "priority-service-template"
27+
shards = "shards"
28+
replicas = "replicas"
29+
prioritySpanTemplate = "priority-span-template"
30+
priorityServiceTemplate = "priority-service-template"
31+
priorityDependenciesTemplate = "priority-dependencies-template"
32+
prioritySamplingTemplate = "priority-sampling-template"
3233
)
3334

3435
// Config holds configuration for index cleaner binary.
@@ -39,59 +40,28 @@ type Config struct {
3940

4041
// AddFlags adds flags for TLS to the FlagSet.
4142
func (*Config) AddFlags(flags *flag.FlagSet) {
42-
flags.Int(shards, 5, "(deprecated, will be replaced with num-shards-span,num-shards-service,num-shards-sampling,num-shards-dependencies, if .num-shards set, it will be used as global settings for span,service,sampling,dependencies index) Number of shards")
43-
flags.Int(replicas, 1, "(deprecated, will be replaced with num-replicas-span,num-replicas-service,num-replicas-sampling,num-replicas-dependencies, if .num-replicas set, it will be used as global settings for span,service,sampling,dependencies index) Number of replicas")
44-
flags.Int(prioritySpanTemplate, 0, "(deprecated, will be replaced with priority-spans-template) Priority of jaeger-span index template (ESv8 only)")
45-
flags.Int(priorityServiceTemplate, 0, "(deprecated, will be replaced with priority-services-template) Priority of jaeger-service index template (ESv8 only)")
46-
47-
flags.Int64(cfg.NumShardSpanFlag(), 5, "Number of span index shards")
48-
flags.Int64(cfg.NumShardServiceFlag(), 5, "Number of service index shards")
49-
flags.Int64(cfg.NumShardDependenciesFlag(), 5, "Number of dependencies index shards")
50-
flags.Int64(cfg.NumShardSamplingFlag(), 5, "Number of sampling index shards")
51-
52-
flags.Int64(cfg.NumReplicaSpanFlag(), 1, "Number of span index replicas")
53-
flags.Int64(cfg.NumReplicaServiceFlag(), 1, "Number of services index replicas")
54-
flags.Int64(cfg.NumReplicaDependenciesFlag(), 1, "Number of dependencies index replicas")
55-
flags.Int64(cfg.NumReplicaSamplingFlag(), 1, "Number of sampling index replicas")
56-
57-
flags.Int64(cfg.PrioritySpanTemplateFlag(), 0, "Priority of jaeger-span index template (ESv8 only)")
58-
flags.Int64(cfg.PriorityServiceTemplateFlag(), 0, "Priority of jaeger-service index template (ESv8 only)")
59-
flags.Int64(cfg.PriorityDependenciesTemplateFlag(), 0, "Priority of jaeger-dependencies index template (ESv8 only)")
60-
flags.Int64(cfg.PrioritySamplingTemplateFlag(), 0, "Priority of jaeger-sampling index template (ESv8 only)")
43+
flags.Int(shards, 5, "Number of shards")
44+
flags.Int(replicas, 1, "Number of replicas")
45+
flags.Int(prioritySpanTemplate, 0, "Priority of jaeger-span index template (ESv8 only)")
46+
flags.Int(priorityServiceTemplate, 0, "Priority of jaeger-service index template (ESv8 only)")
47+
flags.Int(priorityDependenciesTemplate, 0, "Priority of jaeger-dependencies index template (ESv8 only)")
48+
flags.Int(prioritySamplingTemplate, 0, "Priority of jaeger-sampling index template (ESv8 only)")
6149
}
6250

6351
// InitFromViper initializes config from viper.Viper.
6452
func (c *Config) InitFromViper(v *viper.Viper) {
65-
deprecatedNumShards := v.GetInt(shards)
66-
deprecatedReplicaShards := v.GetInt(replicas)
67-
68-
if deprecatedReplicaShards > 0 || deprecatedNumShards > 0 {
69-
log.Printf("using deprecated %s or %s", shards, replicas)
70-
}
71-
72-
c.Indices.Spans.TemplateNumShards = cfg.LegacyFlagValue(deprecatedNumShards, v.GetInt(cfg.NumShardSpanFlag()))
73-
c.Indices.Services.TemplateNumShards = cfg.LegacyFlagValue(deprecatedNumShards, v.GetInt(cfg.NumShardServiceFlag()))
74-
c.Indices.Dependencies.TemplateNumShards = cfg.LegacyFlagValue(deprecatedNumShards, v.GetInt(cfg.NumShardDependenciesFlag()))
75-
c.Indices.Sampling.TemplateNumShards = cfg.LegacyFlagValue(deprecatedNumShards, v.GetInt(cfg.NumShardSamplingFlag()))
76-
77-
c.Indices.Spans.TemplateNumReplicas = cfg.LegacyFlagValue(deprecatedReplicaShards, v.GetInt(cfg.NumReplicaSpanFlag()))
78-
c.Indices.Services.TemplateNumReplicas = cfg.LegacyFlagValue(deprecatedReplicaShards, v.GetInt(cfg.NumReplicaServiceFlag()))
79-
c.Indices.Dependencies.TemplateNumReplicas = cfg.LegacyFlagValue(deprecatedReplicaShards, v.GetInt(cfg.NumReplicaDependenciesFlag()))
80-
c.Indices.Sampling.TemplateNumReplicas = cfg.LegacyFlagValue(deprecatedReplicaShards, v.GetInt(cfg.NumShardSamplingFlag()))
81-
82-
if v.GetInt(prioritySpanTemplate) > 0 || v.GetInt(priorityServiceTemplate) > 0 {
83-
log.Printf("using deprecated %s or %s", shards, replicas)
84-
}
85-
86-
deprecatedPrioritySpanTemplate := v.GetInt(prioritySpanTemplate)
87-
deprecatedPriorityServiceTemplate := v.GetInt(priorityServiceTemplate)
88-
89-
if deprecatedPriorityServiceTemplate > 0 || deprecatedPrioritySpanTemplate > 0 {
90-
log.Printf("using deprecated %s or %s", prioritySpanTemplate, priorityServiceTemplate)
91-
}
92-
93-
c.Indices.Spans.TemplatePriority = cfg.LegacyFlagValue(deprecatedPrioritySpanTemplate, v.GetInt(cfg.PrioritySpanTemplateFlag()))
94-
c.Indices.Services.TemplatePriority = cfg.LegacyFlagValue(deprecatedPriorityServiceTemplate, v.GetInt(cfg.PriorityServiceTemplateFlag()))
95-
c.Indices.Dependencies.TemplatePriority = v.GetInt64(cfg.PriorityDependenciesTemplateFlag())
96-
c.Indices.Sampling.TemplatePriority = v.GetInt64(cfg.PrioritySamplingTemplateFlag())
53+
c.Indices.Spans.TemplateNumShards = v.GetInt64(shards)
54+
c.Indices.Services.TemplateNumShards = v.GetInt64(shards)
55+
c.Indices.Dependencies.TemplateNumShards = v.GetInt64(shards)
56+
c.Indices.Sampling.TemplateNumShards = v.GetInt64(shards)
57+
58+
c.Indices.Spans.TemplateNumReplicas = v.GetInt64(replicas)
59+
c.Indices.Services.TemplateNumReplicas = v.GetInt64(replicas)
60+
c.Indices.Dependencies.TemplateNumReplicas = v.GetInt64(replicas)
61+
c.Indices.Sampling.TemplateNumReplicas = v.GetInt64(replicas)
62+
63+
c.Indices.Spans.TemplatePriority = v.GetInt64(prioritySpanTemplate)
64+
c.Indices.Services.TemplatePriority = v.GetInt64(priorityServiceTemplate)
65+
c.Indices.Dependencies.TemplatePriority = v.GetInt64(priorityDependenciesTemplate)
66+
c.Indices.Sampling.TemplatePriority = v.GetInt64(prioritySamplingTemplate)
9767
}

cmd/esmapping-generator/app/flags.go

Lines changed: 12 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
package app
1616

1717
import (
18-
"log"
19-
2018
"github.com/spf13/cobra"
2119

2220
"github.com/jaegertracing/jaeger/pkg/es/config"
@@ -44,7 +42,7 @@ const (
4442

4543
// AddFlags adds flags for esmapping-generator main program
4644
func (o *Options) AddFlags(command *cobra.Command) {
47-
var deprecatedOptions config.IndexOptions
45+
var indexOptions config.IndexOptions
4846
command.Flags().StringVar(
4947
&o.Mapping,
5048
mappingFlag,
@@ -56,56 +54,15 @@ func (o *Options) AddFlags(command *cobra.Command) {
5654
7,
5755
"The major Elasticsearch version")
5856
command.Flags().Int64Var(
59-
&deprecatedOptions.TemplateNumShards,
57+
&indexOptions.TemplateNumShards,
6058
shardsFlag,
6159
5,
62-
"(deprecated, will be replaced with num-shards-span,num-shards-service,num-shards-sampling,num-shards-dependencies, if .num-shards set, it will be used as global settings for span,service,sampling,dependencies index) The number of shards per index in Elasticsearch")
60+
"The number of shards per index in Elasticsearch")
6361
command.Flags().Int64Var(
64-
&deprecatedOptions.TemplateNumReplicas,
62+
&indexOptions.TemplateNumReplicas,
6563
replicasFlag,
6664
1,
67-
"(deprecated, will be replaced with num-replicas-span,num-replicas-service,num-replicas-sampling,num-replicas-dependencies, if .num-replicas set, it will be used as global settings for span,service,sampling,dependencies index) The number of replicas per index in Elasticsearch")
68-
69-
command.Flags().Int64Var(
70-
&o.Indices.Spans.TemplateNumShards,
71-
config.NumShardSpanFlag(),
72-
5,
73-
"The number of shards per span index in Elasticsearch")
74-
command.Flags().Int64Var(
75-
&o.Indices.Spans.TemplateNumReplicas,
76-
config.NumReplicaSpanFlag(),
77-
1,
7865
"The number of replicas per index in Elasticsearch")
79-
command.Flags().Int64Var(
80-
&o.Indices.Services.TemplateNumShards,
81-
config.NumShardServiceFlag(),
82-
5,
83-
"The number of shards per service index in Elasticsearch")
84-
command.Flags().Int64Var(
85-
&o.Indices.Services.TemplateNumReplicas,
86-
config.NumReplicaServiceFlag(),
87-
1,
88-
"The number of replicas per service index in Elasticsearch")
89-
command.Flags().Int64Var(
90-
&o.Indices.Dependencies.TemplateNumShards,
91-
config.NumShardDependenciesFlag(),
92-
5,
93-
"The number of shards per dependencies index in Elasticsearch")
94-
command.Flags().Int64Var(
95-
&o.Indices.Dependencies.TemplateNumReplicas,
96-
config.NumReplicaDependenciesFlag(),
97-
1,
98-
"The number of replicas per dependencies index in Elasticsearch")
99-
command.Flags().Int64Var(
100-
&o.Indices.Sampling.TemplateNumShards,
101-
config.NumShardSamplingFlag(),
102-
5,
103-
"The number of shards per sampling index in Elasticsearch")
104-
command.Flags().Int64Var(
105-
&o.Indices.Sampling.TemplateNumReplicas,
106-
config.NumReplicaSamplingFlag(),
107-
1,
108-
"The number of replicas per sampling index in Elasticsearch")
10966
command.Flags().StringVar(
11067
&o.IndexPrefix,
11168
indexPrefixFlag,
@@ -122,21 +79,15 @@ func (o *Options) AddFlags(command *cobra.Command) {
12279
"jaeger-ilm-policy",
12380
"The name of the ILM policy to use if ILM is active")
12481

125-
if deprecatedOptions.TemplateNumShards > 0 {
126-
log.Printf("using deprecated %s", shardsFlag)
127-
o.Indices.Spans.TemplateNumShards = deprecatedOptions.TemplateNumShards
128-
o.Indices.Services.TemplateNumShards = deprecatedOptions.TemplateNumShards
129-
o.Indices.Dependencies.TemplateNumShards = deprecatedOptions.TemplateNumShards
130-
o.Indices.Sampling.TemplateNumShards = deprecatedOptions.TemplateNumShards
131-
}
82+
o.Indices.Spans.TemplateNumShards = indexOptions.TemplateNumShards
83+
o.Indices.Services.TemplateNumShards = indexOptions.TemplateNumShards
84+
o.Indices.Dependencies.TemplateNumShards = indexOptions.TemplateNumShards
85+
o.Indices.Sampling.TemplateNumShards = indexOptions.TemplateNumShards
13286

133-
if deprecatedOptions.TemplateNumReplicas > 0 {
134-
log.Printf("using deprecated %s", replicasFlag)
135-
o.Indices.Spans.TemplateNumReplicas = deprecatedOptions.TemplateNumReplicas
136-
o.Indices.Services.TemplateNumReplicas = deprecatedOptions.TemplateNumReplicas
137-
o.Indices.Dependencies.TemplateNumReplicas = deprecatedOptions.TemplateNumReplicas
138-
o.Indices.Sampling.TemplateNumReplicas = deprecatedOptions.TemplateNumReplicas
139-
}
87+
o.Indices.Spans.TemplateNumReplicas = indexOptions.TemplateNumReplicas
88+
o.Indices.Services.TemplateNumReplicas = indexOptions.TemplateNumReplicas
89+
o.Indices.Dependencies.TemplateNumReplicas = indexOptions.TemplateNumReplicas
90+
o.Indices.Sampling.TemplateNumReplicas = indexOptions.TemplateNumReplicas
14091

14192
// mark mapping flag as mandatory
14293
command.MarkFlagRequired(mappingFlag)

pkg/es/config/flagutils.go

Lines changed: 0 additions & 120 deletions
This file was deleted.

pkg/es/config/flagutils_test.go

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)