Skip to content

tools: Add example LAVA pull lab script - #1561

Open
nuclearcat wants to merge 1 commit into
kernelci:mainfrom
nuclearcat:lava-pull-lab-example
Open

tools: Add example LAVA pull lab script#1561
nuclearcat wants to merge 1 commit into
kernelci:mainfrom
nuclearcat:lava-pull-lab-example

Conversation

@nuclearcat

Copy link
Copy Markdown
Member

Labs running LAVA behind a firewall cannot use the push-style LAVA integration as the pipeline has no URL to reach them. When a lava runtime is configured without a url (e.g. lava-testpull), the pipeline stores the rendered LAVA job definition in external storage and publishes its URL as the job_definition node artifact instead.

Add tools/example_pull_lab_lava.py which polls the events API for such jobs, filtered by a mandatory lab name and optional platforms and device types, and submits the definitions verbatim to a local LAVA instance via its REST API. Results are reported by LAVA itself through the notify callback embedded in the definition, so the lab only needs outbound connectivity.

Also document the LAVA pull lab flow in doc/connecting-pull-lab.md.

Assisted-By: Claude Fable 5 noreply@anthropic.com

Comment thread tools/example_pull_lab_lava.py
Comment thread tools/example_pull_lab_lava.py Outdated
Comment on lines +202 to +203
def poll_loop(args):
global timestamp

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.

What happens if a user runs the script once, quits out and later runs the script again?

pollevents() uses this timestamp as a "from" marker when looking for new jobs.

Do we want to initialise timestamp here to be the time that the script is run? Or store the "latest" used timestamp to a file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will redesign it with persistence, for timestamp

Comment thread tools/example_pull_lab_lava.py Outdated
f"Processing job {node_id} (name: {node.get('name')}, "
f"platform: {platform}, runtime: {runtime})"
)
processed.add(node_id)

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.

I guess processed will just keep getting larger and larger forever? (until the script is quit and re-run)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, i will adjust it and add expiration and persistence for the processed nodes.

Comment thread tools/example_pull_lab_lava.py Outdated
def poll_loop(args):
global timestamp

processed = set()

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.

Should we be saving the "processed" jobs to a file for subsequent script runs to build upon?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, will update it

@patersonc

Copy link
Copy Markdown
Contributor

FYI I've created #1562 to use to test this PR with

Labs running LAVA behind a firewall cannot use the push-style LAVA
integration as the pipeline has no URL to reach them. When a lava
runtime is configured without a url (e.g. lava-testpull), the pipeline
stores the rendered LAVA job definition in external storage and
publishes its URL as the job_definition node artifact instead.

Add tools/example_pull_lab_lava.py which polls the events API for such
jobs, filtered by a mandatory lab name and optional platforms and
device types, and submits the definitions verbatim to a local LAVA
instance via its REST API. Results are reported by LAVA itself through
the notify callback embedded in the definition, so the lab only needs
outbound connectivity.

Submitted jobs and the polling position are persisted in an
append-only JSONL journal that tolerates interrupted writes and is
compacted automatically, so restarting the script does not resubmit
jobs or replay old events.

Also document the LAVA pull lab flow in doc/connecting-pull-lab.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nuclearcat
nuclearcat force-pushed the lava-pull-lab-example branch from 31cbb9c to ac622f9 Compare July 22, 2026 16:41
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.

2 participants