-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add DataConditions for workflow_engine #77448
base: master
Are you sure you want to change the base?
Conversation
🚨 Warning: This pull request contains Frontend and Backend changes! It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently. Have questions? Please ask in the |
This PR has a migration; here is the generated SQL for --
-- Create model DataCondition
--
CREATE TABLE "workflow_engine_datacondition" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "condition" varchar(200) NOT NULL, "threshold" double precision NOT NULL, "condition_result" jsonb NOT NULL, "type" varchar(200) NOT NULL, "detectors_id" bigint NOT NULL, "workflow_action_id" bigint NOT NULL);
ALTER TABLE "workflow_engine_datacondition" ADD CONSTRAINT "workflow_engine_data_detectors_id_d9f45fc7_fk_workflow_" FOREIGN KEY ("detectors_id") REFERENCES "workflow_engine_detector" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_datacondition" VALIDATE CONSTRAINT "workflow_engine_data_detectors_id_d9f45fc7_fk_workflow_";
ALTER TABLE "workflow_engine_datacondition" ADD CONSTRAINT "workflow_engine_data_workflow_action_id_7d1dcfde_fk_workflow_" FOREIGN KEY ("workflow_action_id") REFERENCES "workflow_engine_workflowaction" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_datacondition" VALIDATE CONSTRAINT "workflow_engine_data_workflow_action_id_7d1dcfde_fk_workflow_";
CREATE INDEX CONCURRENTLY "workflow_engine_datacondition_detectors_id_d9f45fc7" ON "workflow_engine_datacondition" ("detectors_id");
CREATE INDEX CONCURRENTLY "workflow_engine_datacondition_workflow_action_id_7d1dcfde" ON "workflow_engine_datacondition" ("workflow_action_id"); |
❌ 1467 Tests Failed:
View the top 3 failed tests by shortest run time
To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard |
4bc1003
to
fc5cf8e
Compare
fc5cf8e
to
453c7ee
Compare
453c7ee
to
448c9aa
Compare
448c9aa
to
5266e33
Compare
This PR has a migration; here is the generated SQL for --
-- Create model DataCondition
--
CREATE TABLE "workflow_engine_datacondition" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "condition" varchar(200) NOT NULL, "threshold" double precision NOT NULL, "condition_result" jsonb NOT NULL, "type" varchar(200) NOT NULL, "detector_id" bigint NOT NULL, "workflow_action_id" bigint NOT NULL);
ALTER TABLE "workflow_engine_datacondition" ADD CONSTRAINT "workflow_engine_data_detector_id_c0979477_fk_workflow_" FOREIGN KEY ("detector_id") REFERENCES "workflow_engine_detector" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_datacondition" VALIDATE CONSTRAINT "workflow_engine_data_detector_id_c0979477_fk_workflow_";
ALTER TABLE "workflow_engine_datacondition" ADD CONSTRAINT "workflow_engine_data_workflow_action_id_7d1dcfde_fk_workflow_" FOREIGN KEY ("workflow_action_id") REFERENCES "workflow_engine_workflowaction" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_datacondition" VALIDATE CONSTRAINT "workflow_engine_data_workflow_action_id_7d1dcfde_fk_workflow_";
CREATE INDEX CONCURRENTLY "workflow_engine_datacondition_detector_id_c0979477" ON "workflow_engine_datacondition" ("detector_id");
CREATE INDEX CONCURRENTLY "workflow_engine_datacondition_workflow_action_id_7d1dcfde" ON "workflow_engine_datacondition" ("workflow_action_id"); |
391c1f0
to
1531f7b
Compare
4b2a71a
to
637d4af
Compare
This PR has a migration; here is the generated SQL for --
-- Create model DataConditionGroup
--
CREATE TABLE "workflow_engine_dataconditiongroup" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "logic_type" varchar(200) NOT NULL, "detector_id" bigint NULL, "workflow_action_id" bigint NULL);
ALTER TABLE "workflow_engine_dataconditiongroup" ADD CONSTRAINT "workflow_engine_data_detector_id_5b8d9491_fk_workflow_" FOREIGN KEY ("detector_id") REFERENCES "workflow_engine_detector" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_dataconditiongroup" VALIDATE CONSTRAINT "workflow_engine_data_detector_id_5b8d9491_fk_workflow_";
ALTER TABLE "workflow_engine_dataconditiongroup" ADD CONSTRAINT "workflow_engine_data_workflow_action_id_600a68ea_fk_workflow_" FOREIGN KEY ("workflow_action_id") REFERENCES "workflow_engine_workflowaction" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_dataconditiongroup" VALIDATE CONSTRAINT "workflow_engine_data_workflow_action_id_600a68ea_fk_workflow_";
CREATE INDEX CONCURRENTLY "workflow_engine_dataconditiongroup_detector_id_5b8d9491" ON "workflow_engine_dataconditiongroup" ("detector_id");
CREATE INDEX CONCURRENTLY "workflow_engine_dataconditiongroup_workflow_action_id_600a68ea" ON "workflow_engine_dataconditiongroup" ("workflow_action_id");
--
-- Create model DataCondition
--
CREATE TABLE "workflow_engine_datacondition" ("id" bigint NOT NULL PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, "date_updated" timestamp with time zone NOT NULL, "date_added" timestamp with time zone NOT NULL, "condition" varchar(200) NOT NULL, "threshold" double precision NOT NULL, "condition_result" jsonb NOT NULL, "type" varchar(200) NOT NULL, "condition_group_id" bigint NOT NULL);
ALTER TABLE "workflow_engine_datacondition" ADD CONSTRAINT "workflow_engine_data_condition_group_id_122daf08_fk_workflow_" FOREIGN KEY ("condition_group_id") REFERENCES "workflow_engine_dataconditiongroup" ("id") DEFERRABLE INITIALLY DEFERRED NOT VALID;
ALTER TABLE "workflow_engine_datacondition" VALIDATE CONSTRAINT "workflow_engine_data_condition_group_id_122daf08_fk_workflow_";
CREATE INDEX CONCURRENTLY "workflow_engine_datacondition_condition_group_id_122daf08" ON "workflow_engine_datacondition" ("condition_group_id"); |
057baf8
to
259fef9
Compare
259fef9
to
784d5c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Schema looks good to me.
784d5c6
to
8cde9cb
Compare
8cde9cb
to
1aa4e69
Compare
1aa4e69
to
3489a07
Compare
3489a07
to
7d15b8c
Compare
|
||
condition = models.CharField(max_length=200) | ||
threshold = models.FloatField() | ||
condition_result = models.JSONField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are we planning to handle the schema for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This schema would just be a primitive value; either a string for the detector or boolean for the workflow actions. i can imagine some other scenarios that having this be flexible as a json primitive - but it should never be a compex object / array etc.
is there a good way to enforce that? (off the top of my head, we could have a pre-save signal that validates it's a primitive or throws an exception? 🤔)
@region_silo_model | ||
class DataConditionGroup(DefaultFieldsModel): | ||
""" | ||
A data condition is a way to specify a condition that must be met for a workflow to execute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A data group is a way to specify a group of conditions that must be met for a workflow action to execute
workflow_action = models.ForeignKey( | ||
WorkflowAction, on_delete=models.CASCADE, blank=True, null=True | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we allow multiple workflow actions to be linked here? So this group of conditions fires this group of actions?
…ated a new model called data condition group which will also store logic gates for the data conditions
7d15b8c
to
a53b0ef
Compare
- Changed workflow_action to be action, and more generic. will use this to emit events on detectors or send notifications in workflows - Created lookup tables; detector_workflow and workflow_data_condition_group - Updated detector and workflow models to represent new design
a53b0ef
to
c06a163
Compare
Description
📜 Technical spec
PR Changes
DataCondition
with a 1 to many relationship forDataConditionGroups
the Group model allows us to defineANY
andALL
, and group the conditions for evaluation.