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

fix(jobs): Fixes creating worker with deleteSuccessfulJobs config setting in JobManager #11653

Merged
merged 2 commits into from
Oct 5, 2024

Conversation

dthyresson
Copy link
Contributor

According to the Job documentation, the JobManager's deleteSuccessfulJobs can be used to decide if one wants successfully completed jobs from being deleted from the BackgroundJobs table.

Keeping job run history around is useful for reporting purposes, such s hoe many jobs run over time, how many fails, how many successes, etc.

However, the deleteSuccessfulJobs was not being correctly passed to the worker in createWorker so the worker always used the default value -- true -- and always deleted the job run record regardless of configuration.

This PR fixes this issue by setting the config value when creating the worker.

@dthyresson dthyresson added the release:fix This PR is a fix label Oct 5, 2024
@dthyresson dthyresson added this to the next-release-patch milestone Oct 5, 2024
@dthyresson dthyresson marked this pull request as ready for review October 5, 2024 13:46
@dthyresson dthyresson requested a review from cannikin October 5, 2024 13:46
@dthyresson
Copy link
Contributor Author

dthyresson commented Oct 5, 2024

Not sure why jobs e2e is failing in CI.

Running locally passes:

redwood dt-fix-job-delete-success-config % yarn e2e:background-jobs ../rw-test-project
Running background jobs E2E tests in project: ...redwoodjs/rw-test-project
Testing: `yarn rw setup jobs`
Confirmed: job config file
Confirmed: jobs directory
Confirmed: jobs dependency in api package.json
Testing: `yarn rw prisma migrate dev`
Action: Adding scripts to get information from the database
Testing: the prisma model exists in the database
Confirmed: prisma model exists
Testing: `yarn rw generate job SampleJob`
Action: Altering the job to perform some test logic
Action: Adding a function to trigger scheduling a job
Action: Running `yarn rw serve api`
Action: Triggering the function
Action: Stopping the api server
Testing: Confirming the job did not run synchronously
Confirmed: job did not run synchronously
Testing: Confirming the job was scheduled into the database
Confirmed: job was scheduled into the database
Testing: `yarn rw jobs workoff`
Testing: Confirming the job ran
Confirmed: job ran
Testing: Confirming the job was removed from the database
Confirmed: job was removed from the database
All tests passed
redwood dt-fix-job-delete-success-config % 

Maybe a prior e2e setup run "does something"?

@Tobbe Tobbe merged commit bef7939 into main Oct 5, 2024
48 of 58 checks passed
@Tobbe Tobbe deleted the dt-fix-job-delete-success-config branch October 5, 2024 20:23
Josh-Walker-GM pushed a commit that referenced this pull request Oct 8, 2024
…ting in JobManager (#11653)

According to the Job documentation, the JobManager's
`deleteSuccessfulJobs ` can be used to decide if one wants successfully
completed jobs from being deleted from the `BackgroundJobs` table.

Keeping job run history around is useful for reporting purposes, such s
hoe many jobs run over time, how many fails, how many successes, etc.

However, the `deleteSuccessfulJobs` was not being correctly passed to
the worker in `createWorker` so the worker always used the default value
-- true -- and always deleted the job run record regardless of
configuration.

This PR fixes this issue by setting the config value when creating the
worker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix This PR is a fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants