Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-20181

Windows Elastic Agents are OOMing under default configurations when deploying third-party plugins

      Summary

      Windows Elastic Agents are OOMing under default configurations when deploying third-party plugins and slows down agent start-up performance.

      Environment

      • Windows Elastic Agents

      Steps to Reproduce

      1. Install a third-party plugin, such as Artifactory
      2. Start a Windows Elastic Agent

      Expected Results

      Agent can successfully deploy the plugin on start-up

      Actual Results

      The below exception is thrown in the bamboo-elastic-agent.out file:

      2018-11-14 08:02:14,797 ERROR [AgentRunnerThread] [ScanningPluginLoader] Unable to deploy plugin 'org.jfrog.bamboo.bamboo-artifactory-plugin' from 'Unit: C:\Users\Bamboo\bamboo-agent-home\plugins\user-installed\bamboo-artifactory-plugin-2.5.1.jar (1542182479271)'.
      2018-11-14 08:02:14,797 ERROR [AgentRunnerThread] [ScanningPluginLoader] Because of the following exception:
      java.lang.OutOfMemoryError: Java heap space
      	at java.util.zip.InflaterInputStream.<init>(InflaterInputStream.java:88)
      	at java.util.zip.ZipFile$ZipFileInflaterInputStream.<init>(ZipFile.java:408)
      	at java.util.zip.ZipFile.getInputStream(ZipFile.java:389)
      	at aQute.bnd.osgi.ZipResource.openInputStream(ZipResource.java:26)
      	at aQute.bnd.osgi.Clazz.parseClassFileWithCollector(Clazz.java:484)
      	at aQute.bnd.osgi.ClassDataCollectors.parse(ClassDataCollectors.java:37)
      	at aQute.bnd.osgi.Analyzer.analyze(Analyzer.java:187)
      	at aQute.bnd.osgi.Builder.analyze(Builder.java:352)
      	at aQute.bnd.osgi.Analyzer.calcManifest(Analyzer.java:618)
      	at com.atlassian.plugin.osgi.factory.transform.stage.GenerateManifestStage.execute(GenerateManifestStage.java:187)
      	at com.atlassian.plugin.osgi.factory.transform.DefaultPluginTransformer.transform(DefaultPluginTransformer.java:140)
      	at com.atlassian.plugin.osgi.factory.OsgiPluginFactory.createOsgiPluginJar(OsgiPluginFactory.java:329)
      	at com.atlassian.plugin.osgi.factory.OsgiPluginFactory.create(OsgiPluginFactory.java:231)
      	at com.atlassian.plugin.loaders.ScanningPluginLoader.deployPluginFromUnit(ScanningPluginLoader.java:142)
      	at com.atlassian.plugin.loaders.ScanningPluginLoader.loadAllPlugins(ScanningPluginLoader.java:87)
      	at com.atlassian.plugin.loaders.PermissionCheckingPluginLoader.loadAllPlugins(PermissionCheckingPluginLoader.java:28)
      	at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:524)
      	at com.atlassian.plugin.manager.DefaultPluginManager.init(DefaultPluginManager.java:503)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1827)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1770)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1698)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$42/668961043.getObject(Unknown Source)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
      

      Workaround

      Set the following into the Instance startup script for the image at Bamboo Administration >> Image Configurations >> Edit

      Option 1

      Requires sed to be installed in the image which is included in our stock images but may not existing in a custom AMI.

      sed -i "s/-Dimagefiles/-Dbamboo.agent.syncOnly -Dimagefiles/" C:\opt\bamboo-elastic-agent\bin\bamboo-elastic-agent.bat
      sed -i 's@cd %%OLD_PWD%%@sed -i \'s/-Xmx256m/-Xmx512m/\' \%%TEMP\%%\\\\bamboo-agent-bootstrap-1.bat\n\%%TEMP\%%\\\\bamboo-agent-bootstrap-1.bat ^>^>bamboo-elastic-agent.out 2^>\^&1\ncd %%OLD_PWD%%@' C:\opt\bamboo-elastic-agent\bin\bamboo-elastic-agent.bat
      
      Option 2:
      setx -m _JAVA_OPTIONS "-Xms256m -Xmx512m"

      This is a global Java variable, so any java processes that run during your builds (e.g. Gradle and Maven) will also inherit this config for their respective JVMs.

            [BAM-20181] Windows Elastic Agents are OOMing under default configurations when deploying third-party plugins

            Since Bamboo 8.0, initial and maximum heap size on Elastic Agents are set to 256 and 1024MB respectively. If needed, heap size can be easily modified by configuring wrapper properties as described on this page: https://confluence.atlassian.com/bamboo/elastic-agent-supervisor-1077903823.html 

            Jan Majkutewicz (Inactive) added a comment - Since Bamboo 8.0, initial and maximum heap size on Elastic Agents are set to 256 and 1024MB respectively. If needed, heap size can be easily modified by configuring wrapper properties as described on this page: https://confluence.atlassian.com/bamboo/elastic-agent-supervisor-1077903823.html  

              jmajkutewicz Jan Majkutewicz (Inactive)
              jowen@atlassian.com Jeremy Owen
              Affected customers:
              11 This affects my team
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: