Skip to content

Commit

Permalink
fix: notification repeat interval
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe authored and moshloop committed Sep 4, 2024
1 parent c6418b1 commit f1572b5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 36 deletions.
38 changes: 6 additions & 32 deletions mission-control/docs/notifications/concepts/repeat-interval.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,40 +22,14 @@ spec:
repeatInterval: 2h
```
The above notification sends at max 1 email notification in a moving 2 hour window.
## Grouping Per Resource per Source Event
## Repeat Group
The `repeatInterval` applies per unique resource per unique event source. This prevents duplicate notifications when the same resource triggers the same event type multiple times within the interval window. It still allows notifications for different event types on the same resource within the window.

By default, the repeat interval applies to any notification sent for the given notification.
### Example:

In the example above, if a notification is sent for a `config.healthy` event and then a new notification is to be sent
for a `config.unhealthy` event, then the notification is dropped due to the repeat interval.
With the above notification in place, if a Kubernetes Helm release's health fluctuates between `healthy` and `unhealthy` multiple times within a 2-hour window, the system limits notifications to just two: one for the `config.healthy` event and one for the `config.unhealthy` event.

Check failure on line 31 in mission-control/docs/notifications/concepts/repeat-interval.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] mission-control/docs/notifications/concepts/repeat-interval.mdx#L31

[Flanksource.DictateFeelings] Don't tell people how they feel with words like 'just'.
Raw output
{"message": "[Flanksource.DictateFeelings] Don't tell people how they feel with words like 'just'.", "location": {"path": "mission-control/docs/notifications/concepts/repeat-interval.mdx", "range": {"start": {"line": 31, "column": 196}}}, "severity": "ERROR"}

With grouping, you can apply the repeat interval per source event & per resource ID.
However, if the Helm release health shifts to `warning` during this same period, it triggers an additional notification. This occurs because the warning status is considered a separate event source.

Check warning on line 33 in mission-control/docs/notifications/concepts/repeat-interval.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] mission-control/docs/notifications/concepts/repeat-interval.mdx#L33

[Flanksource.ProfanityUnlikely] Be careful with 'period', it's profane in some cases.
Raw output
{"message": "[Flanksource.ProfanityUnlikely] Be careful with 'period', it's profane in some cases.", "location": {"path": "mission-control/docs/notifications/concepts/repeat-interval.mdx", "range": {"start": {"line": 33, "column": 74}}}, "severity": "WARNING"}

- `source_event`
- `resource_id`

```yaml title="deployment-updates.yaml"
apiVersion: mission-control.flanksource.com/v1
kind: Notification
metadata:
name: config-updates
namespace: default
spec:
events:
- config.healthy
- config.unhealthy
- config.warning
- config.unknown
filter: config.type == "Kubernetes::Deployment"
to:
email: [email protected]
repeatInterval: 2h
// highlight-start
repeatGroup:
- source_event
// highlight-end
```

With this change, you'll now receive at max 4 notifications for each source event.
The notification throttling mechanism operates independently for each distinct resource. As a result, other Helm releases are not affected by this limitation.
2 changes: 1 addition & 1 deletion modules/canary-checker
Submodule canary-checker updated 77 files
+0 −5 .github/dependabot.yml
+1 −1 .github/workflows/lint.yml
+0 −4 .golangci.yml
+10 −5 Makefile
+20 −5 api/context/context.go
+10 −0 api/v1/checks.go
+1 −0 api/v1/common.go
+5 −1 api/v1/component_types.go
+4 −1 api/v1/system_types.go
+1 −1 build/full/Dockerfile
+1 −1 build/minimal/Dockerfile
+3 −0 canary-checker.properties
+1 −1 chart/Chart.yaml
+37 −0 chart/Makefile
+108 −0 chart/README.md
+17 −0 chart/README.md.tpl
+111 −0 chart/ci/full-values.yaml
+9 −0 chart/deref.ts
+0 −12 chart/templates/clusterrolebinding.yaml
+33 −3 chart/templates/deployment.yaml
+15 −0 chart/templates/rbac.yaml
+1 −0 chart/values.schema.deref.json
+554 −0 chart/values.schema.json
+347 −69 chart/values.yaml
+8 −6 checks/aws_config.go
+6 −6 checks/aws_config_rule.go
+9 −6 checks/cloudwatch.go
+2 −2 checks/exec.go
+6 −5 checks/folder.go
+11 −15 checks/folder_s3.go
+3 −18 checks/folder_sftp.go
+12 −16 checks/folder_smb.go
+51 −17 checks/http.go
+2 −1 checks/jmeter.go
+5 −24 checks/kubernetes.go
+12 −34 checks/kubernetes_resource.go
+20 −3 checks/runchecks.go
+7 −59 checks/s3.go
+1 −1 checks/sql.go
+2 −1 checks/tcp.go
+1 −1 cmd/docs.go
+10 −8 cmd/offline.go
+19 −23 cmd/operator.go
+19 −45 cmd/root.go
+14 −5 cmd/run.go
+4 −7 cmd/serve.go
+6 −4 cmd/topology.go
+0 −1 config/canary-dev.yaml
+32 −6 config/deploy/crd.yaml
+32 −6 config/deploy/manifests.yaml
+28 −10 config/schemas/canary.schema.json
+34 −10 config/schemas/component.schema.json
+3 −0 config/schemas/health_awsconfig.schema.json
+3 −0 config/schemas/health_awsconfigrule.schema.json
+3 −0 config/schemas/health_cloudwatch.schema.json
+3 −0 config/schemas/health_exec.schema.json
+13 −10 config/schemas/health_folder.schema.json
+3 −0 config/schemas/health_s3.schema.json
+37 −10 config/schemas/topology.schema.json
+2 −3 fixtures/datasources/s3_bucket_pass.yaml
+3 −0 fixtures/k8s/kubernetes_resource_pod_exit_code_pass.yaml
+80 −54 go.mod
+151 −104 go.sum
+0 −225 hack/generate-schemas/go.mod
+0 −2,135 hack/generate-schemas/go.sum
+1 −7 main.go
+25 −0 pkg/api.go
+9 −2 pkg/db/canary.go
+0 −157 pkg/db/init.go
+0 −36 pkg/db/postgrest.go
+0 −253 pkg/kube.go
+9 −0 pkg/results.go
+19 −4 pkg/runner/runner.go
+98 −0 pkg/runner/runner_test.go
+4 −0 pkg/system_api.go
+1 −13 pkg/topology/run.go
+4 −6 test/run_test.go
2 changes: 1 addition & 1 deletion modules/config-db
Submodule config-db updated 62 files
+0 −5 .github/dependabot.yml
+2 −0 .github/workflows/lint.yml
+24 −0 .github/workflows/test.yml
+12 −3 .gitignore
+37 −12 Makefile
+44 −18 api/cache.go
+27 −6 api/context.go
+2 −0 api/global.go
+60 −0 api/v1/scrapeconfig_types.go
+42 −2 api/v1/types.go
+1 −1 api/v1/zz_generated.deepcopy.go
+12 −2 build/Dockerfile
+8 −0 chart/crds/configs.flanksource.com_scrapeconfigs.yaml
+2 −2 cmd/offline.go
+12 −28 cmd/operator.go
+13 −51 cmd/root.go
+86 −15 cmd/run.go
+29 −72 cmd/server.go
+9 −3 config/schemas/scrape_config.schema.json
+18 −18 db/changes.go
+1 −1 db/config_scraper.go
+121 −0 db/diff.go
+100 −11 db/diff_test.go
+0 −141 db/init.go
+7 −2 db/models/config_change.go
+11 −0 db/models/config_item.go
+0 −47 db/postgrest.go
+1 −1 db/testdata/person-new.json
+15 −15 db/testdata/person.diff
+7 −1 db/testdata/simple-new.json
+7 −2 db/testdata/simple-old.json
+11 −4 db/testdata/simple.diff
+227 −50 db/update.go
+0 −20 db/utils.go
+22 −0 external/diffgen/Cargo.lock
+12 −0 external/diffgen/Cargo.toml
+6 −0 external/diffgen/libdiffgen.h
+41 −0 external/diffgen/src/lib.rs
+16 −0 fixtures/data/echo-playbook.yaml
+12 −0 fixtures/file-crd-sync.yaml
+84 −52 go.mod
+269 −94 go.sum
+2 −0 hack/generate-schemas/.gitignore
+0 −224 hack/generate-schemas/go.mod
+0 −2,140 hack/generate-schemas/go.sum
+7 −2 hack/generate-schemas/main.go
+37 −0 rustdiffgen.go
+61 −7 scrapers/cron.go
+9 −41 scrapers/kubernetes/events_watch.go
+14 −7 scrapers/kubernetes/informers.go
+7 −10 scrapers/kubernetes/kubernetes.go
+4 −10 scrapers/kubernetes/kubernetes_file.go
+1 −1 scrapers/processors/json.go
+2 −2 scrapers/run.go
+1 −1 scrapers/runscrapers.go
+49 −14 scrapers/runscrapers_test.go
+1 −1 scrapers/slack/slack.go
+1 −0 testdata/.gitignore
+0 −58 utils/kube/exec.go
+0 −242 utils/kube/kube.go
+0 −35 utils/kube/kube_test.go
+0 −58 utils/memory.go
2 changes: 1 addition & 1 deletion modules/duty
Submodule duty updated 69 files
+1 −3 .github/workflows/lint.yml
+1 −1 .github/workflows/test.yaml
+3 −0 .gitignore
+13 −1 Makefile
+32 −7 api/config.go
+13 −0 cache/cache.go
+83 −5 connection/aws.go
+28 −0 connection/azure.go
+1 −0 connection/connection.go
+117 −0 connection/environment.go
+320 −0 connection/git.go
+16 −0 connection/s3.go
+47 −16 connection/sftp.go
+47 −21 connection/smb.go
+91 −0 connection/zz_generated.deepcopy.go
+4 −0 context/accessors.go
+60 −10 context/context.go
+55 −24 context/envvar.go
+45 −1 context/metrics.go
+3 −3 context/properties.go
+11 −5 db.go
+29 −7 echo/debug.go
+0 −29 envvar.go
+50 −0 functions/pre_alter_columns.sql
+105 −63 go.mod
+256 −337 go.sum
+2 −0 hack/migrate/.gitignore
+0 −203 hack/migrate/go.mod
+0 −2,374 hack/migrate/go.sum
+1 −0 hack/migrate/main.go
+18 −6 job/cleanup.go
+94 −30 job/job.go
+1 −1 job/job_test.go
+191 −0 kubernetes/dynamic.go
+117 −30 kubernetes/k8s.go
+139 −0 leader/election.go
+1 −1 models/canary.go
+12 −0 models/common.go
+15 −12 models/components.go
+2 −2 models/config.go
+8 −0 models/connections.go
+2 −0 models/notifications.go
+16 −0 models/people.go
+3 −12 models/playbooks.go
+1 −0 models/source.go
+1 −1 models/topology.go
+9 −0 postgrest/postgrest.go
+1 −1 query/topology.go
+6 −5 schema/config.hcl
+9 −0 schema/notifications.hcl
+1 −1 schema/vars.hcl
+84 −0 shell/interpreter.go
+224 −0 shell/shell.go
+23 −0 shell/zz_generated.deepcopy.go
+42 −0 shutdown/shutdown.go
+127 −13 start.go
+1 −0 tests/job_test.go
+11 −22 tests/setup/common.go
+1 −1 tests/upstream_test.go
+2 −4 types/zz_generated.deepcopy.go
+62 −0 upstream/agent_status_ring.go
+42 −27 upstream/controllers.go
+18 −3 views/006_config_views.sql
+1 −0 views/010_topology.sql
+1 −0 views/015_job_history.sql
+1 −0 views/018_playbooks.sql
+1 −0 views/031_casbin_effect.sql
+0 −1 views/031_truncate_casbin.sql
+0 −1 views/032_playbook_nulls.sql
2 changes: 1 addition & 1 deletion modules/mission-control
Submodule mission-control updated 71 files
+1 −1 .github/workflows/build.yml
+1 −1 .github/workflows/codeql.yml
+2 −1 .github/workflows/lint.yml
+5 −5 .github/workflows/release.yml
+1 −1 .github/workflows/scorecard.yml
+14 −1 .github/workflows/test.yml
+4 −4 Dockerfile
+13 −3 Makefile
+0 −2 api/global.go
+7 −0 api/v1/notification_types.go
+43 −6 api/v1/playbook_actions.go
+1 −1 api/v1/playbook_types.go
+7 −1 api/v1/zz_generated.deepcopy.go
+3 −2 artifacts/jobs.go
+8 −0 auth/admin_user.go
+4 −2 auth/kratos.go
+19 −7 auth/middleware.go
+67 −18 cmd/playbook.go
+1 −0 cmd/root.go
+15 −8 cmd/server.go
+0 −40 cmd/shutdown.go
+7 −2 cmd/sync.go
+11 −0 config/crds/mission-control.flanksource.com_notifications.yaml
+94 −3 config/crds/mission-control.flanksource.com_playbooks.yaml
+9 −0 config/schemas/notification.schema.json
+13 −2 config/schemas/playbook-spec.schema.json
+13 −2 config/schemas/playbook.schema.json
+1 −3 connection/controllers.go
+7 −7 db/components.go
+3 −3 db/config.go
+0 −21 db/init.go
+11 −9 db/notifications.go
+16 −5 echo/serve.go
+61 −47 go.mod
+210 −93 go.sum
+2 −0 hack/generate-schemas/.gitignore
+0 −221 hack/generate-schemas/go.mod
+0 −2,144 hack/generate-schemas/go.sum
+1 −1 hack/generate-schemas/main.go
+54 −7 notification/events.go
+80 −0 notification/notification_test.go
+89 −51 notification/send.go
+20 −44 notification/shoutrrr.go
+38 −0 notification/slack.go
+108 −0 notification/template.go
+28 −0 notification/templates/check.failed
+28 −0 notification/templates/check.passed
+26 −0 notification/templates/component.health
+26 −0 notification/templates/config.db.update
+26 −0 notification/templates/config.health
+1 −0 pkg/clients/aws/aws.go
+29 −5 pkg/clients/git/connectors/connectors.go
+28 −15 pkg/clients/git/connectors/git_access_token.go
+3 −4 pkg/clients/git/connectors/git_ssh.go
+12 −12 pkg/clients/git/git.go
+1 −1 playbook/actions/exec.go
+69 −22 playbook/actions/gitops.go
+2 −2 playbook/actions/gitops_test.go
+2 −1 playbook/actions/notification.go
+6 −7 playbook/controllers.go
+1 −1 playbook/events_test.go
+6 −6 playbook/params.go
+6 −6 playbook/playbook.go
+5 −5 playbook/playbook_test.go
+1 −1 playbook/run_consumer.go
+1 −1 playbook/runner/agent.go
+27 −22 playbook/runner/exec.go
+0 −2 playbook/runner/runner.go
+14 −14 snapshot/dump.go
+10 −9 snapshot/snapshot.go
+2 −1 upstream/controllers.go

0 comments on commit f1572b5

Please sign in to comment.