cloudfoundry / cloudfoundry/cloud_controller_ng

cf run-task failing for docker-based apps

Open
#1,376 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug scheduled
Dominant language
Ruby
Stars
207
Forks
373
Avg merge
2d 12h
Merged PRs (30d)
56

Description

Issue

A simple app built with Ruby on Rails and deployed to cloud.gov via docker image runs fine, but cf run-tasks and cf ssh do not work without workarounds.

Context

It appears that the PATH gets messed up for cf run-tasks and cf ssh while the actual running app is fine. On an example app:

cf run-tasks cf-test "bundle exec rake db:migrate" fails, but

cf run-task cf-test "export PATH=/usr/local/bundle/bin:/usr/local/bundle/gems/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin && cd /usr/src/app && bundle check --path vendor/bundle/ && bundle exec rake db:migrate"

works. The same PATH exporting and bundle check dance is required to run commands after using cf ssh APP_NAME

On further testing today, run-task might only require prepending the cd /usr/src/app (that path being the WORKDIR of the docker image) part to correctly run, though cf ssh requires the full setup before commands start being found.

Steps to Reproduce

A reproducing example app is at https://github.com/rahearn/cf-docker-test

The full docker build command used was:

docker build -t rcahearn/cf-test --build-arg RAILS_MASTER_KEY=809a1129e14e8e36f126c76dfce87e25 --build-arg BUILD_ENV=production --build-arg BUNDLE_WITHOUT="development test" .

Expected result

Tasks such as bundle exec rake db:migrate:status complete successfully.

Current result

Tasks such as bundle exec rake db:migrate:status fail with logs:

2019-06-14T09:09:24.14-0400 [APP/TASK/f180fd00/0] ERR Could not locate Gemfile or .bundle/ directory
2019-06-14T09:09:24.17-0400 [APP/TASK/f180fd00/0] OUT Exit status 10

Commands such as bundle exec rake db:migrate:status when run after sshing to app fail with:

root@f153f6fd-97a9-47ab-4a36-e9c8:/usr/src/app# bundle exec rake db:migrate:status
bash: bundle: command not found

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducing app at https://github.com/rahearn/cf-docker-test and compare the environment used by cf run-task and cf ssh. The payload names no cloud_controller_ng files or tests; done means Docker-based apps can run the documented task and SSH commands without manually exporting PATH, changing directories, or running bundle setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, rails, ruby
Domain
backend, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.