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

Harmony 1996: Add 'empty-result' status to WorkItem class and work-items table #683

Merged
merged 9 commits into from
Jan 27, 2025

Conversation

indiejames
Copy link
Contributor

Jira Issue ID

HARMONY-1996

Description

This PR adds a new status to WorkItem to represent when a service processed the work-item, but produced to data. This is to allow us to provide a better experience for users by not staging empty files.

Local Test Steps

  1. Use dbViz to update a work-item's status to 'empty-result' and verify that this is allowed. (This change will not be visible anywhere until further tickets are worked)
  2. Run a Harmony request and verify that it goes through okay.
  3. Check the status page and workflow UI to make sure the behavior has not changed

PR Acceptance Checklist

  • Acceptance criteria met
  • Tests added/updated (if needed) and passing
  • Documentation updated (if needed)
  • [ x] Harmony in a Box tested? (if changes made to microservices)

db/db.sql Outdated
@@ -80,7 +92,8 @@ CREATE TABLE `work_items` (
`workflowStepIndex` integer not null,
`scrollID` varchar(4096),
`serviceID` varchar(255) not null,
`status` text check (`status` in ('ready', 'queued', 'running', 'successful', 'failed', 'canceled')) not null,
`status` varchar(255) check (`status` in ('ready', 'queued', 'running', 'successful', 'failed', 'canceled', 'warning')) not null,
`subStatus` varchar(255) check (`subStatus` in ('no-data')),
Copy link
Member

Choose a reason for hiding this comment

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

The column name should besub_status to match the Postgres definition.

Copy link
Member

Choose a reason for hiding this comment

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

The value is missing null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

db/db.sql Outdated
CREATE INDEX work_items_jobID_idx ON work_items(jobID);
CREATE INDEX work_items_serviceID_idx ON work_items(serviceID);
CREATE INDEX work_items_status_idx ON work_items(status);
CREATE INDEX work_items_subStatus_idx ON work_items(subStatus);
Copy link
Member

Choose a reason for hiding this comment

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

The column name should besub_status to match the Postgres definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

db/db.sql Outdated
)
) not null default 'error',
`category` varchar(255) check (
`category` in (
Copy link
Collaborator

@vinnyinverso vinnyinverso Jan 24, 2025

Choose a reason for hiding this comment

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

Do we want to have to change this check every time a new category is added in service lib? If we're adding new categories only via pull request in the service lib, it has been validated already by the time it gets to Harmony. This is also missing the existing error categories like "Server", "Forbidden".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I'll drop this constraint here as well as in the migration.

@@ -51,6 +51,9 @@ export default class WorkItem extends Record implements WorkItemRecord {
// The status of the operation - see WorkItemStatus
status?: WorkItemStatus;

// The sub-status of the operation - see WorkItemSubStatus
subStatus?: WorkItemSubStatus;
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think we have coding standard to use underscores in new column names. i.e. sub_status.
I commented above that the sub_status name is not consistent in db definition vs migration. If you want to go with subStatus, it is fine with me as long as we make it consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason I thought it could be snake case in the dB, but camel case in the models. I see now that we are not doing that (maybe it doesn't work). I'll make it snake case here.

Copy link
Contributor

@chris-durbin chris-durbin left a comment

Choose a reason for hiding this comment

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

I have a general question about sub_status and category. I see in work_items we are calling the field sub_status and in job_errors we're calling it category. I believe they are the same thing - would it be better to use the same column name?

CHECK (status IN ('ready', 'queued', 'running', 'successful', 'failed', 'canceled', 'warning')),
ADD COLUMN "sub_status" VARCHAR(255),
ADD CONSTRAINT "work_items_sub_status_check"
CHECK (sub_status IN (null, 'no-data'));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should have an enumeration on this field which I think we were calling "category" - we should allow any string and don't need this constraint.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

ADD COLUMN "category" VARCHAR(255) DEFAULT 'generic' NOT NULL;

CREATE INDEX job_errors_level ON job_errors (level);
CREATE INDEX job_errors_category ON job_errors (category)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if it matters, but for consistency should we have each statement end in a semi-colon?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

DROP INDEX job_errors_category;
DROP_INDEX job_errors_level;
ALTER TABLE "job_errors"
DROP CONSTRAINT "job_errors_category_check",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see a job_error_category_check constraint in the up migration - and I don't think we want one so assume this should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -10,7 +10,10 @@
"allowJs": true,
"noImplicitAny": false,
"sourceMap": true,
"outDir": "built"
"outDir": "built",
"typeRoots": [
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity what does this fix - anything we should do differently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was having consistent failures from tsc complaining about not finding types for lots of packages. This tells it where to look. Not sure why no one else has seen these errors.

CHECK (status IN ('ready', 'queued', 'running', 'successful', 'failed', 'canceled', 'warning')),
ADD COLUMN "sub_status" VARCHAR(255);

CREATE INDEX work_items_sub_status ON work_items (sub_status);
Copy link
Member

Choose a reason for hiding this comment

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

nit: add _index to index name for consistency. i.e. work_items_sub_status_index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

CHECK (level IN ('error', 'warning')),
ADD COLUMN "category" VARCHAR(255);

CREATE INDEX job_errors_level ON job_errors (level);
Copy link
Member

Choose a reason for hiding this comment

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

same comment with index naming convention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

*/
exports.down = function (knex) {
return knex.schema.raw(`
DROP INDEX job_errors_category;
Copy link
Member

Choose a reason for hiding this comment

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

I got - syntax error at or near "DROP_INDEX" error when running the down migration.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ugh - fixed here and in the other migration

ALTER TABLE "job_errors"
DROP COLUMN "category",
DROP CONSTRAINT "job_errors_level_check",
DROP COLUMN "level;"
Copy link
Member

Choose a reason for hiding this comment

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

typo in level;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member

@ygliuvt ygliuvt left a comment

Choose a reason for hiding this comment

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

Need to fix the down migration issue.

@indiejames
Copy link
Contributor Author

Need to fix the down migration issue.

Done

@indiejames indiejames requested a review from ygliuvt January 27, 2025 17:01
Copy link
Contributor

@chris-durbin chris-durbin left a comment

Choose a reason for hiding this comment

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

Successfully tested the migrations and rollbacks. Verified requests continued to work as expected.

Copy link
Member

@ygliuvt ygliuvt left a comment

Choose a reason for hiding this comment

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

Tested successfully.

@indiejames indiejames merged commit 229aa98 into main Jan 27, 2025
5 checks passed
@indiejames indiejames deleted the harmony-1996 branch January 27, 2025 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants