Issue Details (XML | Word | Printable)

Key: HUDSON-5222
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Blocker Blocker
Assignee: abayer
Reporter: dhauslad
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Hudson

Wrong Computer used for SCM polling

Created: 09/Jan/10 07:05 AM   Updated: 12/Jan/10 09:01 AM   Resolved: 11/Jan/10 02:44 PM
Component/s: clearcase
Affects Version/s: current
Fix Version/s: current

File Attachments: 1. Text File 5222-part2.patch (0.8 kB)
2. Text File HUDSON-5222.patch (0.6 kB)

Environment: Windows XP Pro and Server 2003.


 Description  « Hide

The clearcase plugin always uses the current computer for resolution of build variables rather than the Computer associated with the last build, even when polling on the last build's Computer. This causes polling to fail for us. We allow our jobs to roam freely in the cluster. But based on the code, even if the job was tied to a particular node and the node was not the master node, AND the view-name depends upon node-specific configuration, the polling fails.

To let our jobs roam freely in the cluster, we introduced a node-specific attribute to the view name. Our views are all named ${SHORT_COMPUTERNAME}_${JOB_NAME}. SHORT_COMPUTERNAME is a parameter uniquely defined on each Node. This is so that clearcase doesn't complain when there are 2 views for the job in the cluster.

hudson: 1.339
clearcase: 1.1



Sort Order: Ascending order - Click to sort in descending order
abayer added a comment - 09/Jan/10 10:31 AM

I think HUDSON-5214 should actually address this - before 1.1, we were using a deprecated method for determining the Computer to use for build variable resolution. That deprecated method generally returned the Computer used for the previous build (the method is deprecated because it's not 100% reliable). In 1.1, we switched to using a method that returned the current Computer consistently, but that method, as it turned out, didn't work properly in polling, only during a build. So now we're using a different approach in polling than we are in the build itself - we're using a more reliable way of getting the Computer the previous build ran on in the polling, while still using the current Computer in the build proper. I think this approach should solve your problem - polling, so far as I can tell, runs on the Computer the last build of the project ran on, so we should be getting the right information.

Also, while your per-Node parameter should work, you could just use NODE_NAME - that's specific to the ClearCase plugin's build variable resolver, but it gets you what you want.


dhauslad added a comment - 09/Jan/10 12:20 PM

I'll give 5214 a try. We wanted to use NODE_NAME. However, our convention is to use the computername for the NODE_NAME, and for some of our nodes, the names are fairly long. In an effort to chop some characters off the view paths, we defined SHORT_COMPUTERNAME which is the last 8 characters of the computername. Thanks for the tip nonetheless. Did you happen to look at the patch I proposed to HUDSON-2934 by any chance? It's currently assigned to hudson core (which may be appropriate), but it can be coerced into a working state by a change to AbstractClearCaseSCM.


dhauslad added a comment - 09/Jan/10 01:26 PM

Well, testing with the 5214 continued to fail with the same error. Frankly, I'm not much surprised, since the 5214 fix was pretty much the same as one I tested this morning (arrived at by studying SCMTrigger). The only difference was the name of the method for getting the latest build and you made a better effort in the test class.


dhauslad added a comment - 09/Jan/10 01:47 PM

Do you have any ideas what might be causing our builds to continue failing?


dhauslad added a comment - 11/Jan/10 09:32 AM

I tried changing pollChanges to also pass the constructed BuildVariableResolver to generateNormalizedViewName a few lines later, and it continues to misbehave. I was very optimistic when I noticed that when generateNormalizedViewName is provided a build, it uses getCurrentComputer to supply the Computer for env resolution.


abayer added a comment - 11/Jan/10 10:03 AM

Hmm - try this patch. I think the problem may have been as simple as that the BuildVariableResolver wasn't actually looking at the Computer's environment variables.


abayer added a comment - 11/Jan/10 10:14 AM

Yeah, that worked for me - committing that fix.


scm_issue_link added a comment - 11/Jan/10 10:16 AM

Code changed in hudson
User: : abayer
Path:
trunk/hudson/plugins/clearcase/src/main/java/hudson/plugins/clearcase/util/BuildVariableResolver.java
trunk/hudson/plugins/clearcase/src/test/java/hudson/plugins/clearcase/AbstractClearCaseScmTest.java
http://fisheye4.cenqua.com/changelog/hudson/?cs=25684
Log:
[FIXED HUDSON-5222] Added support for Computer environment variables in view name macros.


dhauslad added a comment - 11/Jan/10 01:49 PM

I stripped out my patch for 2934, restored the plugin to trunk, rebuilt, and continue to face the same problem.

We have about 25 jobs defined, all using clearcase. We use Hudson 1.339. Most jobs are set to poll "@hourly". There are 5 nodes in the cluster. Is there too much contention at the same time (they all seem to poll right around the hour)?

The View Name for all of our jobs is "${SHORT_COMPUTERNAME}_${JOB_NAME}".

I also changed line preceding the hasChanges call to "String normalizedViewName = generateNormalizedViewName((BuildVariableResolver) variableResolver);" and it continues to fail.

When I debug, the generateNormalizedViewName seems to be at fault; the normalizedViewName is set to the wrong value for the lastBuild's Computer. When I debugged into the BuildVariableResolver, it seems that the problem is that the environment returned for the last build has the wrong value for the variable. If the Computer and build are switched in order, perhaps it will succeed. Our "SHORT_COMPUTERNAME" variable seems ill advised right now.


abayer added a comment - 11/Jan/10 02:00 PM

I have no problem flipping the Computer/Build order around. Have you tried it locally with that?


dhauslad added a comment - 11/Jan/10 02:28 PM

Just wrapped up testing it and it works like with the order switched. Are you sure you don't have any issues switching the order?


abayer added a comment - 11/Jan/10 02:43 PM

Yeah, that's fine by me - if it turns out to introduce other problems, well, we'll deal with that when we get to it. =)


