| 814 |
mhunt |
1 |
package com.erggroup.buildtool.daemon;
|
|
|
2 |
|
|
|
3 |
import com.erggroup.buildtool.daemon.BuildThread;
|
|
|
4 |
import com.erggroup.buildtool.ripple.MutableString;
|
|
|
5 |
import com.erggroup.buildtool.ripple.Package;
|
| 4285 |
dpurdie |
6 |
import com.erggroup.buildtool.ripple.ReleaseConfig;
|
| 814 |
mhunt |
7 |
import com.erggroup.buildtool.ripple.ReleaseManager;
|
|
|
8 |
import com.erggroup.buildtool.ripple.RippleEngine;
|
| 4285 |
dpurdie |
9 |
import com.erggroup.buildtool.ripple.RunLevelData;
|
| 4280 |
dpurdie |
10 |
import com.erggroup.buildtool.smtp.Smtpsend;
|
| 814 |
mhunt |
11 |
|
|
|
12 |
import java.io.BufferedReader;
|
| 834 |
mhunt |
13 |
import java.io.DataInputStream;
|
| 814 |
mhunt |
14 |
import java.io.File;
|
| 834 |
mhunt |
15 |
import java.io.FileInputStream;
|
|
|
16 |
import java.io.InputStreamReader;
|
| 814 |
mhunt |
17 |
import java.sql.SQLException;
|
| 4285 |
dpurdie |
18 |
import java.util.Iterator;
|
| 2541 |
dpurdie |
19 |
import java.lang.System;
|
| 814 |
mhunt |
20 |
|
|
|
21 |
import org.apache.log4j.Logger;
|
|
|
22 |
|
|
|
23 |
/**Master Thread sub component
|
|
|
24 |
*/
|
|
|
25 |
public class MasterThread
|
|
|
26 |
extends BuildThread
|
|
|
27 |
{
|
|
|
28 |
|
|
|
29 |
/**Logger
|
|
|
30 |
* @attribute
|
|
|
31 |
*/
|
|
|
32 |
private static final Logger mLogger = Logger.getLogger(MasterThread.class);
|
|
|
33 |
|
| 2541 |
dpurdie |
34 |
/**Nagios Monitoring
|
|
|
35 |
* @attribute
|
|
|
36 |
*/
|
|
|
37 |
protected long mPhaseStartTime = 0;
|
|
|
38 |
|
| 864 |
mhunt |
39 |
/**constructor
|
| 814 |
mhunt |
40 |
*/
|
| 896 |
mhunt |
41 |
public MasterThread(int rtag_id, int rcon_id, String unitTest)
|
| 814 |
mhunt |
42 |
{
|
| 818 |
mhunt |
43 |
mLogger.warn("MasterThread rtag_id " + rtag_id + " rcon_id " + rcon_id);
|
| 814 |
mhunt |
44 |
mRtagId = rtag_id;
|
|
|
45 |
mRconId = rcon_id;
|
| 896 |
mhunt |
46 |
if ( unitTest == null )
|
|
|
47 |
{
|
|
|
48 |
unitTest = new String();
|
|
|
49 |
}
|
|
|
50 |
mUnitTest = unitTest;
|
| 814 |
mhunt |
51 |
}
|
|
|
52 |
|
|
|
53 |
/**implements the sequence diagrams coordinate slave threads, generate build files, allowed to proceed, check environment
|
|
|
54 |
*/
|
|
|
55 |
public void run()
|
|
|
56 |
{
|
|
|
57 |
Integer id = new Integer(mRtagId);
|
|
|
58 |
setName(id.toString());
|
| 4285 |
dpurdie |
59 |
mLogger.warn("Master Thread run");
|
| 814 |
mhunt |
60 |
boolean exit = false;
|
|
|
61 |
RippleEngine rippleEngine = new RippleEngine(mReleaseManager, mRtagId, true);
|
|
|
62 |
MutableString addendum = new MutableString();
|
|
|
63 |
|
|
|
64 |
while(!exit)
|
|
|
65 |
{
|
|
|
66 |
try
|
|
|
67 |
{
|
| 2541 |
dpurdie |
68 |
mPhaseStartTime = 0;
|
| 916 |
mhunt |
69 |
mLogger.fatal("run calling sleepCheck");
|
| 886 |
mhunt |
70 |
sleepCheck();
|
| 916 |
mhunt |
71 |
mLogger.fatal("run calling rippleEngine.collectMetaData");
|
| 2541 |
dpurdie |
72 |
mPhaseStartTime = System.currentTimeMillis();
|
| 868 |
mhunt |
73 |
rippleEngine.collectMetaData();
|
| 2541 |
dpurdie |
74 |
mPhaseStartTime = 0;
|
| 868 |
mhunt |
75 |
|
| 814 |
mhunt |
76 |
if ( Thread.currentThread().isInterrupted() )
|
|
|
77 |
{
|
|
|
78 |
mLogger.warn("run is interrupted");
|
|
|
79 |
// unit test technique
|
|
|
80 |
throw new ExitException();
|
|
|
81 |
}
|
|
|
82 |
|
| 896 |
mhunt |
83 |
if ( mUnitTest.compareTo("unit test spawn thread") == 0)
|
| 814 |
mhunt |
84 |
{
|
|
|
85 |
throw new Exception();
|
|
|
86 |
}
|
|
|
87 |
|
|
|
88 |
MutableString buildFileContent = new MutableString();
|
|
|
89 |
|
| 896 |
mhunt |
90 |
if ( mUnitTest.compareTo("unit test check environment") != 0)
|
| 814 |
mhunt |
91 |
{
|
| 896 |
mhunt |
92 |
if ( mUnitTest.compareTo("unit test generate build files") != 0)
|
| 814 |
mhunt |
93 |
{
|
| 896 |
mhunt |
94 |
if ((mUnitTest.compareTo("unit test allowed to proceed") != 0) &&
|
|
|
95 |
(mUnitTest.compareTo("unit test not allowed to proceed") != 0) &&
|
|
|
96 |
(mUnitTest.compareTo("unit test exit") != 0))
|
| 814 |
mhunt |
97 |
{
|
| 4280 |
dpurdie |
98 |
//---------------------------------------------------------------
|
|
|
99 |
// Wait for all Slaves to enter waiting or paused state
|
|
|
100 |
// They may be building
|
|
|
101 |
// They may be starting up
|
|
|
102 |
//
|
| 886 |
mhunt |
103 |
mLogger.warn("run coordinate slave threads");
|
|
|
104 |
|
|
|
105 |
mRunLevel = RunLevel.WAITING;
|
|
|
106 |
mLogger.warn("run changing run level to WAITING for rcon_id " + mRconId);
|
| 916 |
mhunt |
107 |
mLogger.fatal("run calling mRunLevel.persistNew to set WAITING");
|
| 890 |
mhunt |
108 |
mRunLevel.persistNew(mReleaseManager, mRconId);
|
| 886 |
mhunt |
109 |
|
|
|
110 |
boolean allSlaveThreadsWaiting = false;
|
|
|
111 |
boolean logWarning = true;
|
|
|
112 |
boolean logWarning2 = true;
|
|
|
113 |
|
|
|
114 |
while ( !allSlaveThreadsWaiting )
|
| 882 |
mhunt |
115 |
{
|
| 916 |
mhunt |
116 |
mLogger.fatal("run calling mReleaseManager.queryRunLevel");
|
| 886 |
mhunt |
117 |
mReleaseManager.queryRunLevel(mRtagId);
|
|
|
118 |
|
| 4285 |
dpurdie |
119 |
// Process all run entries
|
| 886 |
mhunt |
120 |
allSlaveThreadsWaiting = true;
|
| 4285 |
dpurdie |
121 |
for (Iterator<RunLevelData> it = mReleaseManager.mRunLevelCollection.iterator(); it.hasNext(); )
|
| 814 |
mhunt |
122 |
{
|
| 4285 |
dpurdie |
123 |
RunLevelData rl = it.next();
|
|
|
124 |
int runLevel = rl.get_current_run_level();
|
|
|
125 |
|
|
|
126 |
// DEVI 53065 Slave indication that they are done with a package includes
|
| 892 |
mhunt |
127 |
// having a paused run level
|
| 4285 |
dpurdie |
128 |
if ((runLevel != ReleaseManager.DB_WAITING) &&
|
|
|
129 |
(runLevel != ReleaseManager.DB_PAUSED))
|
| 816 |
mhunt |
130 |
{
|
| 886 |
mhunt |
131 |
if ( logWarning )
|
|
|
132 |
{
|
| 4285 |
dpurdie |
133 |
mLogger.warn("run waiting for rcon id " + rl.get_rcon_id());
|
| 886 |
mhunt |
134 |
logWarning = false;
|
|
|
135 |
}
|
|
|
136 |
else
|
|
|
137 |
{
|
| 4285 |
dpurdie |
138 |
mLogger.info("run waiting for rcon id " + rl.get_rcon_id());
|
| 886 |
mhunt |
139 |
}
|
|
|
140 |
allSlaveThreadsWaiting = false;
|
| 4285 |
dpurdie |
141 |
break;
|
| 816 |
mhunt |
142 |
}
|
| 4285 |
dpurdie |
143 |
|
| 814 |
mhunt |
144 |
}
|
| 4285 |
dpurdie |
145 |
|
|
|
146 |
|
| 886 |
mhunt |
147 |
if ( !allSlaveThreadsWaiting )
|
| 814 |
mhunt |
148 |
{
|
| 886 |
mhunt |
149 |
// to do, sleep for periodicMs
|
| 896 |
mhunt |
150 |
if ( mUnitTest.compareTo("unit test coordinate slave threads") == 0 )
|
| 820 |
mhunt |
151 |
{
|
| 886 |
mhunt |
152 |
Thread.currentThread().interrupt();
|
| 820 |
mhunt |
153 |
}
|
|
|
154 |
else
|
|
|
155 |
{
|
| 886 |
mhunt |
156 |
if ( logWarning2 )
|
|
|
157 |
{
|
|
|
158 |
mLogger.warn("run sleeping 3 secs waiting for slave threads");
|
|
|
159 |
logWarning2 = false;
|
|
|
160 |
}
|
|
|
161 |
else
|
|
|
162 |
{
|
|
|
163 |
mLogger.info("run sleeping 3 secs waiting for slave threads");
|
|
|
164 |
}
|
| 916 |
mhunt |
165 |
mLogger.fatal("run calling Thread.sleep for 3 secs");
|
| 886 |
mhunt |
166 |
Thread.sleep(3000);
|
|
|
167 |
mLogger.info("run sleep returned");
|
| 820 |
mhunt |
168 |
}
|
| 814 |
mhunt |
169 |
}
|
|
|
170 |
}
|
| 886 |
mhunt |
171 |
|
| 896 |
mhunt |
172 |
if ( mUnitTest.compareTo("unit test coordinate slave threads") == 0 )
|
| 814 |
mhunt |
173 |
{
|
| 886 |
mhunt |
174 |
throw new ExitException();
|
|
|
175 |
}
|
|
|
176 |
|
| 4280 |
dpurdie |
177 |
//---------------------------------------------------------------
|
|
|
178 |
// Publish Package Build Results
|
|
|
179 |
// Indicate to RM that we are publishing
|
|
|
180 |
// Ensure that all build machines have placed placed marker in dpkg_archive
|
|
|
181 |
// Save updated build files into VCS
|
|
|
182 |
//
|
| 886 |
mhunt |
183 |
mRunLevel = RunLevel.PUBLISHING;
|
|
|
184 |
mLogger.warn("run changing run level to PUBLISHING for rcon_id " + mRconId);
|
| 916 |
mhunt |
185 |
mLogger.fatal("run calling mRunLevel.persist to set PUBLISHING");
|
| 886 |
mhunt |
186 |
mRunLevel.persist(mReleaseManager, mRconId);
|
|
|
187 |
|
| 916 |
mhunt |
188 |
mLogger.fatal("run calling deliverChange on AbtPublish");
|
| 4280 |
dpurdie |
189 |
deliverChange(null, "AbtPublish", true);
|
|
|
190 |
|
|
|
191 |
// preserve, as they are reset by deliverChange
|
| 886 |
mhunt |
192 |
String reportingFullyPublished = mReportingFullyPublished;
|
| 924 |
dpurdie |
193 |
String reportingNewVcsTag = mReportingNewVcsTag;
|
| 4280 |
dpurdie |
194 |
|
|
|
195 |
//---------------------------------------------------------------
|
|
|
196 |
// TearDown the build workspace
|
|
|
197 |
// Remove the build workspace
|
|
|
198 |
// Save build log files
|
|
|
199 |
//
|
| 916 |
mhunt |
200 |
mLogger.fatal("run calling deliverChange on AbtTearDown");
|
| 4280 |
dpurdie |
201 |
deliverChange(null, "AbtTearDown", true);
|
| 886 |
mhunt |
202 |
|
|
|
203 |
// DEVI 47395 delete the build file now
|
|
|
204 |
// this will prevent any chance of multiply publishing a package version
|
|
|
205 |
File buildFile = new File(mRtagId + "build.xml");
|
|
|
206 |
|
|
|
207 |
if ( buildFile.exists() )
|
|
|
208 |
{
|
|
|
209 |
buildFile.delete();
|
|
|
210 |
}
|
|
|
211 |
|
|
|
212 |
if ( mReportingPackageName != null )
|
|
|
213 |
{
|
|
|
214 |
// a dummy build file did not apply
|
|
|
215 |
// Publishing is done outside ant by design
|
|
|
216 |
// The preference is to do all release manager work outside ant
|
|
|
217 |
|
|
|
218 |
boolean buildErrorOccurred = true;
|
| 2541 |
dpurdie |
219 |
boolean publishError = false;
|
|
|
220 |
|
| 898 |
mhunt |
221 |
// max 50 characters
|
|
|
222 |
String rootCause = "Error publishing to Release Manager";
|
| 886 |
mhunt |
223 |
try
|
| 814 |
mhunt |
224 |
{
|
| 908 |
mhunt |
225 |
if ( mReportingTestBuild.compareTo("0") != 0 )
|
|
|
226 |
{
|
|
|
227 |
mLogger.info("run completing test build on " + mReportingPackageName + mReportingPackageExtension);
|
|
|
228 |
// build failure emails will have been sent
|
|
|
229 |
// just left to notify the user of the test build completion
|
|
|
230 |
Package p = rippleEngine.findPackage(mReportingPackageName + mReportingPackageExtension);
|
|
|
231 |
|
|
|
232 |
if (p != ReleaseManager.NULL_PACKAGE)
|
|
|
233 |
{
|
|
|
234 |
boolean success = false;
|
|
|
235 |
|
|
|
236 |
if ( reportingFullyPublished != null && reportingFullyPublished.compareTo("yes") == 0 )
|
|
|
237 |
{
|
|
|
238 |
success = true;
|
|
|
239 |
}
|
|
|
240 |
|
| 916 |
mhunt |
241 |
mLogger.fatal("run calling p.completeTestBuild");
|
| 908 |
mhunt |
242 |
p.completeTestBuild(rippleEngine.mMailServer, rippleEngine.mMailSender, mReleaseManager, rippleEngine.mBaselineName, success);
|
|
|
243 |
}
|
|
|
244 |
|
|
|
245 |
// ... and clean up the mess in the archive
|
|
|
246 |
throw new Exception();
|
|
|
247 |
}
|
|
|
248 |
|
| 886 |
mhunt |
249 |
if ( reportingFullyPublished != null && reportingFullyPublished.compareTo("yes") == 0 )
|
| 814 |
mhunt |
250 |
{
|
| 886 |
mhunt |
251 |
buildErrorOccurred = false;
|
| 868 |
mhunt |
252 |
|
| 924 |
dpurdie |
253 |
if ( reportingNewVcsTag.length() > 0 )
|
| 852 |
mhunt |
254 |
{
|
| 886 |
mhunt |
255 |
Integer rtagId = new Integer(mRtagId);
|
|
|
256 |
|
|
|
257 |
if ( mGbeGatherMetricsOnly == null )
|
| 868 |
mhunt |
258 |
{
|
| 906 |
mhunt |
259 |
// publish to release manager
|
| 2541 |
dpurdie |
260 |
// On error mAutoMakeReleaseCause will contain error string
|
|
|
261 |
mLogger.fatal("run calling mReleaseManager.autoMakeRelease");
|
|
|
262 |
publishError = mReleaseManager.autoMakeRelease(
|
|
|
263 |
rtagId.toString(),
|
|
|
264 |
mReportingPackageName,
|
|
|
265 |
mReportingPackageExtension,
|
|
|
266 |
mReportingPackageVersion,
|
|
|
267 |
reportingNewVcsTag,
|
|
|
268 |
mReportingPackageDepends,
|
|
|
269 |
mReportingIsRipple);
|
|
|
270 |
|
|
|
271 |
// publishErrors only affect one package
|
|
|
272 |
if ( publishError )
|
|
|
273 |
{
|
|
|
274 |
rootCause = mReleaseManager.mAutoMakeReleaseCause;
|
|
|
275 |
mLogger.fatal("autoMakeRelease publishError: " + rootCause);
|
|
|
276 |
throw new Exception();
|
|
|
277 |
}
|
| 868 |
mhunt |
278 |
}
|
| 2541 |
dpurdie |
279 |
|
| 886 |
mhunt |
280 |
FileInputStream abtmetrics = new FileInputStream( rtagId.toString() + "abtmetrics.txt" );
|
|
|
281 |
DataInputStream din = new DataInputStream( abtmetrics );
|
|
|
282 |
InputStreamReader isr = new InputStreamReader( din );
|
|
|
283 |
BufferedReader br = new BufferedReader( isr );
|
|
|
284 |
String metrics = br.readLine();
|
|
|
285 |
mLogger.warn( "execute read metrics string " + metrics );
|
|
|
286 |
br.close();
|
|
|
287 |
isr.close();
|
|
|
288 |
din.close();
|
|
|
289 |
|
| 916 |
mhunt |
290 |
mLogger.fatal("run calling mReleaseManager.insertPackageMetrics");
|
| 886 |
mhunt |
291 |
mReleaseManager.insertPackageMetrics(rtagId.toString(), mReportingPackageName, mReportingPackageExtension, metrics );
|
| 4280 |
dpurdie |
292 |
|
|
|
293 |
//
|
|
|
294 |
// Info reportinging
|
|
|
295 |
// Send an email to track build system usage - may be noise
|
|
|
296 |
//
|
|
|
297 |
mLogger.fatal("run calling emailBuildComplete");
|
|
|
298 |
emailBuildComplete(rippleEngine, reportingNewVcsTag);
|
|
|
299 |
|
|
|
300 |
// All done
|
|
|
301 |
// The package has been built and released
|
| 852 |
mhunt |
302 |
}
|
| 886 |
mhunt |
303 |
else
|
|
|
304 |
{
|
| 924 |
dpurdie |
305 |
mLogger.info("run package not labelled in Version Control on " + mReportingPackageName + mReportingPackageVersion);
|
| 898 |
mhunt |
306 |
// max 50 characters
|
| 924 |
dpurdie |
307 |
rootCause = "Error publishing to Version Control System";
|
| 886 |
mhunt |
308 |
throw new Exception();
|
|
|
309 |
}
|
| 814 |
mhunt |
310 |
}
|
|
|
311 |
else
|
|
|
312 |
{
|
| 886 |
mhunt |
313 |
mLogger.info("run build error occurred on " + mReportingPackageName + mReportingPackageVersion);
|
| 814 |
mhunt |
314 |
throw new Exception();
|
|
|
315 |
}
|
| 886 |
mhunt |
316 |
|
| 814 |
mhunt |
317 |
}
|
| 886 |
mhunt |
318 |
catch( Exception e)
|
| 814 |
mhunt |
319 |
{
|
| 898 |
mhunt |
320 |
// a build error occurred or
|
| 924 |
dpurdie |
321 |
// an error occurred publishing to Version Control or Release Manager
|
| 886 |
mhunt |
322 |
// take out the archive entry first
|
|
|
323 |
String fs = System.getProperty( "file.separator" );
|
|
|
324 |
String dpkgArchiveEntry = new String(Package.mGbeDpkg + fs + mReportingPackageName + fs + mReportingPackageVersion);
|
|
|
325 |
File dpkgArchiveEntryFile = new File(dpkgArchiveEntry);
|
|
|
326 |
mLogger.info("run checking existence of " + dpkgArchiveEntry);
|
|
|
327 |
|
|
|
328 |
if ( dpkgArchiveEntryFile.exists() )
|
| 814 |
mhunt |
329 |
{
|
| 886 |
mhunt |
330 |
if ( dpkgArchiveEntryFile.isDirectory() )
|
|
|
331 |
{
|
|
|
332 |
mLogger.warn("run deleting " + dpkgArchiveEntryFile.getName());
|
| 916 |
mhunt |
333 |
mLogger.fatal("run calling deleteDirectory on " + dpkgArchiveEntryFile);
|
| 886 |
mhunt |
334 |
deleteDirectory(dpkgArchiveEntryFile);
|
|
|
335 |
}
|
| 814 |
mhunt |
336 |
}
|
| 924 |
dpurdie |
337 |
|
| 886 |
mhunt |
338 |
Integer rtagId = new Integer(mRtagId);
|
|
|
339 |
|
| 4280 |
dpurdie |
340 |
if ( ! buildErrorOccurred )
|
| 886 |
mhunt |
341 |
{
|
| 924 |
dpurdie |
342 |
mLogger.fatal("an error occurred publishing to Version Control or Release Manager");
|
| 908 |
mhunt |
343 |
// force exclusion by default
|
|
|
344 |
int testBuildInstruction = 0;
|
|
|
345 |
try
|
|
|
346 |
{
|
|
|
347 |
testBuildInstruction = Integer.parseInt( mReportingTestBuild );
|
|
|
348 |
}
|
|
|
349 |
catch( NumberFormatException nfe )
|
|
|
350 |
{
|
|
|
351 |
}
|
| 916 |
mhunt |
352 |
mLogger.fatal("run calling excludeFromBuild");
|
| 908 |
mhunt |
353 |
mReleaseManager.excludeFromBuild(mReportingPackageVersionId, null, rtagId.toString(), null, rootCause, null, false, testBuildInstruction);
|
| 2541 |
dpurdie |
354 |
|
|
|
355 |
if ( ! publishError )
|
|
|
356 |
{
|
|
|
357 |
throw new Exception("an error occurred publishing to Version Control or Release Manager");
|
|
|
358 |
}
|
| 886 |
mhunt |
359 |
}
|
| 898 |
mhunt |
360 |
|
| 902 |
mhunt |
361 |
// DEVI 55364
|
|
|
362 |
// Package has not been built on all configured platforms
|
|
|
363 |
// Under normal circumstances, this root cause will be masked by a previously reported error
|
|
|
364 |
// Under abnormal circumstances amidst build activity such as:
|
|
|
365 |
// - slave build machine reboots
|
|
|
366 |
// - slave build machines with a read only file system
|
|
|
367 |
// this root cause is required to keep the end user informed
|
|
|
368 |
// max 50 chars
|
|
|
369 |
String cause = "Buildtool env error occurred. Attempt build again";
|
| 908 |
mhunt |
370 |
// force exclusion by default
|
|
|
371 |
int testBuildInstruction = 0;
|
|
|
372 |
try
|
|
|
373 |
{
|
|
|
374 |
testBuildInstruction = Integer.parseInt( mReportingTestBuild );
|
|
|
375 |
}
|
|
|
376 |
catch( NumberFormatException nfe )
|
|
|
377 |
{
|
|
|
378 |
}
|
| 916 |
mhunt |
379 |
mLogger.fatal("run calling excludeFromBuild");
|
| 908 |
mhunt |
380 |
mReleaseManager.excludeFromBuild(mReportingPackageVersionId, mReportingPackageVersion, rtagId.toString(), null, mReportingBuildFailureLogFile == null ? cause : null, mReportingBuildFailureLogFile, false, testBuildInstruction);
|
| 814 |
mhunt |
381 |
}
|
|
|
382 |
}
|
| 886 |
mhunt |
383 |
|
| 896 |
mhunt |
384 |
if ( mUnitTest.compareTo("unit test coordinate slave threads") == 0 )
|
| 886 |
mhunt |
385 |
{
|
|
|
386 |
throw new ExitException();
|
|
|
387 |
}
|
|
|
388 |
mLogger.info("run coordinate slave threads returned");
|
| 814 |
mhunt |
389 |
}
|
|
|
390 |
|
| 4280 |
dpurdie |
391 |
|
|
|
392 |
//---------------------------------------------------------------
|
|
|
393 |
// Start of a new build cycle
|
|
|
394 |
// Determine if the daemon has been paused.
|
|
|
395 |
//
|
| 886 |
mhunt |
396 |
mLogger.warn("run checking allowedToProceed");
|
| 916 |
mhunt |
397 |
mLogger.fatal("run calling allowedToProceed");
|
| 886 |
mhunt |
398 |
allowedToProceed(true);
|
|
|
399 |
mLogger.info("run allowedToProceed returned");
|
|
|
400 |
|
| 896 |
mhunt |
401 |
if ( mUnitTest.compareTo("unit test allowed to proceed") == 0 )
|
| 886 |
mhunt |
402 |
{
|
|
|
403 |
throw new ExitException();
|
|
|
404 |
}
|
| 814 |
mhunt |
405 |
|
| 4280 |
dpurdie |
406 |
// Set up Release Config in mReleaseConfigCollection
|
|
|
407 |
// This will be used when creating a build file
|
|
|
408 |
mLogger.fatal("run calling queryReleaseConfig");
|
|
|
409 |
mReleaseManager.queryReleaseConfig(mRtagId);
|
|
|
410 |
|
|
|
411 |
//---------------------------------------------------------------
|
|
|
412 |
// Plan the next build
|
|
|
413 |
// Determine what is to be built
|
|
|
414 |
// Generate build files
|
| 814 |
mhunt |
415 |
mLogger.warn("run generating build files");
|
| 924 |
dpurdie |
416 |
mLogger.fatal("run calling planRelease");
|
| 4123 |
dpurdie |
417 |
mPhaseStartTime = System.currentTimeMillis();
|
| 814 |
mhunt |
418 |
rippleEngine.planRelease();
|
| 4123 |
dpurdie |
419 |
mPhaseStartTime = 0;
|
|
|
420 |
|
| 2541 |
dpurdie |
421 |
mPhaseStartTime = System.currentTimeMillis();
|
| 916 |
mhunt |
422 |
mLogger.fatal("run calling reportChange");
|
| 908 |
mhunt |
423 |
rippleEngine.reportChange();
|
| 2541 |
dpurdie |
424 |
mPhaseStartTime = 0;
|
| 924 |
dpurdie |
425 |
|
| 814 |
mhunt |
426 |
// get the build file from the ripple engine
|
|
|
427 |
rippleEngine.getFirstBuildFileContent(buildFileContent, addendum);
|
|
|
428 |
|
|
|
429 |
if ( addendum.value.compareTo("non generic") == 0 )
|
|
|
430 |
{
|
|
|
431 |
// publish the build file
|
|
|
432 |
mLogger.warn("run publishing build file");
|
| 916 |
mhunt |
433 |
mLogger.fatal("run calling publishBuildFile");
|
| 814 |
mhunt |
434 |
mReleaseManager.publishBuildFile(mRtagId, buildFileContent.value);
|
|
|
435 |
}
|
|
|
436 |
else
|
|
|
437 |
{
|
|
|
438 |
// publish a dummy build file for either generic or dummy cases
|
|
|
439 |
// this results in the slave not running ant
|
|
|
440 |
mLogger.warn("run publishing dummy build file");
|
| 916 |
mhunt |
441 |
mLogger.fatal("run calling publishBuildFile on dummy");
|
| 814 |
mhunt |
442 |
mReleaseManager.publishBuildFile(mRtagId, mDummyBuildFileContent);
|
|
|
443 |
}
|
|
|
444 |
}
|
| 4280 |
dpurdie |
445 |
else
|
|
|
446 |
{
|
|
|
447 |
// UTF: Set up Release Config in mReleaseConfigCollection
|
|
|
448 |
mLogger.fatal("run calling queryReleaseConfig for UTF");
|
|
|
449 |
mReleaseManager.queryReleaseConfig(mRtagId);
|
|
|
450 |
}
|
| 814 |
mhunt |
451 |
mLogger.info("run generated build files");
|
| 924 |
dpurdie |
452 |
// Start of a build cycle. Set new log file to capture entire build log
|
|
|
453 |
flagStartBuildCycle();
|
|
|
454 |
|
| 4280 |
dpurdie |
455 |
//---------------------------------------------------------------
|
|
|
456 |
// SetUp BuildSpace
|
|
|
457 |
// Extract source from version control
|
|
|
458 |
//
|
| 868 |
mhunt |
459 |
if ( mGbeGatherMetricsOnly != null )
|
|
|
460 |
{
|
|
|
461 |
// set view up early for metrics gathering to ensure build file is fully written before letting the slave loose
|
| 916 |
mhunt |
462 |
mLogger.fatal("run calling setViewUp");
|
| 868 |
mhunt |
463 |
setViewUp(buildFileContent.value, true);
|
|
|
464 |
}
|
|
|
465 |
|
| 4280 |
dpurdie |
466 |
//---------------------------------------------------------------
|
|
|
467 |
// Notify all slaves that there is work to be done
|
|
|
468 |
// Change the run level for all threads in associated with the baseline
|
|
|
469 |
//
|
| 814 |
mhunt |
470 |
mLogger.warn("run change the run level for all threads in associated with the baseline");
|
| 4285 |
dpurdie |
471 |
|
| 814 |
mhunt |
472 |
mRunLevel = RunLevel.ACTIVE;
|
| 4285 |
dpurdie |
473 |
for (Iterator<ReleaseConfig> it = mReleaseManager.mReleaseConfigCollection.iterator(); it.hasNext(); )
|
|
|
474 |
{
|
|
|
475 |
ReleaseConfig rc = it.next();
|
| 814 |
mhunt |
476 |
|
| 4285 |
dpurdie |
477 |
mLogger.warn("run changing run level to ACTIVE for rcon_id " + rc.get_rcon_id() );
|
|
|
478 |
mLogger.fatal("run calling mRunLevel.persist to set ACTIVE");
|
|
|
479 |
mRunLevel.persist(mReleaseManager, rc.get_rcon_id());
|
| 814 |
mhunt |
480 |
}
|
| 4285 |
dpurdie |
481 |
|
| 896 |
mhunt |
482 |
if ( mUnitTest.compareTo("unit test generate build files") == 0 )
|
| 814 |
mhunt |
483 |
{
|
|
|
484 |
throw new ExitException();
|
|
|
485 |
}
|
|
|
486 |
}
|
|
|
487 |
mLogger.info("run changed run levels");
|
|
|
488 |
|
| 4280 |
dpurdie |
489 |
//---------------------------------------------------------------
|
|
|
490 |
// Check that we are good to proceed with the build
|
|
|
491 |
// Check environment
|
|
|
492 |
// Ensure we have enough disk space
|
|
|
493 |
//
|
| 814 |
mhunt |
494 |
mLogger.warn("run checkEnvironment");
|
| 916 |
mhunt |
495 |
mLogger.fatal("run calling checkEnvironment");
|
| 814 |
mhunt |
496 |
checkEnvironment();
|
|
|
497 |
mLogger.info("run checkEnvironment returned");
|
|
|
498 |
|
| 896 |
mhunt |
499 |
if ( mUnitTest.compareTo("unit test check environment") == 0 )
|
| 814 |
mhunt |
500 |
{
|
|
|
501 |
throw new ExitException();
|
|
|
502 |
}
|
|
|
503 |
|
| 4280 |
dpurdie |
504 |
//---------------------------------------------------------------
|
|
|
505 |
// Build the package
|
|
|
506 |
// Setup the workspace
|
|
|
507 |
// Build the package - deliver change to product baseline
|
|
|
508 |
//
|
| 814 |
mhunt |
509 |
mLogger.warn("run deliverChange");
|
| 868 |
mhunt |
510 |
|
|
|
511 |
if ( mGbeGatherMetricsOnly == null )
|
|
|
512 |
{
|
| 916 |
mhunt |
513 |
mLogger.fatal("run calling setViewUp metrics only");
|
| 868 |
mhunt |
514 |
setViewUp(buildFileContent.value, true);
|
|
|
515 |
}
|
|
|
516 |
|
| 922 |
dpurdie |
517 |
mLogger.fatal("run calling deliverChange - the actual build " + mReportingPackageName + "_" + mReportingPackageVersion);
|
| 4280 |
dpurdie |
518 |
deliverChange(null, null, true);
|
| 814 |
mhunt |
519 |
mLogger.info("run deliverChange returned");
|
| 886 |
mhunt |
520 |
|
|
|
521 |
mSleep = false;
|
|
|
522 |
if ( addendum.value.compareTo("dummy") == 0 )
|
|
|
523 |
{
|
|
|
524 |
// no build requirement, so let things settle
|
|
|
525 |
mLogger.warn("run no build requirement, so let things settle");
|
|
|
526 |
mSleep = true;
|
|
|
527 |
}
|
| 814 |
mhunt |
528 |
}
|
| 4280 |
dpurdie |
529 |
//---------------------------------------------------------------
|
|
|
530 |
// Build loop exception handling (only)
|
|
|
531 |
//
|
| 814 |
mhunt |
532 |
catch( SQLException e )
|
|
|
533 |
{
|
|
|
534 |
// oracle connection issues
|
|
|
535 |
mLogger.warn("run oracle connection issues");
|
| 886 |
mhunt |
536 |
mException = true;
|
| 814 |
mhunt |
537 |
}
|
|
|
538 |
catch( ExitException e )
|
|
|
539 |
{
|
| 858 |
mhunt |
540 |
mLogger.warn("run ExitException");
|
| 814 |
mhunt |
541 |
exit = true;
|
|
|
542 |
}
|
|
|
543 |
catch( InterruptedException e )
|
|
|
544 |
{
|
|
|
545 |
mLogger.warn("run InterruptedException");
|
|
|
546 |
}
|
|
|
547 |
catch( Exception e )
|
|
|
548 |
{
|
| 930 |
dpurdie |
549 |
mLogger.error("run indefinitePause " + e.toString());
|
| 868 |
mhunt |
550 |
String cause = e.getMessage();
|
| 930 |
dpurdie |
551 |
if ( cause == null )
|
| 814 |
mhunt |
552 |
{
|
| 930 |
dpurdie |
553 |
cause = e.toString();
|
|
|
554 |
}
|
|
|
555 |
|
|
|
556 |
try
|
|
|
557 |
{
|
|
|
558 |
// notify first
|
|
|
559 |
// many reasons for indefinite pause, including database related, so do database last
|
|
|
560 |
mRecoverable = false;
|
| 896 |
mhunt |
561 |
|
| 930 |
dpurdie |
562 |
if ( cause.compareTo(Package.mRecoverable) == 0 )
|
| 868 |
mhunt |
563 |
{
|
| 930 |
dpurdie |
564 |
mRecoverable = true;
|
| 868 |
mhunt |
565 |
}
|
| 930 |
dpurdie |
566 |
|
|
|
567 |
indefinitePause(rippleEngine, cause);
|
|
|
568 |
mReleaseManager.indefinitePause();
|
|
|
569 |
// DEVI 51366 force sleep at beginning of while loop
|
|
|
570 |
mException = true;
|
| 814 |
mhunt |
571 |
}
|
| 930 |
dpurdie |
572 |
catch( Exception f )
|
|
|
573 |
{
|
|
|
574 |
mLogger.error("run indefinitePause failed");
|
|
|
575 |
}
|
| 814 |
mhunt |
576 |
}
|
|
|
577 |
}
|
|
|
578 |
}
|
|
|
579 |
|
| 4280 |
dpurdie |
580 |
|
|
|
581 |
/** Sends email notification and mark the successful completion of a build
|
|
|
582 |
* Used simply to keep an email trail of build operations
|
|
|
583 |
* Send only the the buildadm group
|
|
|
584 |
*
|
|
|
585 |
* Uses globals for data
|
|
|
586 |
*/
|
|
|
587 |
public void emailBuildComplete( RippleEngine rippleEngine, String reportingNewVcsTag )
|
|
|
588 |
{
|
|
|
589 |
mLogger.debug("emailBuildComplete");
|
|
|
590 |
|
|
|
591 |
String subject = "BUILD SUCCESS on package " + mReportingPackageName + " " + mReportingPackageVersion;
|
|
|
592 |
String mailBody="Release : " + rippleEngine.mBaselineName + "<br>" +
|
|
|
593 |
"Package : " + mReportingPackageName + "<br>" +
|
|
|
594 |
"Version : " + mReportingPackageVersion + "<br>" +
|
|
|
595 |
"PVID : " + mReportingPackageVersionId + "<br>" +
|
|
|
596 |
"VcsTag : " + reportingNewVcsTag + "<br>" +
|
|
|
597 |
"Ripple : " + mReportingIsRipple + "<br>" +
|
|
|
598 |
"Dependencies : " + mReportingPackageDepends + "<br>";
|
|
|
599 |
|
|
|
600 |
mailBody += "<p><hr>";
|
|
|
601 |
try
|
|
|
602 |
{
|
|
|
603 |
Smtpsend.send( rippleEngine.mMailServer, // mailServer
|
|
|
604 |
rippleEngine.mMailSender, // source
|
|
|
605 |
rippleEngine.mMailSender, // target - send to myself
|
|
|
606 |
null, // cc
|
|
|
607 |
null, // bcc
|
|
|
608 |
subject, // subject
|
|
|
609 |
mailBody, // body
|
|
|
610 |
null // attachment
|
|
|
611 |
);
|
|
|
612 |
}
|
|
|
613 |
catch( Exception e )
|
|
|
614 |
{
|
|
|
615 |
mLogger.warn("Email Failure: emailBuildComplete:" + e.getMessage());
|
|
|
616 |
}
|
|
|
617 |
mLogger.debug("emailBuildComplete. Returning");
|
|
|
618 |
}
|
|
|
619 |
|
| 814 |
mhunt |
620 |
/**returns 'M'
|
|
|
621 |
*/
|
|
|
622 |
protected char getMode()
|
|
|
623 |
{
|
|
|
624 |
mLogger.debug("getMode");
|
|
|
625 |
return 'M';
|
|
|
626 |
}
|
| 2541 |
dpurdie |
627 |
|
|
|
628 |
/**
|
|
|
629 |
* Nagios interface extension
|
|
|
630 |
* This method should be overriden by classes that extend this class
|
|
|
631 |
* If not overriden then the test indicates OK
|
|
|
632 |
*
|
|
|
633 |
* Returns true if the thread looks OK
|
|
|
634 |
*/
|
|
|
635 |
boolean checkThreadExtended()
|
|
|
636 |
{
|
|
|
637 |
boolean retVal = true;
|
|
|
638 |
mLogger.info("Master checkThreadExtended");
|
|
|
639 |
if ( mPhaseStartTime > 0 )
|
|
|
640 |
{
|
|
|
641 |
/*
|
|
|
642 |
** Report if we appear to be stuck in the current phase
|
|
|
643 |
** At the moment the phases that we monitor should complete
|
|
|
644 |
** within 5 minutes and 10 minutes is real error.
|
|
|
645 |
** We do need to allow time for interlocking with other tasks.
|
|
|
646 |
*/
|
| 4123 |
dpurdie |
647 |
if ( ((System.currentTimeMillis() - mPhaseStartTime) / 1000) > (10 * 60) )
|
| 2541 |
dpurdie |
648 |
{
|
| 4123 |
dpurdie |
649 |
mLogger.info("Master checkThreadExtended: " + ((System.currentTimeMillis() - mPhaseStartTime) / 1000));
|
| 2541 |
dpurdie |
650 |
retVal = false;
|
|
|
651 |
}
|
|
|
652 |
}
|
|
|
653 |
return retVal;
|
|
|
654 |
}
|
|
|
655 |
|
| 814 |
mhunt |
656 |
}
|