-
Notifications
You must be signed in to change notification settings - Fork 5
Feature/819 store error messages #827
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e684ddc
Add error_message field to DB
kevinwallimann f4161ef
Store diagnostics in job instance table
kevinwallimann f295c9b
Rename error_message -> diagnostics
kevinwallimann 9cdf362
Add diagnostics to notification
kevinwallimann b1e73aa
List all causes
kevinwallimann cdaaefb
Add bulletpoints
kevinwallimann 8198457
Fixes
kevinwallimann 65779f6
Merge branch 'develop' into feature/819-store-error-messages
kevinwallimann e9c1eeb
Fix format
kevinwallimann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
108 changes: 108 additions & 0 deletions
108
src/main/resources/db_scripts/liquibase/v0.5.20.add-diagnostics-field.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| /* | ||
| * Copyright 2018 ABSA Group Limited | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| ALTER TABLE "job_instance" | ||
| ADD COLUMN "diagnostics" VARCHAR; | ||
| ALTER TABLE "archive_job_instance" | ||
| ADD COLUMN "diagnostics" VARCHAR; | ||
|
|
||
|
|
||
|
|
||
| CREATE OR REPLACE PROCEDURE archive_dag_instances_chunk( | ||
| IN i_min_id BIGINT, | ||
| IN i_max_id BIGINT | ||
| ) | ||
| AS $$ | ||
| ------------------------------------------------------------------------------- | ||
| -- | ||
| -- Procedure: archive_dag_instances_chunk(2) | ||
| -- Copies dag_instances with a final status from i_min_id to i_max_id to the | ||
| -- archive_dag_instance table. | ||
| -- Along with dag_instance, referenced job_instances and events are | ||
| -- archived to the archive_job_instance and archive_event tables, respectively. | ||
| -- This method should not be called directly. Instead, use archive_dag_instances | ||
| -- | ||
| -- Parameters: | ||
| -- i_min_id - Minimum dag instance id to archive | ||
| -- i_max_id - Maximum dag instance id to archive | ||
| -- | ||
| ------------------------------------------------------------------------------- | ||
| DECLARE | ||
| _cnt INT; | ||
| BEGIN | ||
| RAISE NOTICE '============='; | ||
| RAISE NOTICE ' START BATCH'; | ||
| RAISE NOTICE '============='; | ||
|
|
||
| CREATE TEMPORARY TABLE dag_instance_ids_to_archive AS | ||
| SELECT di.id | ||
| FROM dag_instance di | ||
| WHERE di.status NOT IN ('Running', 'InQueue') | ||
| AND di.id >= i_min_id | ||
| AND di.id <= i_max_id; | ||
| GET DIAGNOSTICS _cnt = ROW_COUNT; | ||
| RAISE NOTICE 'Going to archive % dag instances from % to %', _cnt, i_min_id, i_max_id; | ||
|
|
||
| INSERT INTO archive_dag_instance (status, workflow_id, id, started, finished, triggered_by) | ||
| SELECT di.status, di.workflow_id, di.id, di.started, di.finished, di.triggered_by | ||
| FROM dag_instance di | ||
| JOIN dag_instance_ids_to_archive diita ON di.id = diita.id | ||
| ON CONFLICT (id) DO NOTHING; | ||
| GET DIAGNOSTICS _cnt = ROW_COUNT; | ||
| RAISE NOTICE 'Archived % dag instances from % to %', _cnt, i_min_id, i_max_id; | ||
|
|
||
| INSERT INTO archive_job_instance (job_name, job_status, executor_job_id, created, updated, "order", dag_instance_id, id, application_id, step_id, diagnostics) | ||
| SELECT ji.job_name, ji.job_status, ji.executor_job_id, ji.created, ji.updated, ji."order", ji.dag_instance_id, ji.id, ji.application_id, ji.step_id, ji.diagnostics | ||
| FROM job_instance ji | ||
| JOIN dag_instance_ids_to_archive diita ON ji.dag_instance_id = diita.id | ||
| ON CONFLICT (id) DO NOTHING; | ||
| GET DIAGNOSTICS _cnt = ROW_COUNT; | ||
| RAISE NOTICE 'Archived % job instances', _cnt; | ||
|
|
||
| INSERT INTO archive_event (sensor_event_id, sensor_id, dag_instance_id, id, payload) | ||
| SELECT e.sensor_event_id, e.sensor_id, e.dag_instance_id, e.id, e.payload | ||
| FROM "event" e | ||
| JOIN dag_instance_ids_to_archive diita ON e.dag_instance_id = diita.id | ||
| ON CONFLICT (id) DO NOTHING; | ||
| GET DIAGNOSTICS _cnt = ROW_COUNT; | ||
| RAISE NOTICE 'Archived % events', _cnt; | ||
|
|
||
| RAISE NOTICE 'Going to delete dag instances'; | ||
|
|
||
| DELETE FROM job_instance ji | ||
| USING dag_instance_ids_to_archive diita | ||
| WHERE ji.dag_instance_id = diita.id; | ||
| GET DIAGNOSTICS _cnt = ROW_COUNT; | ||
| RAISE NOTICE 'Deleted % job instances', _cnt; | ||
|
|
||
| DELETE FROM "event" e | ||
| USING dag_instance_ids_to_archive diita | ||
| WHERE e.dag_instance_id = diita.id; | ||
| GET DIAGNOSTICS _cnt = ROW_COUNT; | ||
| RAISE NOTICE 'Deleted % events', _cnt; | ||
|
|
||
| DELETE FROM dag_instance di | ||
| USING dag_instance_ids_to_archive diita | ||
| WHERE di.id = diita.id; | ||
| GET DIAGNOSTICS _cnt = ROW_COUNT; | ||
| RAISE NOTICE 'Deleted % dag instances', _cnt; | ||
|
|
||
| DROP TABLE dag_instance_ids_to_archive; | ||
|
|
||
| RAISE NOTICE '============='; | ||
| RAISE NOTICE ' END BATCH'; | ||
| RAISE NOTICE '============='; | ||
| END; | ||
| $$ LANGUAGE plpgsql; |
26 changes: 26 additions & 0 deletions
26
src/main/resources/db_scripts/liquibase/v0.5.20.add-diagnostics-field.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # | ||
| # Copyright 2018 ABSA Group Limited | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
|
|
||
| databaseChangeLog: | ||
| - changeSet: | ||
| id: v0.5.20.add-diagnostics-field | ||
| logicalFilePath: v0.5.20.add-diagnostics-field | ||
| author: HyperdriveDevTeam@absa.africa | ||
| context: default | ||
| changes: | ||
| - sqlFile: | ||
| relativeToChangelogFile: true | ||
| path: v0.5.20.add-diagnostics-field.sql | ||
| splitStatements: false |
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
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
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
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
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
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
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.
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.
I think this one is overkill. I would just add whole text within diagnosticsOpt.