scm_issue_link added a comment - 11/Jan/10 02:44 PM

Code changed in hudson
User: : abayer
Path:
trunk/hudson/plugins/clearcase/src/main/java/hudson/plugins/clearcase/util/BuildVariableResolver.java
http://fisheye4.cenqua.com/changelog/hudson/?cs=25687
Log:
[FIXED HUDSON-5222] Flipping build/computer order for environment variable resolution


dhauslad added a comment - 11/Jan/10 05:22 PM

I'll watch it more closely for a day or two, but it looks like it's working like a champ. Thanks for your support on this. Can you take a look at the patch I proposed for HUDSON-2934? If you put that in the trunk, I can get back to an uncustomized plugin.


patrikschalin added a comment - 12/Jan/10 06:59 AM

Is there a way to get hold of a build with this fix, we are currently suffering from this...


dhauslad added a comment - 12/Jan/10 07:09 AM

If your organization doesn't use either Maven 2 and Subversion, install them.

Read these.

http://wiki.hudson-ci.org/display/HUDSON/Plugin+tutorial
http://wiki.hudson-ci.org/display/HUDSON/Hints+for+plugin-development+newbies

Do a Subversion update to get the latest to your machine. The url for the clearcase plugin is:

https://svn.dev.java.net/svn/hudson/trunk/hudson/plugins/clearcase

From the folder you create to house the plugin, do "mvn clean package" or "mvn package". I like to clean before every build because it updates the build timestamp that you see in the installed plugins tab in Hudson.

The build creates a target folder inside the root one. It has the clearcase.hpi. You can either manually copy that to your plugins directory and restart Hudson or use the Hudson UI's pluginManager/advanced page to install it from the machine you build it on.

Enjoy!


abayer added a comment - 12/Jan/10 07:39 AM

Also, FYI, I'll be pushing a release of 1.1.1 (http://wiki.hudson-ci.org/display/HUDSON/ClearCase+Plugin#ClearCasePlugin-Version1.1.1) by the end of the week. I just want to make sure I catch as many of the easy-to-fix 1.0->1.1 bugs as possible.


dhauslad added a comment - 12/Jan/10 08:53 AM

I look forward to the 1.1.1 release! I really appreciate your responsiveness on this stuff. Sorry about hounding you about 2934 (I'm a newbie to JIRA and SVN) and didn't get the notification (or notice) your comment on it.

As a quick sanity check, I diffed our versions of the key files and found only one diff that I think will cause me a problem. On version 25724 of AbstractClearCaseSCM, you have generateNormalizedViewName(lastBuild) whereas I have generateNormalizedViewName(variableResolver). I think this will make a difference because the signature you're using defaults to the current computer when constructing a BuildVariableResolver. I need it to be the computer from the last build.


abayer added a comment - 12/Jan/10 09:01 AM

You're right - I just blanked on that. It's in now.