feat: add maintenance window lifecycle workflow triggers#6615
Open
aditya-786 wants to merge 2 commits into
Open
feat: add maintenance window lifecycle workflow triggers#6615aditya-786 wants to merge 2 commits into
aditya-786 wants to merge 2 commits into
Conversation
Fire workflows when a maintenance window is created, updated, or deleted, mirroring the existing incident trigger. The maintenance window is exposed to the workflow through the `maintenance` context.
Contributor
|
No linked issues found. Please add the corresponding issues in the pull request description. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
maintenanceworkflow trigger so workflows can run when a maintenance window changes. This is the lifecycle-events feature requested in #6532, useful for notifying stakeholders (Slack, PagerDuty, email, etc.) when maintenance is scheduled or removed.A workflow subscribes to the actions it cares about:
The window is exposed to the workflow through a
maintenancecontext, so steps can template values like{{ maintenance.name }},{{ maintenance.cel_query }},{{ maintenance.start_time }}and{{ maintenance.end_time }}.How it works
This mirrors the existing incident trigger end to end:
MaintenanceWindowDtois the event object passed to the workflow (inkeep/api/models/db/maintenance_window.py).WorkflowManager.insert_maintenanceenqueues every enabled workflow subscribed to the fired action, reusing a smallget_maintenance_eventshelper for the trigger matching (mirrorsinsert_incident).try/exceptso a workflow failure can never break the maintenance API (mirrorsIncidentBl.send_workflow_event).WorkflowSchedulerandContextManagerroute the new DTO through the same paths already used for alerts and incidents (metricstrigger_type,triggered_bylabel,event_type, and themaintenancecontext key).No schema migration and no new background job are required.
Scope
This PR covers the
created/updated/deletedactions, which are one-shot hooks on the CRUD routes. The time-basedstarted/endedtransitions from the issue are intentionally left for a follow-up, since they need a persisted notified-state and a periodic check and are better reviewed on their own.Tests
tests/test_maintenance_workflow_trigger.py:get_maintenance_eventsfilters by trigger type and flattens the subscribed actions.insert_maintenanceenqueues a matching workflow withtriggered_by="maintenance:created"and the window as the event.insert_maintenanceskips a workflow when the fired action is not one it subscribed to.Relates to #6532