-
Notifications
You must be signed in to change notification settings - Fork 18.7k
/etc/hostname Device or resource busy #9295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@fromonesrc could you provide more information according to https://github.com/docker/docker/blob/master/CONTRIBUTING.md#reporting-issues |
Sorry about that, will follow up soon as I can. |
The issue is that even though you can "write" to those files, you can't rename them. This is due to both files being bind mounted. I am using ansible to automatically update /etc/hosts with references to either other machines, or to localhost. I then place lines like the following in the file: x.x.x.x $app_service.configThe method that ansible uses to update a file, is to write it to a temporary location, then do an atomic rename. This is a fairly standard way to update files, while ensuring safety that the new file has been saved to disk. |
@vbatts I've updated the issue with more detail about my env. |
+1 (the ability to write/modify /etc/hosts, /etc/resolv.conf and possibbly other tools is key for any deployment CI testing on docker on any image and any tooling (chef, ansible, puppet, salt)). @vbatts - The ability to specify --dns --add-host is fine. But the use case is to run deployment testing within a docker container. So since the deployment tools running test modify filesystem withing the image they must have an option to modify any part of the FS. Even the performance will be affected. |
I have found the same issue on Docker 1.3, 1.4. The cause was not in docker. The chef hostfile cokbook was using a file resource (which ootb enables atomic_update: true) and that caused the issue on /etc/hosts file update. When I logged in the new docker image However, with false it works:
The solution could be to use chef_client config option on .kitchen.yml:
However I guess, chef_client cookbook do not set this option at the current state: chef-boneyard/chef-client#248 Also I run immediately to another issue while modifing /etc/resolv.conf with template resource:
but due the chef-apply issue with template resource I did not proceed further - https://tickets.opscode.com/browse/CHEF-4002?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel |
closed see comment about problem not within docker but chef #9295 (comment) |
@epcim I found out that the correct place to put the setting in .kitchen.yml is in the provisioner section like so.
You can also put this in the global provisioner section if you wish. |
For future people that come across this issue, I thought I would leave link to the documentation in Docker that explains why Puppet, Chef, etc can't update /etc/hosts, /etc/resolv.conf, & /etc/hostname in a container (at least not if they are doing an atomic rename that they would normally do). -- https://docs.docker.com/articles/networking/#dns That documentation explains how those three files are special overlays managed by Docker as part of its networking support. Essentially your provisioning scripts ought to leave them alone and you can pass command-line arguments to docker to influence their contents. From the docs -
|
Use shell/copy magic to w/a moby/moby#9295 Related-bug: #1547587 Change-Id: I881d362968a10d816cbd368cb185900dfaa0b3bc Signed-off-by: Bogdan Dobrelya <bdobrelia@mirantis.com>
@jdmulloy Hi, I'm the software developer at chef who actually wrote the file_atomic_update code. You should not be abusing the global setting in that way. The right way to fix this is to update only the specific file resources that need to use it. Your workaround will work right up until it invalidates your testing and you deploy code to production that fails which passed in your preproduction testing. And if you deploy this setting to production and flip every file resource in your production runs to not be atomic you incur a severe risk of incurring data loss, corruption of files and crashing. I'll be updating the Chef::Config internal documentation and the chef.docs.io website with big warnings not to tweak that global setting, along with updating the docs.chef.io site with warnings against doing that. https://github.com/chef/chef/pull/4696/files I've also released a chef_hostname cookbook which has the right setting and supports docker containers: |
@lamont-granquist , so how do we properly rectify this issue? |
set you can even re-open file or template resources used by other resources and
throw that in a recipe somewhere after for editing /etc/hostname and/or /etc/hosts to set the hostname the chef_hostname resource does that for you, just use it: https://supermarket.chef.io/cookbooks/chef_hostname if you are using some other cookbook to edit /etc/hosts then that cookbook should get patched, but you can use the previous technique to open up the resource collection and dynamically patch the resource it creates. |
The resolver cookbook issue that @epcim mentioned above is also being fixed here: |
The chef/chef#4949 issue has been opened to solve this in chef core for all file resources and detect docker guests and add the atomic_updates flag by default -- only for /etc/hosts, /etc/hostname and /etc/resolv.conf and only in docker guests. |
The page mentioned in comment #9295 (comment) is no longer available |
Faced multiple issues with docker failing. - https://travis-ci.org/issmirnov/ansible-role-zap/jobs/206008075 - moby/moby#9295 In short, we can't use docker since /etc/hosts is a protected file. Setting up systemd docker containers is also a pain. Going to stick to simple syntax checks.
STATE: When trying to setup '/etc/resolv.conf' for a docker image, chef fails with the following error: >> ================================================================================ >> Error executing action `create` on resource 'template[/etc/resolv.conf]' >> ================================================================================ >> >> Errno::EBUSY >> ------------ >> Device or resource busy @ rb_file_s_rename - (/etc/.chef-resolv20220527-680-734sd3.conf, /etc/resolv.conf) >> >> Cookbook Trace: (most recent call first) >> ---------------------------------------- >> /opt/kitchen/cache/cookbooks/resolver/resources/config.rb:99:in `block in class_from_file' The logic behind this error is describe on the follwing issue: moby/moby#9295 (comment) And a PR was created to fix this in a previous recipe: sous-chefs#22 PROPOSED SOLUTION: Add the 'atomic_update' property on the resource Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
STATE: When trying to setup '/etc/resolv.conf' for a docker image, chef fails with the following error: >> ================================================================================ >> Error executing action `create` on resource 'template[/etc/resolv.conf]' >> ================================================================================ >> >> Errno::EBUSY >> ------------ >> Device or resource busy @ rb_file_s_rename - (/etc/.chef-resolv20220527-680-734sd3.conf, /etc/resolv.conf) >> >> Cookbook Trace: (most recent call first) >> ---------------------------------------- >> /opt/kitchen/cache/cookbooks/resolver/resources/config.rb:99:in `block in class_from_file' The logic behind this error is describe on the follwing issue: moby/moby#9295 (comment) And a PR was created to fix this in a previous recipe: sous-chefs#22 PROPOSED SOLUTION: Add the 'atomic_update' property on the resource Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
* fix(workflow): Fix the github workflow STATE: As stated in the following comments: #60 (comment) This commit applies this fix Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com> * feat(atomic_update): Allow the atomic_update property STATE: When trying to setup '/etc/resolv.conf' for a docker image, chef fails with the following error: >> ================================================================================ >> Error executing action `create` on resource 'template[/etc/resolv.conf]' >> ================================================================================ >> >> Errno::EBUSY >> ------------ >> Device or resource busy @ rb_file_s_rename - (/etc/.chef-resolv20220527-680-734sd3.conf, /etc/resolv.conf) >> >> Cookbook Trace: (most recent call first) >> ---------------------------------------- >> /opt/kitchen/cache/cookbooks/resolver/resources/config.rb:99:in `block in class_from_file' The logic behind this error is describe on the follwing issue: moby/moby#9295 (comment) And a PR was created to fix this in a previous recipe: #22 PROPOSED SOLUTION: Add the 'atomic_update' property on the resource Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com> * doc(atomic_update): Update the documentation for 'atomic_update' Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com> * CI: Set atomic_update to false in default test recipe Signed-off-by: Lance Albertson <lance@osuosl.org> * CI: Update and fix tested platforms Signed-off-by: Lance Albertson <lance@osuosl.org> Co-authored-by: Lance Albertson <lance@osuosl.org>
I am using Chef to update
/etc/hostname
and/etc/hosts
which fails with this error:This was supposedly fixed in 1.2.0. Any ideas what I could be doing wrong or if this is a regression?
I am running on OS X 10.10 via boot2docker on Ubuntu 12.04.
Here are some more environment details:
The text was updated successfully, but these errors were encountered: