Skip to content

Commit 5b90ee6

Browse files
committed
Use dynamic config reload for subnet labels
Use explicit dynamic vs static config flag Refactor flp_pipeline_builder.go to break down stages config into smaller functions
1 parent 7af9131 commit 5b90ee6

File tree

7 files changed

+278
-270
lines changed

7 files changed

+278
-270
lines changed

internal/controller/flp/flp_common_objects.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,17 @@ func metricsSettings(desired *flowslatest.FlowCollectorSpec, vol *volumes.Builde
266266
return metricsSettings
267267
}
268268

269-
func getStaticJSONConfig(desired *flowslatest.FlowCollectorSpec, vol *volumes.Builder, promTLS *flowslatest.CertificateReference, pipeline *PipelineBuilder, dynCMName string) (string, error) {
269+
func getJSONConfigs(desired *flowslatest.FlowCollectorSpec, vol *volumes.Builder, promTLS *flowslatest.CertificateReference, pipeline *PipelineBuilder, dynCMName string) (string, string, error) {
270270
metricsSettings := metricsSettings(desired, vol, promTLS)
271271
advancedConfig := helper.GetAdvancedProcessorConfig(desired)
272+
static, dynamic := pipeline.GetSplitStageParams()
272273
config := map[string]interface{}{
273274
"log-level": desired.Processor.LogLevel,
274275
"health": map[string]interface{}{
275276
"port": *advancedConfig.HealthPort,
276277
},
277278
"pipeline": pipeline.GetStages(),
278-
"parameters": pipeline.GetStaticStageParams(),
279+
"parameters": static,
279280
"metricsSettings": metricsSettings,
280281
"dynamicParameters": config.DynamicParameters{
281282
Namespace: desired.Namespace,
@@ -288,22 +289,19 @@ func getStaticJSONConfig(desired *flowslatest.FlowCollectorSpec, vol *volumes.Bu
288289
"port": *advancedConfig.ProfilePort,
289290
}
290291
}
291-
bs, err := json.Marshal(config)
292+
jsonStatic, err := json.Marshal(config)
292293
if err != nil {
293-
return "", err
294+
return "", "", err
294295
}
295-
return string(bs), nil
296-
}
297296

298-
func getDynamicJSONConfig(pipeline *PipelineBuilder) (string, error) {
299-
config := map[string]interface{}{
300-
"parameters": pipeline.GetDynamicStageParams(),
297+
config = map[string]interface{}{
298+
"parameters": dynamic,
301299
}
302-
bs, err := json.Marshal(config)
300+
jsonDynamic, err := json.Marshal(config)
303301
if err != nil {
304-
return "", err
302+
return "", "", err
305303
}
306-
return string(bs), nil
304+
return string(jsonStatic), string(jsonDynamic), nil
307305
}
308306

309307
func promService(desired *flowslatest.FlowCollectorSpec, svcName, namespace, appLabel string) *corev1.Service {

internal/controller/flp/flp_monolith_objects.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -121,38 +121,30 @@ func (b *monolithBuilder) deployment(annotations map[string]string) *appsv1.Depl
121121
}
122122

123123
func (b *monolithBuilder) configMaps() (*corev1.ConfigMap, string, *corev1.ConfigMap, error) {
124-
grpcStage := newGRPCPipeline(b.desired, &b.volumes)
125-
pipeline := newPipelineBuilder(
124+
pipeline, err := createPipeline(
126125
b.desired,
127126
b.flowMetrics,
128127
b.fcSlices,
129128
b.detectedSubnets,
130129
b.info.Loki,
131130
b.info.ClusterInfo.GetID(),
132131
&b.volumes,
133-
&grpcStage,
132+
newGRPCPipeline(b.desired, &b.volumes),
134133
)
135-
err := pipeline.AddProcessorStages()
136134
if err != nil {
137135
return nil, "", nil, err
138136
}
139137

140-
// Get static CM
141-
data, err := getStaticJSONConfig(b.desired, &b.volumes, b.promTLS, &pipeline, monoDynConfigMap)
138+
// Get static and dynamic CM
139+
static, dynamic, err := getJSONConfigs(b.desired, &b.volumes, b.promTLS, pipeline, monoDynConfigMap)
142140
if err != nil {
143141
return nil, "", nil, err
144142
}
145-
staticCM, digest, err := configMap(monoConfigMap, b.info.Namespace, data, monoName)
143+
staticCM, digest, err := configMap(monoConfigMap, b.info.Namespace, static, monoName)
146144
if err != nil {
147145
return nil, "", nil, err
148146
}
149-
150-
// Get dynamic CM (hot reload)
151-
data, err = getDynamicJSONConfig(&pipeline)
152-
if err != nil {
153-
return nil, "", nil, err
154-
}
155-
dynamicCM, _, err := configMap(monoDynConfigMap, b.info.Namespace, data, monoName)
147+
dynamicCM, _, err := configMap(monoDynConfigMap, b.info.Namespace, dynamic, monoName)
156148
if err != nil {
157149
return nil, "", nil, err
158150
}

0 commit comments

Comments
 (0)