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

Bamboo will delete the whole Docker Runner container including long-term mounted volumes data(!) from the host if the ${bamboo.build.working.directory} location doesn't exist or can't be accessed

      Issue Summary

      This is reproducible on Data Center:

      This is likely a combined bug with:

      Bamboo will delete the whole Docker runner container contents, INCLUDING LONG-TERM, MOUNTED VOLUMES data in the Docker host, if the ${bamboo.build.working.directory} location can't be accessed and the "Clean working directory after each build" is enabled under the Job's Other options

      When the "Clean working directory after each build" option is enabled, Bamboo will call com.atlassian.bamboo.utils#QuietlyRemoved which will invoke the creation of the cleanDirectory.sh script to be executed on the container. As Bamboo could not initially cwd to the ${bamboo.build.working.directory} directory as it didn't exist, the script would be executed on the container's root folder ( / ) with the following content:

      #!/bin/sh
      find . -mindepth 1 -delete >/dev/null 2>&1
      

      That find command invocation will delete all the files in the container, including files that are long-term set as mounted external volumes on the Job's Docker configuration >> Volumes properties.

      Steps to Reproduce

      1. Configure a Job with Docker Runner and enable "Clean working directory after each build" under Other options
      2. Have the ${bamboo.build.working.directory} not created, to get there you can assign a different volume to the ${bamboo.build.working.directory} location on the Job's configuration "Volume" properties. E.g.:
        ${bamboo.build.working.directory} >> /opt/src
        
      3. Have an extra path to the container configuration's volume setting that would be mounted as an external, long-term volume. E.g.
        /home/ccache >> /home/ccache
        
      4. Populate the /home/ccache folder with data you expect to remain after the build
      5. Add a simple "hello world" task to the Plan
      6. Run the Plan

      Expected Results

      1. The build should fail as Bamboo could not access the workdir
      2. The long-term data on the external volume should remain intact

      Actual Results

      1. The build succeeds (green)
      2. No logs are available as they got removed before being transferred to the server
      3. All the data on the long-term volume is gone

      Workaround

      1. Use only the default Job's ${bamboo.working.directory} mount point on the Job's Volume options
      2. Do not enable the "Clean working directory after each build" Job option. If the cleanup is necessary after each build, add a Final task (so it can run regardless of other Task results) to the Job and invoke a Script Task that would remove the desired content from the folders you wish in a controlled way.

          Form Name

            [BAM-22120] Bamboo will delete the whole Docker Runner container including long-term mounted volumes data(!) from the host if the ${bamboo.build.working.directory} location doesn't exist or can't be accessed

            There are no comments yet on this issue.

              0ecd005f55dd Krzysztof Podsiadło
              73868399605e Eduardo Alvarenga
              Affected customers:
              1 This affects my team
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: