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 1985 - Add cron service to run scheduled jobs #702

Merged
merged 10 commits into from
Feb 21, 2025
Merged

Conversation

indiejames
Copy link
Contributor

Jira Issue ID

HARMONY-1985

Description

Adds a cron service that can run scheduled jobs and move work-reaper functionality to it.

Local Test Steps

For harmony in a box:

  1. Build the image locally
    npm run build in the services/cron-service directory
  2. Add the following lines to your .env file to make the work-reaper run every minute and to have it reap any work-items and workflow-steps that are more than 1 minute old, so you will be able to see things happening faster:
REAPABLE_WORK_AGE_MINUTES=1
WORK_REAPER_CRON="*/1 * * * *"
  1. Run harmony in a box
  2. Use k9s or kubectl to verify that the cron-service microservice is running, then tail the log on the pod
  3. Execute a harmony query
  4. Watch the cron-service log. Every minute you should see the work-reaper run. By the second run or so you should see it deleting the work-items and workflow-steps for your job.
  5. (Optional) use dBViz to verify the the reaper deleted the work-items and workflow-steps

For sandbox:

  1. Check out the HARMONY-1985 branch of harmony-ci-cd
  2. Add the following lines to your .env file in harmony-ci-cd
tf_reapable_work_age_minutes=1
tf_work_reaper_cron="*/1 * * * *"
  1. Run ./bin/deploy in the harmony-ci-cd directory
  2. Run steps 4-6 from above

PR Acceptance Checklist

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

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 tested it out successfully running in developer mode (not harmony in a box).

envsubst < $file | kubectl apply -f - -n harmony

# create the work failer
file="services/work-failer/config/service-template.yaml"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the work-failer 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.

it was a mistake - fixed

import { CronJob } from './cronjob';

/**
* Find work items that are older than notUpdatedForMinutes and delete them.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: indentation looks off for the JSDocs for this and the next function.

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

exit 1
fi
envsubst < $file | kubectl apply -f - -n harmony
fi
Copy link
Member

Choose a reason for hiding this comment

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

This line should be removed otherwise you get syntax error because the fi won't match on line 68.

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


# create the work failer
# create the work failer
Copy link
Member

Choose a reason for hiding this comment

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

nit: fix the indentation.

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.

Tested successfully with harmony in a box.

@indiejames indiejames merged commit 8a4db5a into main Feb 21, 2025
5 checks passed
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.

3 participants