Skip to content

Commit 3a72713

Browse files
authored
fix(observability): Set contribute attribute for main route to read only (#1213)
Signed-off-by: Alexander Dahmen <alexander.dahmen@inovex.de>
1 parent aba82ea commit 3a72713

6 files changed

Lines changed: 26 additions & 3 deletions

File tree

docs/data-sources/observability_instance.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Read-Only:
136136

137137
Read-Only:
138138

139+
- `continue` (Boolean) Whether an alert should continue matching subsequent sibling nodes.
139140
- `group_by` (List of String) The labels by which incoming alerts are grouped together. For example, multiple alerts coming in for cluster=A and alertname=LatencyHigh would be batched into a single group. To aggregate by all possible labels use the special value '...' as the sole label name, for example: group_by: ['...']. This effectively disables aggregation entirely, passing through all alerts as-is. This is unlikely to be what you want, unless you have a very low alert volume or your upstream notification system performs its own grouping.
140141
- `group_interval` (String) How long to wait before sending a notification about new alerts that are added to a group of alerts for which an initial notification has already been sent. (Usually ~5m or more.)
141142
- `group_wait` (String) How long to initially wait to send a notification for a group of alerts. Allows to wait for an inhibiting alert to arrive or collect more initial alerts for the same group. (Usually ~0s to few minutes.) .

docs/resources/observability_instance.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ Optional:
153153
- `repeat_interval` (String) How long to wait before sending a notification again if it has already been sent successfully for an alert. (Usually ~3h or more).
154154
- `routes` (Attributes List) List of child routes. (see [below for nested schema](#nestedatt--alert_config--route--routes))
155155

156+
Read-Only:
157+
158+
- `continue` (Boolean) Whether an alert should continue matching subsequent sibling nodes.
159+
156160
<a id="nestedatt--alert_config--route--routes"></a>
157161
### Nested Schema for `alert_config.route.routes`
158162

stackit/internal/services/observability/instance/datasource.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,10 @@ func (d *instanceDataSource) Schema(_ context.Context, _ datasource.SchemaReques
309309
Description: "The route for the alert.",
310310
Computed: true,
311311
Attributes: map[string]schema.Attribute{
312+
"continue": schema.BoolAttribute{
313+
Description: routeDescriptions["continue"],
314+
Computed: true,
315+
},
312316
"group_by": schema.ListAttribute{
313317
Description: "The labels by which incoming alerts are grouped together. For example, multiple alerts coming in for cluster=A and alertname=LatencyHigh would be batched into a single group. To aggregate by all possible labels use the special value '...' as the sole label name, for example: group_by: ['...']. This effectively disables aggregation entirely, passing through all alerts as-is. This is unlikely to be what you want, unless you have a very low alert volume or your upstream notification system performs its own grouping.",
314318
Computed: true,

stackit/internal/services/observability/instance/resource.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ var globalConfigurationTypes = map[string]attr.Type{
125125

126126
// Struct corresponding to Model.AlertConfig.route
127127
type mainRouteModel struct {
128+
Continue types.Bool `tfsdk:"continue"`
128129
GroupBy types.List `tfsdk:"group_by"`
129130
GroupInterval types.String `tfsdk:"group_interval"`
130131
GroupWait types.String `tfsdk:"group_wait"`
@@ -167,6 +168,7 @@ type routeModelNoRoutes struct {
167168
}
168169

169170
var mainRouteTypes = map[string]attr.Type{
171+
"continue": types.BoolType,
170172
"group_by": types.ListType{ElemType: types.StringType},
171173
"group_interval": types.StringType,
172174
"group_wait": types.StringType,
@@ -771,6 +773,11 @@ func (r *instanceResource) Schema(_ context.Context, _ resource.SchemaRequest, r
771773
Description: "Route configuration for the alerts.",
772774
Required: true,
773775
Attributes: map[string]schema.Attribute{
776+
"continue": schema.BoolAttribute{
777+
Description: routeDescriptions["continue"],
778+
Computed: true,
779+
Default: booldefault.StaticBool(false),
780+
},
774781
"group_by": schema.ListAttribute{
775782
Description: routeDescriptions["group_by"],
776783
Optional: true,
@@ -1826,6 +1833,7 @@ func getMockAlertConfig(ctx context.Context) (alertConfigModel, error) {
18261833
}
18271834

18281835
mockRoute, diags := types.ObjectValue(mainRouteTypes, map[string]attr.Value{
1836+
"continue": types.BoolValue(false),
18291837
"receiver": types.StringValue("email-me"),
18301838
"group_by": mockGroupByList,
18311839
"group_wait": types.StringValue("30s"),
@@ -2057,6 +2065,7 @@ func mapRouteToAttributes(ctx context.Context, route *observability.Route) (attr
20572065
}
20582066

20592067
routeMap := map[string]attr.Value{
2068+
"continue": types.BoolPointerValue(route.Continue),
20602069
"group_by": groupByModel,
20612070
"group_interval": types.StringPointerValue(route.GroupInterval),
20622071
"group_wait": types.StringPointerValue(route.GroupWait),
@@ -2397,6 +2406,7 @@ func toRoutePayload(ctx context.Context, routeTF *mainRouteModel) (*observabilit
23972406
}
23982407

23992408
return &observability.UpdateAlertConfigsPayloadRoute{
2409+
Continue: conversion.BoolValueToPointer(routeTF.Continue),
24002410
GroupBy: groupByPayload,
24012411
GroupInterval: conversion.StringValueToPointer(routeTF.GroupInterval),
24022412
GroupWait: conversion.StringValueToPointer(routeTF.GroupWait),

stackit/internal/services/observability/instance/resource_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ func fixtureReceiverModel(emailConfigs, opsGenieConfigs, webHooksConfigs basetyp
6565

6666
func fixtureRouteModel() basetypes.ObjectValue {
6767
return types.ObjectValueMust(mainRouteTypes, map[string]attr.Value{
68+
"continue": types.BoolValue(false),
6869
"group_by": types.ListValueMust(types.StringType, []attr.Value{
6970
types.StringValue("label1"),
7071
types.StringValue("label2"),
@@ -98,6 +99,7 @@ func fixtureRouteModel() basetypes.ObjectValue {
9899

99100
func fixtureNullRouteModel() basetypes.ObjectValue {
100101
return types.ObjectValueMust(mainRouteTypes, map[string]attr.Value{
102+
"continue": types.BoolNull(),
101103
"group_by": types.ListNull(types.StringType),
102104
"group_interval": types.StringNull(),
103105
"group_wait": types.StringNull(),
@@ -175,7 +177,7 @@ func fixtureReceiverPayload(emailConfigs *[]observability.CreateAlertConfigRecei
175177

176178
func fixtureRoutePayload() *observability.UpdateAlertConfigsPayloadRoute {
177179
return &observability.UpdateAlertConfigsPayloadRoute{
178-
Continue: nil,
180+
Continue: utils.Ptr(false),
179181
GroupBy: utils.Ptr([]string{"label1", "label2"}),
180182
GroupInterval: utils.Ptr("1m"),
181183
GroupWait: utils.Ptr("1m"),
@@ -252,7 +254,7 @@ func fixtureWebHooksConfigsResponse() observability.WebHook {
252254

253255
func fixtureRouteResponse() *observability.Route {
254256
return &observability.Route{
255-
Continue: nil,
257+
Continue: utils.Ptr(false),
256258
GroupBy: utils.Ptr([]string{"label1", "label2"}),
257259
GroupInterval: utils.Ptr("1m"),
258260
GroupWait: utils.Ptr("1m"),

stackit/internal/services/observability/observability_acc_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ var testConfigVarsMax = config.Variables{
110110
"match": config.StringVariable("alert1"),
111111
"match_regex": config.StringVariable("alert1"),
112112
"matchers": config.StringVariable("instance =~ \".*\""),
113-
"continue": config.StringVariable("true"),
113+
"continue": config.StringVariable("false"),
114114
// credential
115115
"credential_description": config.StringVariable("This is a description for the test credential."),
116116
// logalertgroup
@@ -549,6 +549,7 @@ func TestAccResourceMax(t *testing.T) {
549549
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.group_wait", testutil.ConvertConfigVariable(testConfigVarsMax["group_wait"])),
550550
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.receiver", testutil.ConvertConfigVariable(testConfigVarsMax["receiver_name"])),
551551
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.repeat_interval", testutil.ConvertConfigVariable(testConfigVarsMax["repeat_interval"])),
552+
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.continue", testutil.ConvertConfigVariable(testConfigVarsMax["continue"])),
552553

553554
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.routes.0.group_by.0", testutil.ConvertConfigVariable(testConfigVarsMax["group_by"])),
554555
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.routes.0.group_interval", testutil.ConvertConfigVariable(testConfigVarsMax["group_interval"])),
@@ -955,6 +956,7 @@ func TestAccResourceMax(t *testing.T) {
955956
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.group_wait", testutil.ConvertConfigVariable(testConfigVarsMax["group_wait"])),
956957
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.receiver", testutil.ConvertConfigVariable(testConfigVarsMax["receiver_name"])),
957958
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.repeat_interval", testutil.ConvertConfigVariable(testConfigVarsMax["repeat_interval"])),
959+
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.continue", testutil.ConvertConfigVariable(testConfigVarsMax["continue"])),
958960

959961
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.routes.0.group_by.0", testutil.ConvertConfigVariable(testConfigVarsMax["group_by"])),
960962
resource.TestCheckResourceAttr("stackit_observability_instance.instance", "alert_config.route.routes.0.group_interval", testutil.ConvertConfigVariable(testConfigVarsMax["group_interval"])),

0 commit comments

Comments
 (0)