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

Disabling auto-capability detection for the remote agent is not working for new agent

      Summary

      1. Source-code

      ./components/bamboo-api/src/main/java/com/atlassian/bamboo/utils/SystemProperty.java:195
          /**
           *  Prevents agents from automatically overriding remote agent capabilities on new startup
           * <p>
           * <ul>
           * <li>Default    : false
           * <li>Usage: <ul><li>env : DISABLE_AGENT_AUTO_CAPABILITY_DETECTION="true"
           *                  <li>java: -DDISABLE_AGENT_AUTO_CAPABILITY_DETECTION=true
           *              </ul>
           * </ul>
           */
          public static final SystemProperty DISABLE_AGENT_AUTO_CAPABILITY_DETECTION = new SystemProperty(false, "DISABLE_AGENT_AUTO_CAPABILITY_DETECTION");
      

      2. Steps to Reproduce

      1. stop Bamboo (server)
      2. add property to prevent agents from automatically overriding remote agent capabilities on new startup
        <bamboo-install>/bin/setenv.sh, Windows (setenv.bat) - Linux/MacOSX (setenv.sh)
        JVM_SUPPORT_RECOMMENDED_ARGS="-DDISABLE_AGENT_AUTO_CAPABILITY_DETECTION=true"
        
      3. start Bamboo server
      4. install Bamboo remote agent
        java -Dbamboo.home=/path/to/remote-agent-home -jar atlassian-bamboo-agent-installer-5.9.x.jar http://BAMBOO_BASE_URL/agentServer/
        

      3. Expected Results

      According to Bamboo's documentation - Disabling auto-capability detection for the remote agent the remote agent should not automatically detect and add capabilities.

      There may be situations where you want to prevent Bamboo from automatically detecting and adding capabilities (such as JDKs) to the remote agent, or where you don't want to run the remote agent with default capabilities.

      4. Actual Results

      By going to "Bamboo administration >> Overview >> Build resources >> Agents" and selecting the "Remote Agent", under "Capabilities" tab we can find a few capabilities listed. The same can be reviewed by running the following SQL query against Bamboo's database:

      /* 1507331 is the remote agent id */
      select *
        from queue as AGENT
        join capability as CAPABILITY
              on AGENT.capability_set = CAPABILITY.capability_set
       where AGENT.capability_set = 1507331;
      

      As a response from the query above, you can find the following:

      queue_id agent_type title agent_description created_date updated_date enabled capability_set last_start_time last_stop_time elastic_instance_id elastic_image capability_id key_identifier value capability_set
      1474563 REMOTE 192.168.10.80 Remote agent on host 192.168.10.80 2015-10-20 12:19:49 2015-10-20 12:19:49 true 1507331 2015-10-20 12:19:49 (null) (null) (null) 1540115 system.builder.mvn3.Maven 3 /opt/maven/apache-maven-3.3.3 1507331
      1474563 REMOTE 192.168.10.80 Remote agent on host 192.168.10.80 2015-10-20 12:19:49 2015-10-20 12:19:49 true 1507331 2015-10-20 12:19:49 (null) (null) (null) 1540114 system.jdk.JDK /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home 1507331
      1474563 REMOTE 192.168.10.80 Remote agent on host 192.168.10.80 2015-10-20 12:19:49 2015-10-20 12:19:49 true 1507331 2015-10-20 12:19:49 (null) (null) (null) 1540113 system.jdk.JDK 1.7 /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home 1507331
      1474563 REMOTE 192.168.10.80 Remote agent on host 192.168.10.80 2015-10-20 12:19:49 2015-10-20 12:19:49 true 1507331 2015-10-20 12:19:49 (null) (null) (null) 1540112 system.hg.executable /usr/local/bin/hg 1507331
      1474563 REMOTE 192.168.10.80 Remote agent on host 192.168.10.80 2015-10-20 12:19:49 2015-10-20 12:19:49 true 1507331 2015-10-20 12:19:49 (null) (null) (null) 1540111 system.git.executable /usr/local/bin/git 1507331
      1474563 REMOTE 192.168.10.80 Remote agent on host 192.168.10.80 2015-10-20 12:19:49 2015-10-20 12:19:49 true 1507331 2015-10-20 12:19:49 (null) (null) (null) 1540110 system.jdk.JDK 1.7.0_79 /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home 1507331
      1474563 REMOTE 192.168.10.80 Remote agent on host 192.168.10.80 2015-10-20 12:19:49 2015-10-20 12:19:49 true 1507331 2015-10-20 12:19:49 (null) (null) (null) 1540109 foo bar 1507331

      5. Notes

      In the above example, it was created "<bamboo-agent-home>/bin/bamboo-capabilities.properties"with the following content:

      <bamboo-agent-home>/bin/bamboo-capabilities.properties
      foo=bar
      

      And we can notice the capability was added to the remote agent.

      queue_id agent_type title agent_description created_date updated_date enabled capability_set last_start_time last_stop_time elastic_instance_id elastic_image capability_id key_identifier value capability_set
      1474563 REMOTE 192.168.10.80 Remote agent on host 192.168.10.80 2015-10-20 12:19:49 2015-10-20 12:19:49 true 1507331 2015-10-20 12:19:49 (null) (null) (null) 1540109 foo bar 1507331

            [BAM-16502] Disabling auto-capability detection for the remote agent is not working for new agent

            As mentioned in previous comments the DISABLE_AGENT_AUTO_CAPABILITY_DETECTION property needs to be set in n wrapper.conf file in agent home directory:

            wrapper.java.additional.3=-DDISABLE_AGENT_AUTO_CAPABILITY_DETECTION=true
            

            Krystian Brazulewicz added a comment - As mentioned in previous comments the DISABLE_AGENT_AUTO_CAPABILITY_DETECTION property needs to be set in n wrapper.conf file in agent home directory: wrapper.java.additional.3=-DDISABLE_AGENT_AUTO_CAPABILITY_DETECTION= true

            Thanks @johannes_appenzeller : Revisiting the wrapper.conf and replacing the previously documented lower-case property with this one now really actually does the trick for restarting agents. Thanks!

            Benjamin Schmid added a comment - Thanks @johannes_appenzeller : Revisiting the wrapper.conf and replacing the previously documented lower-case property with this one now really actually does the trick for restarting agents. Thanks!

            Hi @Benjamin Schmid, what version of Bamboo are you on? This works in later versions of Bamboo if disabled directly on the agent. In wrapper.conf, set

            wrapper.java.additional.3=-DDISABLE_AGENT_AUTO_CAPABILITY_DETECTION=true
            

            This will have the desired effect.

            Johannes A added a comment - Hi @Benjamin Schmid, what version of Bamboo are you on? This works in later versions of Bamboo if disabled directly on the agent. In wrapper.conf, set wrapper.java.additional.3=-DDISABLE_AGENT_AUTO_CAPABILITY_DETECTION= true This will have the desired effect.

            Any updates on this? I need to manually delete all the introduced capabilities after every agent restart. Otherwise people immediately start using those capability and massively complain because they wont build properly.

            The major reasons why the autodiscovered capabilities are not usable is that they miss the version. I.e. they say only "NodeJS" but not if 6.xLTS oder 8.x LTS or even 4.x.

            Benjamin Schmid added a comment - Any updates on this? I need to manually delete all the introduced capabilities after every agent restart. Otherwise people immediately start using those capability and massively complain because they wont build properly. The major reasons why the autodiscovered capabilities are not usable is that they miss the version. I.e. they say only "NodeJS" but not if 6.xLTS oder 8.x LTS or even 4.x.

              Unassigned Unassigned
              rsperafico Rafael Sperafico (Inactive)
              Affected customers:
              15 This affects my team
              Watchers:
              15 Start watching this issue

                Created:
                Updated:
                Resolved: