Skip to content
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

Chef falsely reports file not existing when it can't find the interpreter #8251

Open
oneandoneis2 opened this Issue Feb 25, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@oneandoneis2
Copy link

oneandoneis2 commented Feb 25, 2019

Description

Chef was creating (from download) a file containing a python script, then attempting to execute it and reporting "No such file or directory" for the file it had just created. It turned out the problem was the script shebang line called /usr/bin/python and python wasn't installed to this path.

Correct behaviour would be what the shell does: Reporting bad interpreter: /usr/bin/python: no such file or directory

Chef Version

13.8.5

Platform Version

Ubuntu 18.04

Replication Case

Create a file /tmp/foo.py with the first line having an invalid shebang path and have chef try to run it via an execute.

Client Output

    reverse_proxy_18.04: ================================================================================
    reverse_proxy_18.04: Error executing action `run` on resource 'execute[Install agent]'
    reverse_proxy_18.04: ================================================================================
    reverse_proxy_18.04:
    reverse_proxy_18.04: Errno::ENOENT
    reverse_proxy_18.04: -------------
    reverse_proxy_18.04: No such file or directory - /tmp/packer-chef-client/local-mode-cache/cache/awslogs-agent-setup.py
    reverse_proxy_18.04:
    reverse_proxy_18.04: Resource Declaration:
    reverse_proxy_18.04: ---------------------
    reverse_proxy_18.04: # In /tmp/packer-chef-client/local-mode-cache/cache/cookbooks/uj_cloudwatch/recipes/agent.rb
    reverse_proxy_18.04:
    reverse_proxy_18.04: 30: execute 'Install agent' do
    reverse_proxy_18.04: 31:   command "#{Chef::Config[:file_cache_path]}/#{script} -n -r eu-west-2 -c #{tmp_config_path}"
    reverse_proxy_18.04: 32: end

Stacktrace

@lamont-granquist

This comment has been minimized.

Copy link
Contributor

lamont-granquist commented Feb 25, 2019

We don't parse anything inside of the script to change how we execute it and only call exec on it.

This is accurately what exec gives back as an exit code.

I'm not sure what the shell command line is doing to give back that exit status, but I'm more inclined to view this as correct behavior in the general case and not a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.