2

I'm trying to get 'cf run-task' to work on the swisscom cloudfoundry instance. But it fails with even the simplest command:

$ cf run-task hostapp "echo SUCCESS" --name task1
Creating task for app hostapp in org xxx / space yyy as xxx@yyy.com...
Unexpected Response
Response Code: 404
FAILED

Is run-task not yet supported in cf api version 2.96.0? (which seems to be the current installed version on the swisscom env)

domi
  • 2,167
  • 1
  • 28
  • 45
  • 3
    Possible duplicate of [Cannot run Cloudfoundry Task - Unexpected Response 404](https://stackoverflow.com/questions/46606065/cannot-run-cloudfoundry-task-unexpected-response-404) – Sybil Nov 07 '17 at 08:10

2 Answers2

1

The Swisscom Application Cloud has not activated the cf run-task feature yet. As of now, it's best to use cf ssh and then run the command manually from within your container or include these tasks as idempotent actions in your app's startup script.

cf run-task will be enabled in a future release of the Application Cloud.

cloudlena
  • 865
  • 11
  • 14
  • 1
    thats really unfortunate, on one hand the recommendation is not to use `ssh` to update the DB (https://stackoverflow.com/questions/47061859/why-does-cloudfoundry-ssh-drop-the-connection-after-24-minutes?noredirect=1#comment81098786_47061859), but on the other hand `run-task` is disabled. If I have large amount of data for the initial load of a database, then initializing the DB at app start is really not a good idea... are there any plans to activate the feature any time soon? – domi Nov 07 '17 at 09:22
  • @domi what is "large amount of data" in GB and record count? Do you use MariaDB Ent? – Sybil Nov 08 '17 at 13:34
  • @FyodorGlebov it depends on what kind of env we do a setup for, but it goes can go up to 1G and maybe more in the future. Doing it at the app start, does also mean I have to pack all this data with the application and this for ever, even though I don't need it anymore in old envs. Not having 'run-task' available also means Swisscom env is not compatible with our other env. (pivotal) and we have to implement different scripting solutions for Swisscom. – domi Nov 09 '17 at 07:48
  • @domi thanks. In what format your data? SQL dump? YML? – Sybil Nov 09 '17 at 07:53
  • @domi is it initial load? – Sybil Nov 09 '17 at 08:29
  • @FyodorGlebov in XML (liquibase) and yes when we setup a new env then its initial load, but it could also happen that we introduce a new table with the next feature that will also need an initial load. So an "initial load" could happen anytime again, it's just a question of the state the env has a t that time. ...we run multiple different environments and number is growing faster in the future. – domi Nov 09 '17 at 10:00
  • any news here? is there a roadmap for this feature? – Daniel Feb 22 '18 at 12:07
  • There has been a release at the end of 2018 that enabled this feature. @mastertinner could you please update this post accordingly? – Chris Jan 15 '19 at 14:03
0

As mentioned by @mastertinner Swisscom has since enabled cf run-task as part of their application cloud offering. They send out e-mails discussing the release on 22. November 2018, linking to the official CloudFoundry documentation: https://docs.cloudfoundry.org/devguide/using-tasks.html

You can use these commands:

cf tasks [APP_NAME]
cf run-task [APP_NAME] [COMMAND]
cf terminate-task [APP_NAME] [TASK_ID]
Chris
  • 3,245
  • 4
  • 29
  • 53