Skip to content
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

#2207 - Investigate Root Cause of Camunda Workers Getting Stuck #2219

Merged
merged 10 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,24 @@ export class ApplicationController {
>
>,
): Promise<MustReturnJobActionAcknowledgement> {
const updateResult = await this.applicationService.updateStatus(
job.variables.applicationId,
job.customHeaders.fromStatus,
job.customHeaders.toStatus,
);
if (!updateResult.affected) {
return job.error(
APPLICATION_STATUS_NOT_UPDATED,
"The application status was not updated either because the application id was not found or the application is not in the expected status.",
try {
const updateResult = await this.applicationService.updateStatus(
job.variables.applicationId,
job.customHeaders.fromStatus,
job.customHeaders.toStatus,
);
if (!updateResult.affected) {
return job.error(
APPLICATION_STATUS_NOT_UPDATED,
"The application status was not updated either because the application id was not found or the application is not in the expected status.",
);
}
return job.complete();
} catch (error: unknown) {
return job.fail(
`Unexpected error while updating the application status. ${error}`,
);
}
return job.complete();
}

/**
Expand All @@ -85,36 +91,42 @@ export class ApplicationController {
>
>,
): Promise<MustReturnJobActionAcknowledgement> {
const application = await this.applicationService.getApplicationById(
job.variables.applicationId,
{ loadDynamicData: true },
);
if (!application) {
return job.error(APPLICATION_NOT_FOUND, "Application id not found.");
}
if (application.applicationException) {
// The exceptions were already processed for this application.
return job.complete({
applicationExceptionStatus:
application.applicationException.exceptionStatus,
});
}
// Check for application exceptions present in the application dynamic data.
const exceptions = this.applicationExceptionService.searchExceptions(
application.data,
);
if (exceptions.length) {
const createdException =
await this.applicationExceptionService.createException(
job.variables.applicationId,
exceptions,
);
try {
const application = await this.applicationService.getApplicationById(
job.variables.applicationId,
{ loadDynamicData: true },
);
if (!application) {
return job.error(APPLICATION_NOT_FOUND, "Application id not found.");
}
if (application.applicationException) {
// The exceptions were already processed for this application.
return job.complete({
applicationExceptionStatus:
application.applicationException.exceptionStatus,
});
}
// Check for application exceptions present in the application dynamic data.
const exceptions = this.applicationExceptionService.searchExceptions(
application.data,
);
if (exceptions.length) {
const createdException =
await this.applicationExceptionService.createException(
job.variables.applicationId,
exceptions,
);
return job.complete({
applicationExceptionStatus: createdException.exceptionStatus,
});
}
return job.complete({
applicationExceptionStatus: createdException.exceptionStatus,
applicationExceptionStatus: ApplicationExceptionStatus.Approved,
});
} catch (error: unknown) {
return job.fail(
`Unexpected error while verifying the application exceptions. ${error}`,
);
}
return job.complete({
applicationExceptionStatus: ApplicationExceptionStatus.Approved,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,24 @@ export class AssessmentController {
ZeebeJob<AssessmentDataJobInDTO, ICustomHeaders, IOutputVariables>
>,
): Promise<MustReturnJobActionAcknowledgement> {
const assessment = await this.studentAssessmentService.getById(
job.variables.assessmentId,
);
if (!assessment) {
return job.error(ASSESSMENT_NOT_FOUND, "Assessment not found.");
try {
const assessment = await this.studentAssessmentService.getById(
job.variables.assessmentId,
);
if (!assessment) {
return job.error(ASSESSMENT_NOT_FOUND, "Assessment not found.");
}
const assessmentDTO = this.transformToAssessmentDTO(assessment);
const outputVariables = filterObjectProperties(
assessmentDTO,
job.customHeaders,
);
return job.complete(outputVariables);
} catch (error: unknown) {
return job.fail(
`Unexpected error while loading assessment consolidated data. ${error}`,
);
}
const assessmentDTO = this.transformToAssessmentDTO(assessment);
const outputVariables = filterObjectProperties(
assessmentDTO,
job.customHeaders,
);
return job.complete(outputVariables);
}

/**
Expand All @@ -127,11 +133,15 @@ export class AssessmentController {
ZeebeJob<SaveAssessmentDataJobInDTO, ICustomHeaders, IOutputVariables>
>,
): Promise<MustReturnJobActionAcknowledgement> {
await this.studentAssessmentService.updateAssessmentData(
job.variables.assessmentId,
job.variables.assessmentData,
);
return job.complete();
try {
await this.studentAssessmentService.updateAssessmentData(
job.variables.assessmentId,
job.variables.assessmentData,
);
return job.complete();
} catch (error: unknown) {
return job.fail(`Unexpected error saving the assessment data. ${error}`);
}
}

/**
Expand All @@ -150,11 +160,17 @@ export class AssessmentController {
>
>,
): Promise<MustReturnJobActionAcknowledgement> {
await this.studentAssessmentService.updateNOAApprovalStatus(
job.variables.assessmentId,
job.customHeaders.status,
);
return job.complete();
try {
await this.studentAssessmentService.updateNOAApprovalStatus(
job.variables.assessmentId,
job.customHeaders.status,
);
return job.complete();
} catch (error: unknown) {
return job.fail(
`Unexpected error while updating the NOA status. ${error}`,
);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,26 @@ export class CRAIntegrationController {
>
>,
): Promise<MustReturnJobActionAcknowledgement> {
const incomeRequest =
await this.incomeVerificationService.createIncomeVerification(
job.variables.applicationId,
job.variables.taxYear,
job.variables.reportedIncome,
job.variables.supportingUserId,
);
const [identifier] = incomeRequest.identifiers;
try {
const incomeRequest =
await this.incomeVerificationService.createIncomeVerification(
job.variables.applicationId,
job.variables.taxYear,
job.variables.reportedIncome,
job.variables.supportingUserId,
);
const [identifier] = incomeRequest.identifiers;

await this.incomeVerificationService.checkForCRAIncomeVerificationBypass(
identifier.id,
);
await this.incomeVerificationService.checkForCRAIncomeVerificationBypass(
identifier.id,
);

return job.complete({ incomeVerificationId: identifier.id });
return job.complete({ incomeVerificationId: identifier.id });
} catch (error: unknown) {
return job.fail(
`Unexpected error while creating the CRA income verification. ${error}`,
);
}
}

/**
Expand All @@ -85,10 +91,16 @@ export class CRAIntegrationController {
>
>,
): Promise<MustReturnJobActionAcknowledgement> {
const incomeVerificationCompleted =
await this.incomeVerificationService.isIncomeVerificationCompleted(
job.variables.incomeVerificationId,
try {
const incomeVerificationCompleted =
await this.incomeVerificationService.isIncomeVerificationCompleted(
job.variables.incomeVerificationId,
);
return job.complete({ incomeVerificationCompleted });
} catch (error: unknown) {
return job.fail(
`Unexpected error while checking the CRA income verification. ${error}`,
);
return job.complete({ incomeVerificationCompleted });
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,33 @@ export class ProgramInfoRequestController {
>
>,
): Promise<MustReturnJobActionAcknowledgement> {
const application = await this.applicationService.getApplicationById(
job.variables.applicationId,
{ loadDynamicData: false },
);
if (!application) {
return job.error(
APPLICATION_NOT_FOUND,
"Application not found while verifying the PIR.",
try {
const application = await this.applicationService.getApplicationById(
job.variables.applicationId,
{ loadDynamicData: false },
);
if (!application) {
return job.error(
APPLICATION_NOT_FOUND,
"Application not found while verifying the PIR.",
);
}
if (application.pirStatus) {
// PIR status was already set, just return it.
return job.complete({
programInfoStatus: application.pirStatus,
});
}
await this.applicationService.updateProgramInfoStatus(
job.variables.applicationId,
job.customHeaders.programInfoStatus,
job.variables.studentDataSelectedProgram,
);
}
if (application.pirStatus) {
// PIR status was already set, just return it.
return job.complete({
programInfoStatus: application.pirStatus,
programInfoStatus: job.customHeaders.programInfoStatus,
});
} catch (error: unknown) {
return job.fail(`Unexpected error while seting the PIR status. ${error}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo on "seting".

}
await this.applicationService.updateProgramInfoStatus(
job.variables.applicationId,
job.customHeaders.programInfoStatus,
job.variables.studentDataSelectedProgram,
);
return job.complete({
programInfoStatus: job.customHeaders.programInfoStatus,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,26 @@ export class SupportingUserController {
>
>,
): Promise<MustReturnJobActionAcknowledgement> {
const hasSupportingUsers =
await this.supportingUserService.hasSupportingUsers(
job.variables.applicationId,
try {
const hasSupportingUsers =
await this.supportingUserService.hasSupportingUsers(
job.variables.applicationId,
);
if (hasSupportingUsers) {
return job.complete();
}
const supportingUsers =
await this.supportingUserService.createSupportingUsers(
job.variables.applicationId,
job.variables.supportingUsersTypes,
);
const createdSupportingUsersIds = supportingUsers.map(
(supportingUser) => supportingUser.id,
);
if (hasSupportingUsers) {
return job.complete();
return job.complete({ createdSupportingUsersIds });
} catch (error: unknown) {
return job.fail(`Unexpected error creating supporting users. ${error}`);
}
const supportingUsers =
await this.supportingUserService.createSupportingUsers(
job.variables.applicationId,
job.variables.supportingUsersTypes,
);
const createdSupportingUsersIds = supportingUsers.map(
(supportingUser) => supportingUser.id,
);
return job.complete({ createdSupportingUsersIds });
}

@ZeebeWorker(Workers.LoadSupportingUserData, {
Expand All @@ -70,20 +74,26 @@ export class SupportingUserController {
>
>,
): Promise<MustReturnJobActionAcknowledgement> {
const supportingUser =
await this.supportingUserService.getSupportingUserById(
job.variables.supportingUserId,
try {
const supportingUser =
await this.supportingUserService.getSupportingUserById(
job.variables.supportingUserId,
);
if (!supportingUser) {
job.error(
SUPPORTING_USER_NOT_FOUND,
"Supporting user not found while checking for supporting user response.",
);
}
const outputVariables = filterObjectProperties(
supportingUser.supportingData,
job.customHeaders,
);
if (!supportingUser) {
job.error(
SUPPORTING_USER_NOT_FOUND,
"Supporting user not found while checking for supporting user response.",
return job.complete(outputVariables);
} catch (error: unknown) {
return job.fail(
`Unexpected error while loading supporting user data. ${error}`,
);
}
const outputVariables = filterObjectProperties(
supportingUser.supportingData,
job.customHeaders,
);
return job.complete(outputVariables);
}
}