Skip to content

feat(k8s): add job that can spawn one off queryservice-updater#701

Merged
m90 merged 3 commits into
fr/rebuild-qs-cmdfrom
fr/qs-updater-job
Dec 12, 2023
Merged

feat(k8s): add job that can spawn one off queryservice-updater#701
m90 merged 3 commits into
fr/rebuild-qs-cmdfrom
fr/qs-updater-job

Conversation

@m90

@m90 m90 commented Dec 4, 2023

Copy link
Copy Markdown
Contributor

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

Connects wbstack/queryservice-updater#143

Note that this PR does only provide the Job class but does not yet create such jobs. This shall happen in a dedicated PR (#704) which introduces a command for creating jobs for all entities in all wikis.

@m90
m90 force-pushed the fr/qs-updater-job branch 2 times, most recently from 8b93045 to 403442b Compare December 4, 2023 12:49
@m90

m90 commented Dec 4, 2023

Copy link
Copy Markdown
Contributor Author

After manually creating the qs-jobs namespace, I was able to use this successfully in my local setup using tinker:

>>> dispatch(new SpawnQueryserviceUpdaterJob('longtext.wbaas.localhost', 'Q1,Q2', 'http://queryservice.default.svc.cluster.local:9999/bigdata/namespace/qsns_06620d449d/sparql'))                            
[!] Aliasing 'SpawnQueryserviceUpdaterJob' to 'App\Jobs\SpawnQueryserviceUpdaterJob' for this Tinker session.                                                                                               
=> Illuminate\Foundation\Bus\PendingDispatch {#4559}  

Which created a job and a pod. The job finished as intended, logging:

#logback.classic pattern: %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
14:03:10.301 [main] INFO  o.w.query.rdf.tool.WbStackUpdate - Starting Updater 0.3.84 (3bcfddc0f526c9a227773e68fe29419343d33993) --wikibaseHost longtext.wbaas.localhost --ids Q1,Q2 --entityNamespaces 120,122,146 --sparqlUrl http://queryservice.default.svc.cluster.local:9999/bigdata/namespace/qsns_06620d449d/sparql --wikibaseScheme http --conceptUri https://lontext.wbaas.localhost
14:03:10.665 [main] INFO  o.w.q.r.t.change.ChangeSourceContext - Checking where we left off
14:03:10.665 [main] INFO  o.w.query.rdf.tool.rdf.RdfRepository - Checking for left off time from the updater
14:03:11.195 [main] INFO  o.w.query.rdf.tool.rdf.RdfRepository - Checking for left off time from the dump
14:03:11.354 [main] INFO  o.w.q.r.t.change.ChangeSourceContext - Defaulting start time to 30 days ago: 2023-11-04T14:03:11.354Z
14:03:11.420 [main] INFO  org.wikidata.query.rdf.tool.Updater - Polled up to 1 at (0.0, 0.0, 0.0) updates per second and (0.0, 0.0, 0.0) ids per second
Successfully ran update command.

]
]);

$job = $kubernetesClient->jobs()->apply($jobSpec);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Should this be create instead (making it fail when the job already exists). Not sure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probably depends on if we think jobs should be unique per wiki or not (e.g. in the event one fails and we try again)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can decide this when implementing the command. Right now I would think it doesn't matter, but then I don't know which retry mechanisms we come up with lateron.

{
$this->wikiDomain = $wikiDomain;
$this->jobsKubernetesNamespace = env('API_JOB_NAMESPACE', 'api-jobs');
$this->jobsKubernetesNamespace = Config::get('wbstack.api_job_namespace');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a drive by fix for a mistake made earlier on this year. It will works as before, but we probably want to update the chart at some point as well to use WBSTACK_ env vars throughout.

@deer-wmde deer-wmde left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works nicely - I encountered some error last week when trying it out but I guess that was some unlucky constellation of my local cluster, today it worked just fine.

One thing I noticed that maybe we can improve (but rather related to wbstack/queryservice-updater#143 I think) is that the Updater seems to go through 100 loops even if not necessary just had an old QS Updater image

@m90
m90 changed the base branch from main to fr/rebuild-qs-cmd December 12, 2023 10:24
@m90
m90 merged commit c8d32c0 into fr/rebuild-qs-cmd Dec 12, 2023
@m90
m90 deleted the fr/qs-updater-job branch December 12, 2023 10:29
m90 added a commit that referenced this pull request Dec 12, 2023
* feat(k8s): add job that can spawn one off queryservice-updater

* fix: consider entity payload for job uniqueness

* refactor: read env vars through config
m90 added a commit that referenced this pull request Dec 13, 2023
* feat(qs): scaffold command for rebuilding queryservice data

* feat: add stub methods

* feat: fetch entity ids from mediawiki api

* chore: log received args in dummy job for testing

* refactor: use max page size

* fix: use proper command name

* fix: directly query namespaces table

* fix: do not fail on null lexemes setting

* test: add test setup for qs rebuild command

* test: add test for full command run

* refactor: make sparql url configurable

* test: explicitly set config values in test

* refactor: source command config from cli args with defaults

* test: add test case for command failure

* test: empty wikis shall not dispatch jobs

* feat: allow passing multiple domains

* fix: explicitly request json responses from api

* feat(k8s): add job that can spawn one off queryservice-updater (#701)

* feat(k8s): add job that can spawn one off queryservice-updater

* fix: consider entity payload for job uniqueness

* refactor: read env vars through config

* chore: dispatch proper job

* fix: kubernetes labels cannot contain commas

* docs: add changelog

* chore: pass exception to extra logging args

* chore: add logging to command

* fix: entity payload in labels exceeds allowed length
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