-
Bug
-
Resolution: Unresolved
-
Low
-
None
-
8.1.3
-
None
-
3
-
Severity 3 - Minor
-
3
-
Summary
Bamboo has the facility to run a Job within a Docker context.
If the Job creates a directory that is not world writable that contains a file then the agent is unable to clean the directory if requested.
Bamboo currently tries to workaround this issue by prepending a "umask 000" command to any script task. Unfortunately, this does not prevent the user from creating directories that are not world writable.
The owner of any file created within a Docker runner job will default to being owned by the owner of the docker daemon. This is usually NOT the same user that is running the Bamboo agent.
When the "Clean working directory after each job" is ticked the bamboo agent will attempt to remove all the files in the Build directory. It first attempts to change the permissions on the files and directories so that they are writable. This will fail outside the docker environment because the Bamboo agent does not own the file.
The working directory cleaning works correctly in the end, and this was fixed via BAM-20082 however the error message "Could not remove working directory.. operation not permitted" still appears in the logs
Environment
Job runs in a Docker environment.
"Clean working directory after each job" enabled.
Steps to Reproduce
- create Job and specify to run job in Docker container. use "ubuntu" image.
- create script task to create a file in a directory.
mkdir dir chmod 755 dir touch dir/file
Expected Results
The Job is successful , no error message seen in the logs and the directory cleaned up
Actual Results
The Job is successful and the directory is cleaned up successfully , but below error message is seen in the logs , every time the build runs :-
Could not remove working directory for plan 'MSS-GRP0-GB': /home/bamboo/bamboo-agent-home/xml-data/build-dir/MSS-GRP0-GB/rpm_package_creator/release: Operation not permitted INFO | jvm 2 | 2022/01/31 14:35:42 | java.nio.file.FileSystemException: /home/bamboo/bamboo-agent-home/xml-data/build-dir/MSS-GRP0-GB/rpm_package_creator/release: Operation not permitted INFO | jvm 2 | 2022/01/31 14:35:42 | at sun.nio.fs.UnixException.translateToIOException(UnixException.java:91) INFO | jvm 2 | 2022/01/31 14:35:42 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) INFO | jvm 2 | 2022/01/31 14:35:42 | at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) INFO | jvm 2 | 2022/01/31 14:35:42 | at sun.nio.fs.UnixFileAttributeViews$Posix.setMode(UnixFileAttributeViews.java:238) INFO | jvm 2 | 2022/01/31 14:35:42 | at sun.nio.fs.UnixFileAttributeViews$Posix.setPermissions(UnixFileAttributeViews.java:260) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.utils.BambooPathUtils$1.preVisitDirectory(BambooPathUtils.java:111) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.utils.BambooPathUtils$1.preVisitDirectory(BambooPathUtils.java:91) INFO | jvm 2 | 2022/01/31 14:35:42 | at java.nio.file.Files.walkFileTree(Files.java:2677) INFO | jvm 2 | 2022/01/31 14:35:42 | at java.nio.file.Files.walkFileTree(Files.java:2742) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.utils.BambooPathUtils.cleanDirectory(BambooPathUtils.java:80) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.util.BambooFileUtils.cleanDirectory(BambooFileUtils.java:612) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.cleanWorkingDirectory(ExecuteBuildTask.java:115) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:94) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:190) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:162) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:137) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:118) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:130) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.lambda$start$0(DefaultBuildAgent.java:110) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) INFO | jvm 2 | 2022/01/31 14:35:42 | at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) INFO | jvm 2 | 2022/01/31 14:35:42 | at java.lang.Thread.run(Thread.java:748)
Notes
In https://jira.atlassian.com/browse/BAM-20082 despite the error the working directory is cleaned correctly.In this bug special handling for cleaning directories while using docker runner.The working directory cleaning works correctly in the end, however the erro message still appears in the logs
Workaround
It looks that despite the error the working directory is cleaned correctly. The working directory is getting cleaned up for sure . The only issue is the error message -"Could not remove working directory for plan: Operation not permitted " generated in the logs everytime the build is run.
- relates to
-
BAM-20082 "Operation not permitted" failure to clean up Docker runner build directory
-
- Closed
-