Commit Graph

10 Commits

Author SHA1 Message Date
Antoine Musso 0c47b4292d Retire the project on OpenDev
It has been migrated to the Jenkins community:
https://github.com/jenkinsci/gearman-plugin/

Depends-On: Ib6010d7ce85a934501c50a53e9ac78dcf74bc403
Change-Id: I0c84db2ad3fbb4d9f0eff793a0159c6ed3a8e25c
2021-05-27 17:23:43 +02:00
Jan Hruban 46d74f029f Fix permission problem when finding builds
Plugin runs as user "anonymous". Escalate priviledges so it can find
projects/builds also in the case that "anonymous" user does not have
read permissions for them.

Change-Id: Iccf19460bb02a450d4a82fdabaf9dbc37a3ffe97
2016-03-21 09:44:28 +01:00
Khai Do a5164d65a4 Update to Jenkins LTS 1.625.3 and fix function registration
Using a newer Jenkins LTS (ver 1.625.3) did not work with the
gearman-plugin. Gearman function registeration wasn't working
correct because Computer.currentComputer()[1] and getInstance()[2]
methods seemed to always return null on initialization of the
plugin. The Jenkins.getActiveInstance method (introduced in
Jenkins-1.589)[3] works more reliably.

[1] http://javadoc.jenkins-ci.org/hudson/model/Node.html#getNodeName()
[2] http://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html#getActiveInstance()
[3] e6c2e16f7a

Change-Id: I1534beda9c39a9d15da4d7b96f17e7b75699a631
2016-01-24 06:14:52 -08:00
James E. Blair c97253eff5 Rework starting/stopping executors
There was at least one error, likely a race condition, with the
previous code which could cause more than one ExecutorWorkerThread for
a node to be spawned.  In particular, I think the bogus comparison in
ComputerListenerImpl may have a large part in that (it checked to see
if a _Computer_ object was in a list of _Thread_ objects).

To improve reliability around adding and removing nodes, all related
functionality is moved to the GearmanProxy class.  Any methods (most
of them) that have to do with starting or stopping worker threads are
synchronized on the GearmanProxy monitor (the important parts of most
threads were already synchronized on the worker list before, so this
should not be much of a performance change).

The methods that start management and executor threads now do their
own checking to verify that such threads do not already exist, making
it so that calling them is more idempotent.  Existing checks external
to the class have been removed (these were likely somewhat racy).

To avoid keeping redundant data structures, the node availability list
is removed, and instead if we need to find an availability object, we
walk the list of worker threads and compare to their nodes.  Because
we do this so much, the list of worker and management threads are
changed to use those explicit classes instead of
AbstractWorkerThreads.

The accessor methods for the internal lists of worker threads is
removed to ensure that they are only managed through GearmanProxy.
This changed some unit tests and required the removal of one complete
test (which was not doing much more than verifying the addition
operator).

Also, when stopping ExecutorWorkerThreads, stop all of the ones
associated with a node.

When a computer goes offline, Computer.getNode() returns null, so we
can't know which workers should be deleted.  Instead of using Nodes as
keys for our workers, use Computers instead and change everything to
use Computer (most functions needed Computer rather than Node anyway),
and in the few remaining places where a Node is needed, convert the
other direction.

Change-Id: Ia5084579317f972400069cc3e84db4e0b6560a80
2013-08-13 11:31:50 -07:00
James E. Blair 7a8d940c4b Update zuul-gearman protocol.
* Use name+number as the build identifier for all meta-jobs.
  (Zuul has name + number as build metadata, so avoid adding new/duplicate
  features).
* Refer to the name of the manager worker as 'manager' instead of 'master'
  to avoid jenkins specifics.
* Just call the url "url" instead of "full_url".
* Change SetDescriptionWorker to use name+number as the build id.
  Also, expect 'html_description' instead of 'description'.
* Don't catch as many exceptions, instead, let them propogate so that they
  get turned into WORK_EXCEPTION packets with information (instead of
  WORK_FAIL packets which have no info).
* Change StopJobWorker to use the same name+number interface as
  setDescriptionWorker (for consistency, expandability, plus it makes
  the code simpler).

