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

subscribe/listen interface documentation #537

Closed
mwasilew opened this issue Jun 4, 2024 · 9 comments
Closed

subscribe/listen interface documentation #537

mwasilew opened this issue Jun 4, 2024 · 9 comments

Comments

@mwasilew
Copy link

mwasilew commented Jun 4, 2024

The docs (https://kernelci.org/docs/api/#publisher--subscriber-interface) say that Any client code can subscribe to receive events with an API token. I tried calling subscribe interface, but I didn't manage to receive any events. Could you please provide an example on how to use the interface? I would like to schedule tests to our internal devices. These tests are usually hardware specific and require special setup which I believe doesn't belong to kernelci-core. So the events I'm interested in are build completed for selected kernel trees.

@nuclearcat
Copy link
Member

Hi! I built simple example, but i did shortcut and didn't used cloudevents to parse events properly, still it should work:
https://gist.github.com/nuclearcat/aec542be9b2f0cb7a7ee3b164d664877
Can you try it please?
The only issue you might need to wait for a while for a kbuild event, or ping me in IRC, i can trigger manual staging builds

@JenySadadia
Copy link
Collaborator

Hello,

Could you please provide me which is your preferred way of receiving events? I assume you want to listen to events outside of pipeline environment.

@JenySadadia
Copy link
Collaborator

You may also want to take a look at a service polling for build events: kernelci/kernelci-pipeline#594

@mwasilew
Copy link
Author

mwasilew commented Jun 4, 2024

@JenySadadia I saw the docs, but they're a bit confusing. For example, what is the channel I should subscribe to? The docs say "channel":"abc", but I assume this is just an example. Is there a list of available channels?

I'm not sure whether I will try to reuse the kernelci-pipeline or write something else. The main idea is to receive events from the API and not depend on the pipeline instance you're running.

@nuclearcat I'll try it. Thank you!

@JenySadadia
Copy link
Collaborator

@JenySadadia I saw the docs, but they're a bit confusing. For example, what is the channel I should subscribe to? The docs say "channel":"abc", but I assume this is just an example. Is there a list of available channels?

Atm API is publishing events on 2 channels i.e. node and user_group. You may not be interested in user group channel as it's for user management-related events.
You should be listening to node channel to receive all node creation and update events.

I'm not sure whether I will try to reuse the kernelci-pipeline or write something else. The main idea is to receive events from the API and not depend on the pipeline instance you're running.

Then I'd recommend using API endpoints directly or kci event CLI tool for this. The latter would be more convenient if you've already setup kci tool from the guide https://kernelci.org/docs/api/early-access/#setting-up-the-kci-tool.

@JenySadadia
Copy link
Collaborator

If you want to create a new channel for instance test and send/receive data on that one, here is the kci commands:

Subscribe to `test` channel:
$ ./kci event subscribe test
28629

Poll for events:
$ ./kci event receive 28629 

Run the below command on a different terminal to send JSON data on `test` channel:
$ ./kci event send node-data.json test

$ ./kci event receive 28629
{"id":"66552254324bb8ea21413698","kind":"test","name":"emerg","path":["checkout","kbuild-gcc-10-x86","baseline-x86-intel","dmesg","emerg"],"group":"baseline-x86-intel","parent":"66552254324bb8ea21413697","state":"done","result":"pass","artifacts":null,"data":{"error_code":null,"error_msg":null,"test_source":null,"test_revision":null,"platform":"dell-latitude-5300-8145U-arcada","device":null,"runtime":"lava-collabora","job_id":null,"job_context":null,"regression":null,"kernel_revision":{"tree":"stable-rc","url":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git","branch":"linux-6.1.y","commit":"094034c9e476724e93cf4db9afc5feb7a6e9bcd8","describe":"v6.1.92-275-g094034c9e4767","version":{"version":6,"patchlevel":1,"sublevel":92,"extra":"-275-g094034c9e4767","name":null},"patchset":null},"arch":"x86_64","defconfig":"x86_64_defconfig","config_full":"x86_64_defconfig+x86-board","compiler":"gcc-10","kernel_type":"bzimage"},"debug":null,"jobfilter":null,"created":"2024-05-28T00:16:20.800000","updated":"2024-05-28T00:16:20.800000","timeout":"2024-05-28T06:16:20.800000","holdoff":null,"owner":"staging.kernelci.org","submitter":"9790c38bd29c1375fc96ed92b9b4bfab","user_groups":[]}

I hope this helps.

@mwasilew
Copy link
Author

mwasilew commented Jun 4, 2024

@JenySadadia thank you, much appreciated!

@JenySadadia
Copy link
Collaborator

Should I close this issue @mwasilew ?

@mwasilew
Copy link
Author

Sorry, I forgot to comment. Please close. I think I got all the details I needed.

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

No branches or pull requests

3 participants