Skip to content

Commit 8119b71

Browse files
Pass down remote config id to kafka actions (#43356)
### What does this PR do? Follow up to #43325 ### Motivation Events generated by the kafka_actions can easily be correlated with the action taken in the UI ### Describe how you validated your changes QA locally ### Additional Notes Co-authored-by: piotr.wolski <[email protected]>
1 parent 642e324 commit 8119b71

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

comp/core/autodiscovery/providers/datastreams/kafka_actions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func (c *actionsController) update(updates map[string]state.RawConfig, applyStat
152152
}
153153

154154
actionsMap["run_once"] = true
155+
actionsMap["remote_config_id"] = parsed.remoteConfigID
155156
for k, v := range auth {
156157
actionsMap[k] = v
157158
}
@@ -182,6 +183,7 @@ type parsedActionsConfig struct {
182183
path string
183184
bootstrapServers string
184185
actionsJSON json.RawMessage
186+
remoteConfigID string
185187
}
186188

187189
func parseActionsConfig(updates map[string]state.RawConfig, applyStateCallback func(string, state.ApplyStatus)) []parsedActionsConfig {
@@ -205,6 +207,7 @@ func parseActionsConfig(updates map[string]state.RawConfig, applyStateCallback f
205207
path: path,
206208
bootstrapServers: bootstrapServers,
207209
actionsJSON: cfg.Actions,
210+
remoteConfigID: rawConfig.Metadata.ID,
208211
})
209212
}
210213
return configs

comp/core/autodiscovery/providers/datastreams/kafka_actions_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func TestActionsController(t *testing.T) {
9090

9191
rcUpdate := map[string]state.RawConfig{
9292
"config_1": {Config: []byte("invalid")},
93-
"config_2": {Config: serializedConfig},
93+
"config_2": {Config: serializedConfig, Metadata: state.Metadata{ID: "test_remote_config_id"}},
9494
}
9595

9696
updateStatus := make(map[string]state.ApplyStatus)
@@ -133,6 +133,9 @@ func TestActionsController(t *testing.T) {
133133
// Check that run_once was injected
134134
assert.Equal(t, true, instance["run_once"])
135135

136+
// Check that remote_config_id was injected
137+
assert.Equal(t, "test_remote_config_id", instance["remote_config_id"])
138+
136139
// Check that actions are present
137140
assert.NotNil(t, instance["read_messages"])
138141
}
@@ -167,7 +170,7 @@ func TestActionsControllerNoBootstrapServers(t *testing.T) {
167170
require.NoError(t, err)
168171

169172
rcUpdate := map[string]state.RawConfig{
170-
"config_1": {Config: serializedConfig},
173+
"config_1": {Config: serializedConfig, Metadata: state.Metadata{ID: "no_bootstrap_test_id"}},
171174
}
172175

173176
updateStatus := make(map[string]state.ApplyStatus)
@@ -204,7 +207,7 @@ func TestActionsControllerNoMatchingKafkaConsumer(t *testing.T) {
204207
require.NoError(t, err)
205208

206209
rcUpdate := map[string]state.RawConfig{
207-
"config_1": {Config: serializedConfig},
210+
"config_1": {Config: serializedConfig, Metadata: state.Metadata{ID: "no_match_test_id"}},
208211
}
209212

210213
updateStatus := make(map[string]state.ApplyStatus)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
enhancements:
2+
- Add remote config ID tagging to events generated by kafka_action integration for easy UI filtering

0 commit comments

Comments
 (0)