Change-Id: I8e078540c252bf9c1f14b79f8182517cbaa13555
2013-06-06 15:40:01 -07:00
zaro0508 9c9acdbdba fix executor names, clean up, remove code duplication
src/main/java/hudson/plugins/gearman/AbstractWorkerThread.java
    Removed Id field, it was initially added because I thought it was the plugin's
    responsibility to cancel jobs that are on the gearman queue.  We've decided that
    it will be the client (zuul or otherwise) responsibility to cancel jobs from the gearman
    queue.  The gearman plugin will cancel jobs that have already been put on the
    jenkins queue.

src/main/java/hudson/plugins/gearman/ComputerListenerImpl.java
src/main/java/hudson/plugins/gearman/ExecutorWorkerThread.java
src/main/java/hudson/plugins/gearman/GearmanPluginConfig.java
src/main/java/hudson/plugins/gearman/GearmanProxy.java
src/main/java/hudson/plugins/gearman/ManagementWorkerThread.java
src/main/java/hudson/plugins/gearman/StartJobWorker.java
    Refactor to reduce code duplication. Consolidated creation of management worker and
    executor workers.  Added a fix so that executors spawned on master node
    is named 'master-manager' for the manager and 'master-exec-#' for executors

src/test/java/hudson/plugins/gearman/ManagementWorkerThreadTest.java
    Added test to make sure worker name is set correctly

src/main/java/hudson/plugins/gearman/GearmanPluginUtil.java
src/test/java/hudson/plugins/gearman/GearmanPluginUtilTest.java
    Useful utils for the gearman plugin with tests

Change-Id: I96e097dc0dbf5cd78e5e82af584976085aee61b3
2013-03-22 15:47:19 -07:00
zaro0508 2b175701d2 add new unit tests for plugin
This commit adds a few unit tests for the gearman-plugin.
A few things were refactored from creating the tests.
1. move methods from GearmanPluginUtil to GearmanPluginConfig
2. removed a few unused methods.

Change-Id: I8ccd0000ff528867c66958294192818f35d83383
2013-03-20 21:11:27 -07:00
zaro0508 c461e204f2 misc doc and logging updates
Checkin to change README from txt to rst format.
Jenkins seems to hijack logging so i've removed all of the
logging specific bindings that were added previously.
I also added "----" to begining of this plugin's logging
messages so i could easily keep track of them.

Change-Id: Ibd8c56af5b9ad18152bcb0d3ff0c41168a6d2fd1
2013-03-12 10:51:24 -07:00
zaro 8ee129e6be make thread safe
This checkin attempts to make gearman plugin objects thread safe.

src/main/java/hudson/plugins/gearman/SaveableListenerImpl.java
   Decided that this was not needed.

src/main/java/hudson/plugins/gearman/GearmanPluginConfig.java
   Added method to allow other objects to access gearman server
   launchWorker, host, and port settings

src/main/java/hudson/plugins/gearman/GearmanPluginUtil.java
   Useful utilities for this plugin

src/main/java/hudson/plugins/gearman/AbstractWorkerThread.java
src/main/java/hudson/plugins/gearman/ComputerListenerImpl.java
src/main/java/hudson/plugins/gearman/ProjectListener.java
src/main/java/hudson/plugins/gearman/GearmanProxy.java
   Made object private and added syncronized setters and getters

Change-Id: I04ca6a275ba8184bd18cf8954d07b94d02b2a47d
2013-03-05 09:51:10 -08:00
zaro 0e81e014da decouple gearman from the gearman configuration
This change is to create a new object to store Gearman
objects and state info.

src/main/java/hudson/plugins/gearman/GearmanProxy.java
  created to keep Gearman state info.

src/main/java/hudson/plugins/gearman/GearmanPluginConfig.java
  simplied this class by removing the core gearman stuff out to
  a GearmanProxy.java class

src/main/java/hudson/plugins/gearman/Constants.java
  Use one logger instead of two.  updated logger reference in all
  of the other files in this checkin

src/main/java/hudson/plugins/gearman/ProjectListener.java
src/main/java/hudson/plugins/gearman/StartJobWorker.java
src/main/java/hudson/plugins/gearman/StopJobWorker.java
src/main/java/hudson/plugins/gearman/ComputerListenerImpl.java
  update references to changed class and methods

Change-Id: I879cdb8839c8b5437bccf6d7e1602c33eff434a6
2013-03-05 09:51:10 -08:00