File tree Expand file tree Collapse file tree 4 files changed +12
-10
lines changed
Expand file tree Collapse file tree 4 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,14 @@ func DefaultLokiStackSpec(size lokiv1.LokiStackSizeType) *lokiv1.LokiStackSpec {
121121// ApplyDefaultSettings manipulates the options to conform to
122122// build specifications
123123func ApplyDefaultSettings (opts * Options ) error {
124+ // Handle the deprecated field opt.Stack.ReplicationFactor.
125+ if (opts .Stack .Replication == nil || opts .Stack .Replication .Factor == 0 ) && opts .Stack .ReplicationFactor > 0 { // nolint:staticcheck
126+ if opts .Stack .Replication == nil {
127+ opts .Stack .Replication = & lokiv1.ReplicationSpec {}
128+ }
129+ opts .Stack .Replication .Factor = opts .Stack .ReplicationFactor // nolint:staticcheck
130+ }
131+
124132 spec := DefaultLokiStackSpec (opts .Stack .Size )
125133
126134 if err := mergo .Merge (spec , opts .Stack , mergo .WithOverride ); err != nil {
Original file line number Diff line number Diff line change @@ -107,16 +107,6 @@ func ConfigOptions(opt Options) config.Options {
107107 protocol = "https"
108108 }
109109
110- // nolint:staticcheck
111- // Handle the deprecated field opt.Stack.ReplicationFactor.
112- if (opt .Stack .Replication == nil || opt .Stack .Replication .Factor == 0 ) && opt .Stack .ReplicationFactor > 0 {
113- if opt .Stack .Replication == nil {
114- opt .Stack .Replication = & lokiv1.ReplicationSpec {}
115- }
116-
117- opt .Stack .Replication .Factor = opt .Stack .ReplicationFactor
118- }
119-
120110 // Build a slice of with the shippers that are being used in the config
121111 // booleans used to prevent duplicates
122112 shippers := []string {}
Original file line number Diff line number Diff line change @@ -1299,6 +1299,8 @@ func TestConfigOptions_Replication(t *testing.T) {
12991299 Stack : tc .spec ,
13001300 Timeouts : testTimeoutConfig (),
13011301 }
1302+ err := ApplyDefaultSettings (& inOpt )
1303+ require .NoError (t , err )
13021304 options := ConfigOptions (inOpt )
13031305 require .Equal (t , tc .wantOptions , * options .Stack .Replication )
13041306 })
Original file line number Diff line number Diff line change @@ -204,6 +204,8 @@ func generateWarnings(stack *lokiv1.LokiStack) []metav1.Condition {
204204 rf := manifests .DefaultLokiStackSpec (stack .Spec .Size ).Replication .Factor
205205 if stack .Spec .Replication != nil && stack .Spec .Replication .Factor > 0 {
206206 rf = stack .Spec .Replication .Factor
207+ } else if stack .Spec .ReplicationFactor > 0 { // nolint:staticcheck
208+ rf = stack .Spec .ReplicationFactor // nolint:staticcheck
207209 }
208210 replicas := manifests .DefaultLokiStackSpec (stack .Spec .Size ).Template .Ingester .Replicas
209211 if stack .Spec .Template != nil && stack .Spec .Template .Ingester != nil && stack .Spec .Template .Ingester .Replicas > 0 {
You can’t perform that action at this time.
0 commit comments