Plugin Development: expansion of Lockable Resources Plugin?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugin Development: expansion of Lockable Resources Plugin?

Kevin Werner
Hi,

The current Lockable Resources Plugin has reservation for external resources and the ability to lock (and wait for availability to lock) them during a build pipeline.  This is very helpful functionality that I'm already using minimally in our test pipelines.  For the plugin to really be useful for me though, I need some additional functionality:

1.  The ability to reserve, unreserve and query the current reservations and available resources through a REST API rather than the GUI; I have a couple external tools that I would like to integrate with.  I need to especially be able to query the resources that are currently reserved to a jenkins user.  The main utility is that we have CI, manual and automated (outside CI) test runs and I want to integrate the reservation system for all, if possible.  For instance, before a manual run starts, I want to make sure that the resources are actually reserved by the developer. 
2.  I would like to possibly add some additional data to the lockable resources as well.  This is a longer-term goal as I could abuse the description field in the short-term and use it for my own purposes.  I'm hoping to be able to add JSON metadata about the resource that is useful for the external tools to know (ex. PDU information so I can power it on/off during a pipeline). 
3.  I would also like to add an optional reservation "tag" when reserving that can help create sub-groups of reservations (ex.  Joe reserves two separate resources, but he wants to use each for two different test runs that are running simultaneously so the external test tool needs to query not only what he has reserved but choose the correct resource for each test run)

Is there any functionality like this that exists already that I don't know about?  I hate reinventing the wheel.

If not, I'm not currently a Jenkins plugin dev, but I have a Java/Groovy background and I'm happy to jump in and start contributing.  I'm assuming I can modify and add to the current Lockable Resources Plugin?  I'm happy to coordinate with other devs with this work.

For now, I'm going to start poking around getting a dev environment setup for myself and start playing around with making my own plugin.

Any feedback or help is welcome.  Thanks in advance!

kddubb

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/f9772acf-5e27-4e56-94bb-bf3f94304e1d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development: expansion of Lockable Resources Plugin?

Jesse Glick-4
On Fri, May 18, 2018 at 12:15 PM, Kevin Werner <[hidden email]> wrote:
> Is there any functionality like this that exists already that I don't know
> about?

Look through

https://github.com/jenkinsci/lockable-resources-plugin/pulls

Probably best to discuss any major plans with @abayer & @amuniz, who
seem to have been active recently merging PRs. As a rule, PRs are most
likely to get traction if they are reasonably small (reviewers have
very limited time to grasp what you are doing), solving a single
specific problem, with thorough test coverage, and no compatibility
impact.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr086Q5JSnhtA7GNCgOADCneBen76%3D%2BwYuQ7OQnwVwXBNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development: expansion of Lockable Resources Plugin?

Kevin Werner
Awesome I'll take a look through those.

On Friday, May 18, 2018 at 10:55:37 AM UTC-6, Jesse Glick wrote:
On Fri, May 18, 2018 at 12:15 PM, Kevin Werner <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="D5ODnQ3LCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">kdd...@...> wrote:
> Is there any functionality like this that exists already that I don't know
> about?

Look through

<a href="https://github.com/jenkinsci/lockable-resources-plugin/pulls" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Flockable-resources-plugin%2Fpulls\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGURJiL8oz_XcfFLiK5NW1ZBtSFmQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Flockable-resources-plugin%2Fpulls\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGURJiL8oz_XcfFLiK5NW1ZBtSFmQ&#39;;return true;">https://github.com/jenkinsci/lockable-resources-plugin/pulls

Probably best to discuss any major plans with @abayer & @amuniz, who
seem to have been active recently merging PRs. As a rule, PRs are most
likely to get traction if they are reasonably small (reviewers have
very limited time to grasp what you are doing), solving a single
specific problem, with thorough test coverage, and no compatibility
impact.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/b6008180-e6e9-48b6-a61b-117f8880cf92%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development: expansion of Lockable Resources Plugin?

Steven Foster
There's definitely an open PR for the 2nd feature which I am patiently waiting for

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/cf6f4ad8-b806-4412-88f6-721a0b5e8c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development: expansion of Lockable Resources Plugin?

Kevin Werner
In reply to this post by Kevin Werner
btw, I haven't had to use the Remote Access API much, but it seems like #1 on my list should be implemented by adding a .../api to the /lockable-resources/ URL?

https://wiki.jenkins.io/display/JENKINS/Remote+access+API

Any suggestions on good plugin examples to use?  I'm sure I can figure it out for myself, but since I'm newer to this I'm sure having a pointer in the right direction from those that know would be helpful!

Thanks in advance,

kddubb

On Friday, May 18, 2018 at 10:22:21 AM UTC-6, Kevin Werner wrote:
Hi,

The current Lockable Resources Plugin has reservation for external resources and the ability to lock (and wait for availability to lock) them during a build pipeline.  This is very helpful functionality that I'm already using minimally in our test pipelines.  For the plugin to really be useful for me though, I need some additional functionality:

1.  The ability to reserve, unreserve and query the current reservations and available resources through a REST API rather than the GUI; I have a couple external tools that I would like to integrate with.  I need to especially be able to query the resources that are currently reserved to a jenkins user.  The main utility is that we have CI, manual and automated (outside CI) test runs and I want to integrate the reservation system for all, if possible.  For instance, before a manual run starts, I want to make sure that the resources are actually reserved by the developer. 
2.  I would like to possibly add some additional data to the lockable resources as well.  This is a longer-term goal as I could abuse the description field in the short-term and use it for my own purposes.  I'm hoping to be able to add JSON metadata about the resource that is useful for the external tools to know (ex. PDU information so I can power it on/off during a pipeline). 
3.  I would also like to add an optional reservation "tag" when reserving that can help create sub-groups of reservations (ex.  Joe reserves two separate resources, but he wants to use each for two different test runs that are running simultaneously so the external test tool needs to query not only what he has reserved but choose the correct resource for each test run)

Is there any functionality like this that exists already that I don't know about?  I hate reinventing the wheel.

If not, I'm not currently a Jenkins plugin dev, but I have a Java/Groovy background and I'm happy to jump in and start contributing.  I'm assuming I can modify and add to the current Lockable Resources Plugin?  I'm happy to coordinate with other devs with this work.

For now, I'm going to start poking around getting a dev environment setup for myself and start playing around with making my own plugin.

Any feedback or help is welcome.  Thanks in advance!

kddubb

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/8a2deb7c-cb4b-45cf-909a-6153a8a611b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development: expansion of Lockable Resources Plugin?

Jesse Glick-4
On Fri, May 18, 2018 at 5:11 PM, Kevin Werner <[hidden email]> wrote:
> it seems like #1
> on my list should be implemented by adding a .../api to the
> /lockable-resources/ URL?

Perhaps for “querying current reservations”, but Stapler export API
(`hudson.model.Api`, what you linked to) is read-only. For general
operations you need to implement Stapler web methods in various
patterns.

> Any suggestions on good plugin examples to use?

Some plugins implement RESTish APIs, some implement CLI commands, some
implement both, and the quality is quite variable I am afraid. Jenkins
core implements plenty of RESTish APIs; sometimes they are documented
in `_api.jelly` files, but usually they are not. You can find APIs
very roughly by searching for usages of `StaplerRequest`,
`StaplerResponse`, `HttpResponse`, and a few other things.

http://stapler.kohsuke.org/reference.html

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1MpjX4LoAySTYaOEt6q0F7KbQ0n1cgVA%2BFCE8EVa6ErA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development: expansion of Lockable Resources Plugin?

Kevin Werner
Thanks Jesse, that should get me started.  I appreciate the pointers.  :)

kddubb

On Friday, May 18, 2018 at 3:39:39 PM UTC-6, Jesse Glick wrote:
On Fri, May 18, 2018 at 5:11 PM, Kevin Werner <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="qAORWY3aCQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">kdd...@...> wrote:
> it seems like #1
> on my list should be implemented by adding a .../api to the
> /lockable-resources/ URL?

Perhaps for “querying current reservations”, but Stapler export API
(`hudson.model.Api`, what you linked to) is read-only. For general
operations you need to implement Stapler web methods in various
patterns.

> Any suggestions on good plugin examples to use?

Some plugins implement RESTish APIs, some implement CLI commands, some
implement both, and the quality is quite variable I am afraid. Jenkins
core implements plenty of RESTish APIs; sometimes they are documented
in `_api.jelly` files, but usually they are not. You can find APIs
very roughly by searching for usages of `StaplerRequest`,
`StaplerResponse`, `HttpResponse`, and a few other things.

<a href="http://stapler.kohsuke.org/reference.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstapler.kohsuke.org%2Freference.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHgQGvGL0WJafZiTrUWy4t70NAi1A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstapler.kohsuke.org%2Freference.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHgQGvGL0WJafZiTrUWy4t70NAi1A&#39;;return true;">http://stapler.kohsuke.org/reference.html

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fc2d26a6-977b-47f6-ab04-cf1f78d116ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development: expansion of Lockable Resources Plugin?

Antonio Muñiz
Hey! All the features you are proposing make sense to me.
The one about "additional data on resources" would be covered by https://github.com/jenkinsci/lockable-resources-plugin/pull/20 maybe... unfortunately that's a big one that I did not have time to review yet.

