Skip to content

Conversation

@m90
Copy link
Contributor

@m90 m90 commented May 11, 2023

Follows up on #601 which my fat fingers accidentally deleted.


Ticket https://phabricator.wikimedia.org/T330389

Requires wbstack/charts#114, wmde/wbaas-deploy#885

@m90 m90 changed the title Fr/mw job queue When wikis have pending jobs, create a Kubernetes job to work through the items May 11, 2023
@m90 m90 force-pushed the fr/mw-job-queue branch from c1378e9 to c98cfda Compare May 11, 2023 11:39
@m90 m90 requested a review from tarrow May 11, 2023 11:43
@m90 m90 force-pushed the fr/mw-job-queue branch 3 times, most recently from 5b892a9 to b0bc4d9 Compare May 11, 2023 12:18
// Schedule site stat updates for each wiki and platform-summary
$schedule->command('schedule:stats')->daily();

$schedule->job(new PollForMediaWikiJobsJob)->everyMinute();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we wanted to have this run at a higher frequency, we'd have two options:

I would guess the former is a bit cleaner.


private function enqueueWiki (string $wikiDomain): void
{
dispatch(new ProcessMediaWikiJobsJob($wikiDomain));
Copy link
Contributor Author

@m90 m90 May 11, 2023

Choose a reason for hiding this comment

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

Do we want/need this to fan out to another job (as is) or should we rather merge the two jobs into one?

@m90 m90 force-pushed the fr/mw-job-queue branch 9 times, most recently from 413019a to de4fe26 Compare May 15, 2023 08:12
@m90 m90 marked this pull request as ready for review May 15, 2023 08:18
@m90 m90 force-pushed the fr/mw-job-queue branch 3 times, most recently from 111f98c to a534670 Compare May 15, 2023 09:12
@m90 m90 force-pushed the fr/mw-job-queue branch from a534670 to 2a5ffd4 Compare May 15, 2023 09:40
@m90 m90 force-pushed the fr/mw-job-queue branch 6 times, most recently from 487b0a8 to df08fb6 Compare May 16, 2023 17:19
@m90 m90 force-pushed the fr/mw-job-queue branch from 73989dc to 5cc6dd3 Compare May 17, 2023 09:15
@m90 m90 force-pushed the fr/mw-job-queue branch from d85f194 to 38caebe Compare May 17, 2023 18:18
]
]);

$job = $kubernetesClient->jobs()->apply($jobSpec);
Copy link
Contributor Author

@m90 m90 May 17, 2023

Choose a reason for hiding this comment

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

Turns out that when using apply instead of create and using a unique .metadata.name per wiki, we can have Kubernetes deduplicate jobs for us and we don't have to check anything at all. Only downside is that we have to use a .spec.ttlSecondsAfterFinished of 0. Still think being able to keep this job free from any logic at all is worth it.

@m90 m90 force-pushed the fr/mw-job-queue branch 2 times, most recently from 2ca82ad to b9939e1 Compare May 31, 2023 18:22
@m90 m90 force-pushed the fr/mw-job-queue branch from b9939e1 to 0e10644 Compare May 31, 2023 18:34
Copy link
Contributor

@deer-wmde deer-wmde left a comment

Choose a reason for hiding this comment

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

Can confirm this worked locally for me! details: https://phabricator.wikimedia.org/T330389#8895083

@m90 m90 merged commit 4341436 into main Jun 1, 2023
@m90 m90 deleted the fr/mw-job-queue branch June 1, 2023 11:44
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