-
Notifications
You must be signed in to change notification settings - Fork 14
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
#3260 - CAS Integration 3A - Create new Supplier and Site - Retry on Error and Scheduler Time #3830
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
0d22c4d
Adding throw error and Canada fix
andrewsignori-aot 8b9e6f5
Merge branch 'main' into feature/#3260-cas-integration-part-4
andrewsignori-aot 62a228e
Adding E2E test for throw
andrewsignori-aot f4fe18e
Minor E2E adjustment
andrewsignori-aot b53cb5a
DB migrations
andrewsignori-aot ffb85e7
E2E improvement
andrewsignori-aot 7433a3c
Fix SFTP issue
andrewsignori-aot 2fdbd65
Changed cron expression to PST
andrewsignori-aot 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
18 changes: 18 additions & 0 deletions
18
.../apps/db-migrations/src/migrations/1729785100207-UpdateCASSupplierIntegrationScheduler.ts
This file contains 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,18 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
import { getSQLFileData } from "../utilities/sqlLoader"; | ||
|
||
export class UpdateCASSupplierIntegrationScheduler1729785100207 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Update-cas-supplier-integration.sql", "Queue"), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
getSQLFileData("Rollback-update-cas-supplier-integration.sql", "Queue"), | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ges/backend/apps/db-migrations/src/sql/Queue/Rollback-update-cas-supplier-integration.sql
This file contains 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,12 @@ | ||
UPDATE | ||
sims.queue_configurations | ||
SET | ||
queue_configuration = '{ | ||
"cron": "0 7 * * *", | ||
"retry": 3, | ||
"cleanUpPeriod": 2592000000, | ||
"retryInterval": 180000, | ||
"dashboardReadonly": false | ||
}' :: json | ||
WHERE | ||
queue_name = 'cas-supplier-integration'; |
12 changes: 12 additions & 0 deletions
12
...ces/packages/backend/apps/db-migrations/src/sql/Queue/Update-cas-supplier-integration.sql
This file contains 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,12 @@ | ||
UPDATE | ||
sims.queue_configurations | ||
SET | ||
queue_configuration = '{ | ||
"cron": "0 19 * * 1-5", | ||
"retry": 3, | ||
"cleanUpPeriod": 2592000000, | ||
"retryInterval": 180000, | ||
"dashboardReadonly": false | ||
}' :: json | ||
WHERE | ||
queue_name = 'cas-supplier-integration'; |
This file contains 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 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 |
---|---|---|
|
@@ -13,7 +13,6 @@ import { | |
logProcessSummaryToJobLogger, | ||
getSuccessMessageWithAttentionCheck, | ||
} from "../../../utilities"; | ||
import { CAS_AUTH_ERROR } from "@sims/integrations/constants"; | ||
|
||
@Processor(QueueNames.CASSupplierIntegration) | ||
export class CASSupplierIntegrationScheduler extends BaseScheduler<void> { | ||
|
@@ -63,19 +62,16 @@ export class CASSupplierIntegrationScheduler extends BaseScheduler<void> { | |
`Records updated: ${suppliersUpdated}.`, | ||
], | ||
processSummary, | ||
{ throwOnError: true }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
); | ||
} catch (error: unknown) { | ||
// Throw an error to force the queue to retry. | ||
if (error instanceof CustomNamedError) { | ||
if (error.name === CAS_AUTH_ERROR) { | ||
// Throw an error to force the queue to retry. | ||
throw new Error( | ||
`Unable to request data to CAS due to an authentication error.`, | ||
); | ||
} | ||
const errorMessage = "Unexpected error while executing the job."; | ||
processSummary.error(errorMessage, error); | ||
return [errorMessage]; | ||
throw new Error(error.message); | ||
sh16011993 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
throw new Error("Unexpected error while executing the job.", { | ||
cause: error, | ||
}); | ||
} finally { | ||
this.logger.logProcessSummary(processSummary); | ||
await logProcessSummaryToJobLogger(processSummary, job); | ||
|
This file contains 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 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.
AC says noon. Either we can have the AC updated or change here.
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.
My bad. I missed the PT part. As we discussed noon PST should be 8PM UTC.
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.
My bad too. All schedulers on wiki are using PST as a reference.
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.
Update to 8 PM UTC which will convert to 12 PM PST.
Updated the wik also.