Feel free to file JIRA issues for the others and even work on them and contribute if you feel comfortable with it.


On 18 May 2018 at 23:42, Kevin Werner <[hidden email]> wrote:
Thanks Jesse, that should get me started.  I appreciate the pointers.  :)

kddubb

On Friday, May 18, 2018 at 3:39:39 PM UTC-6, Jesse Glick wrote:
On Fri, May 18, 2018 at 5:11 PM, Kevin Werner <[hidden email]> wrote:
> it seems like #1
> on my list should be implemented by adding a .../api to the
> /lockable-resources/ URL?

Perhaps for “querying current reservations”, but Stapler export API
(`hudson.model.Api`, what you linked to) is read-only. For general
operations you need to implement Stapler web methods in various
patterns.

> Any suggestions on good plugin examples to use?

Some plugins implement RESTish APIs, some implement CLI commands, some
implement both, and the quality is quite variable I am afraid. Jenkins
core implements plenty of RESTish APIs; sometimes they are documented
in `_api.jelly` files, but usually they are not. You can find APIs
very roughly by searching for usages of `StaplerRequest`,
`StaplerResponse`, `HttpResponse`, and a few other things.

http://stapler.kohsuke.org/reference.html

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fc2d26a6-977b-47f6-ab04-cf1f78d116ba%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CAJc7kzSLb%2B442XkNPVZ%2BoHkfFtTkZw2GKSqJ95dO0UbNUsg3ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin Development: expansion of Lockable Resources Plugin?

Kevin Werner
Awesome, thanks!  For now, I'm learning and getting things working.  I was able to pretty simply turn on the read-only API and add the resources which was very helpful in the short-term.  I will submit pull requests back when I get things in a state that can be submitted.  I'm trying to keep the various functionality on separate branches at first so you can approve and accept things individually.

kddubb

On Tuesday, May 22, 2018 at 2:49:40 AM UTC-6, Antonio Muñiz wrote:
Hey! All the features you are proposing make sense to me.
The one about "additional data on resources" would be covered by <a href="https://github.com/jenkinsci/lockable-resources-plugin/pull/20" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Flockable-resources-plugin%2Fpull%2F20\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelXhw08frhuMrcSbpEuWeH9sOxw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fjenkinsci%2Flockable-resources-plugin%2Fpull%2F20\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelXhw08frhuMrcSbpEuWeH9sOxw&#39;;return true;">https://github.com/jenkinsci/lockable-resources-plugin/pull/20 maybe... unfortunately that's a big one that I did not have time to review yet.

Feel free to file JIRA issues for the others and even work on them and contribute if you feel comfortable with it.


On 18 May 2018 at 23:42, Kevin Werner <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="jHi66t1DCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">kdd...@...> wrote:
Thanks Jesse, that should get me started.  I appreciate the pointers.  :)

kddubb

On Friday, May 18, 2018 at 3:39:39 PM UTC-6, Jesse Glick wrote:
On Fri, May 18, 2018 at 5:11 PM, Kevin Werner <[hidden email]> wrote:
> it seems like #1
> on my list should be implemented by adding a .../api to the
> /lockable-resources/ URL?

Perhaps for “querying current reservations”, but Stapler export API
(`hudson.model.Api`, what you linked to) is read-only. For general
operations you need to implement Stapler web methods in various
patterns.

> Any suggestions on good plugin examples to use?

Some plugins implement RESTish APIs, some implement CLI commands, some
implement both, and the quality is quite variable I am afraid. Jenkins
core implements plenty of RESTish APIs; sometimes they are documented
in `_api.jelly` files, but usually they are not. You can find APIs
very roughly by searching for usages of `StaplerRequest`,
`StaplerResponse`, `HttpResponse`, and a few other things.

<a href="http://stapler.kohsuke.org/reference.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstapler.kohsuke.org%2Freference.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHgQGvGL0WJafZiTrUWy4t70NAi1A&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fstapler.kohsuke.org%2Freference.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHgQGvGL0WJafZiTrUWy4t70NAi1A&#39;;return true;">http://stapler.kohsuke.org/reference.html

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jHi66t1DCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-dev/fc2d26a6-977b-47f6-ab04-cf1f78d116ba%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/fc2d26a6-977b-47f6-ab04-cf1f78d116ba%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-dev/fc2d26a6-977b-47f6-ab04-cf1f78d116ba%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-dev/fc2d26a6-977b-47f6-ab04-cf1f78d116ba%40googlegroups.com.

For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/4d422b30-06b4-46d8-bb20-50f531aec3f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.