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

cf run-task failing for docker-based apps #1376

Open
rahearn opened this issue Jun 14, 2019 · 3 comments
Open

cf run-task failing for docker-based apps #1376

rahearn opened this issue Jun 14, 2019 · 3 comments

Comments

@rahearn
Copy link

rahearn commented Jun 14, 2019

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
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/166700434

The labels on this github issue will be updated when the story is started.

@Gerg
Copy link
Member

Gerg commented Aug 7, 2020

There is some context in #1333 around why the cf ssh environment is different than the app running environment: https://github.com/cloudfoundry/cloud_controller_ng/issues/1333#issuecomment-486478224

@matti
Copy link

matti commented Jun 8, 2021

workarounds:

  • get envs from /proc/<PID>/environ
  • start a "sidecar" server in the entrypoint as port ":9999" which responds with the environment it has and then when executing the task or ssh eval $(curl localhost:999)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants