Cannot run Cloudfoundry Task - Unexpected Response 404
Asked Answered
M

2

7

After my app is successfully pushed via cf I usually need do manually ssh-log into the container and execute a couple of PHP scripts to clear and warmup my cache, potentially execute some DB schema updates etc.

Today I found out about Cloudfoundry Tasks which seems to offer a pretty way to do exactly this kind of things and I wanted to test it whether I can integrate it into my build&deploy script.

So used cf login, got successfully connected to the right org and space, app has been pushed and is running and I tried this command:

cf run-task MYAPP "bin/console doctrine:schema:update --dump-sql --env=prod" --name dumpsql

(tried it with a couple of folder changes like app/bin/console etc.)

and this was the output:

Creating task for app MYAPP in org MYORG / space MYSPACE as me@myemail...
Unexpected Response
Response Code: 404 FAILED

Uses CF CLI: 6.32.0

cf logs ArcticTenTestBackend --recent does not output anything (this might be the case because I have enabled an ELK instance for logging - as I wanted to service-connect to ELK to look up the logs I found out that the service-connector cf plugin is gone for which I will open a new ticket).

Created new Issue for that: https://github.com/cloudfoundry/cli/issues/1242

Mcmasters answered 6/10, 2017 at 12:44 Comment(3)
This is unexpected - please submit an issue at github.com/cloudfoundry/cli/issues/new. Running the cf command with '-v' may provide more insight on where the 404 is coming from.Shelbyshelden
It says Creating task for app MYAPP.... Just to confirm MYAPP is actually the real name of your app, not literally MYAPP. It should be the actual name of your app. Also, please confirm that your app exists when you run the task. You have to have an app pushed first before you can run tasks. Lastly, run cf feature-flags and make sure your environment has task_creation enabled. Hope that helps!Sociopath
Thanks, feature-flags create command is enabled and of course MYAPP is just replaced to put info here.Mcmasters
H
1

As mentioned by @Mathis Kretz Swisscom has gotten around to enable cf run-task since this question was posted. They send out e-mails on 22. November 2018 to announce the feature.

As discussed on your linked documentation you use the following commands to manage tasks:

cf tasks [APP_NAME]
cf run-task [APP_NAME] [COMMAND]
cf terminate-task [APP_NAME] [TASK_ID]
Hacksaw answered 15/1, 2019 at 14:14 Comment(0)
O
3

This is not a CF CLI issue. Swisscom Application Cloud does not yet support the Cloud Foundry tasks. This explains the 404 you are currently receiving. We will expose this feature of Cloud Foundry in an upcoming release of Swisscom Application Cloud.

In the meantime, maybe you can find a way to execute your one-off tasks (cache warming, DB migrations) at application startup.

Optician answered 12/10, 2017 at 15:43 Comment(3)
It's a bit sad that feature flag of cf pretends the support then. and it would be great to find this info in any Swisscom Dev doc.Mcmasters
Additionally I am not sure why the question doesn't get a single upvote by Swisscom given that this might be interesting for other Swisscom users as well.Mcmasters
TWIMC: Swisscom has announced and enabled the run-task feature in November 2018.Hacksaw
H
1

As mentioned by @Mathis Kretz Swisscom has gotten around to enable cf run-task since this question was posted. They send out e-mails on 22. November 2018 to announce the feature.

As discussed on your linked documentation you use the following commands to manage tasks:

cf tasks [APP_NAME]
cf run-task [APP_NAME] [COMMAND]
cf terminate-task [APP_NAME] [TASK_ID]
Hacksaw answered 15/1, 2019 at 14:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.