Problem
Bamboo remote agent fails after exhausting the tentatives of resending a build result to the Bamboo server due to an empty RESULT_FILE_NAME (<bamboo-agent-home>/xml-data/build-dir/build-result.xml)
INFO | jvm 1 | 2021/12/21 11:30:04 | 2021-12-21 11:30:04,828 INFO [0-BAM::agent1.mydomain.net::Agent:pool-3-thread-1] [BuildAgentControllerImpl] Found a result that requires re-sending.... INFO | jvm 1 | 2021/12/21 11:30:04 | 2021-12-21 11:30:04,834 ERROR [0-BAM::agent1.mydomain.net::Agent:pool-3-thread-1] [BuildAgentControllerImpl] Error loading build context: abort result restoration INFO | jvm 1 | 2021/12/21 11:30:04 | com.thoughtworks.xstream.io.StreamException: INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:126) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.AbstractPullReader.readRealEvent(AbstractPullReader.java:148) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.AbstractPullReader.readEvent(AbstractPullReader.java:141) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.AbstractPullReader.move(AbstractPullReader.java:118) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.AbstractPullReader.moveDown(AbstractPullReader.java:103) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.XppReader.<init>(XppReader.java:63) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:54) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:65) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.AbstractDriver.createReader(AbstractDriver.java:74) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1340) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1292) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.sendPreviousBuildResultIfRequired(BuildAgentControllerImpl.java:237) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.lambda$start$0(DefaultBuildAgent.java:118) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) INFO | jvm 1 | 2021/12/21 11:30:04 | at java.lang.Thread.run(Unknown Source) INFO | jvm 1 | 2021/12/21 11:30:04 | Caused by: java.io.EOFException: input contained no data INFO | jvm 1 | 2021/12/21 11:30:04 | at org.xmlpull.mxp1.MXParser.fillBuf(MXParser.java:3003) INFO | jvm 1 | 2021/12/21 11:30:04 | at org.xmlpull.mxp1.MXParser.more(MXParser.java:3046) INFO | jvm 1 | 2021/12/21 11:30:04 | at org.xmlpull.mxp1.MXParser.parseProlog(MXParser.java:1410) INFO | jvm 1 | 2021/12/21 11:30:04 | at org.xmlpull.mxp1.MXParser.nextImpl(MXParser.java:1395) INFO | jvm 1 | 2021/12/21 11:30:04 | at org.xmlpull.mxp1.MXParser.next(MXParser.java:1093) INFO | jvm 1 | 2021/12/21 11:30:04 | at com.thoughtworks.xstream.io.xml.XppReader.pullNextEvent(XppReader.java:109) INFO | jvm 1 | 2021/12/21 11:30:04 | ... 17 more INFO | jvm 1 | 2021/12/21 11:30:04 | 2021-10-11 13:57:16,944 WARN [0-BAM::agent1.mydomain.net::Agent:pool-3-thread-1] [DefaultBuildAgent] 1 attempts at building without a successful run. The agent will stop after reaching 10 exceptions.
Environment
Bamboo 8.0.1 (agent resiliency code)
Steps to Reproduce
- Stop the Agent
- Have build results to be sent to Bamboo server
- Create an empty RESULT_FILE_NAME (<bamboo-agent-home>/xml-data/build-dir/build-result.xml)
- Start the agent
- Observe Bamboo agent trying to load the contents of RESULT_FILE_NAME as a stream and failing
- The Bamboo agent will retry 10 times by default and then exit.
- The Agent will never be available for builds.
Expected Results
The Bamboo agent should bypass the empty RESULT_FILE_NAME and continue.
Actual Results
The Bamboo agent retries sending the build results 10 times and then exits.
Workaround
Delete <bamboo-agent-home>/xml-data/build-dir/build-result.xml
Notes
BuildAgentControllerImpl.java
public boolean sendPreviousBuildResultIfRequired(ExecutableBuildAgent buildAgent) { if (AgentTypeHolder.get() == AgentType.LOCAL) { return true; } log.info("Found a result that requires re-sending...."); final XStream xStream = secureXStreamFactory.createXStream(); final File workingDirectory = buildDirectoryManager.getBaseBuildWorkingDirectory(); Path buildResultXml = Paths.get(workingDirectory.getAbsolutePath(), RESULT_FILE_NAME); if (Files.exists(buildResultXml)) { try { CommonContext context = (CommonContext) xStream.fromXML(buildResultXml.toFile()); if (context != null) { return retryProcessingResult(buildAgent, context); } } catch (Exception e) { log.error(null, e); buildAgent.incrementError(); return false; } } return true; }