cli icon indicating copy to clipboard operation
cli copied to clipboard

CLI should strengthen the command of 'cf files'

Open magicwang-cn opened this issue 12 years ago • 9 comments

currently, 'cf files' command only print out files about the first instance of the app.As follows: func (repo CloudControllerAppFilesRepository) ListFiles(appGuid, path string) (files string, apiErr error) { url := fmt.Sprintf("%s/v2/apps/%s/instances/0/files/%s", repo.config.ApiEndpoint(), appGuid, path) request, apiErr := repo.gateway.NewRequest("GET", url, repo.config.AccessToken(), nil) if apiErr != nil { return }

files, _, apiErr = repo.gateway.PerformRequestForTextResponse(request)
return

}

so we can't print out files about all instances of app.

magicwang-cn avatar May 19 '14 06:05 magicwang-cn

We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/71552474. This repo is managed by the 'CLI' team.

cf-gitbot avatar May 19 '14 06:05 cf-gitbot

Hi @w00204372,

This was an intentional design decision. Ideally, we would like users to treat instances as ephemeral containers; individual instances should not keep state in their temporary storage, so the first container should return a file list that matches what the other instances have.

Can you explain what your potential use case for this would be?

As a workaround, you can use cf curl to hit an endpoint directly:

cf curl /v2/apps/:app_guid/instances/0/files/

Thanks, CF Community Support (@stupakov)

stupakov avatar May 21 '14 17:05 stupakov

Hi @stupakov , yes ,cf curl can satisfy this request.but i think that some users don't know the really HTTP PATH(such as /v2/apps/:app_guid/instances/0/files/), and even more, app maybe have its log file, so one app with more than one instance, their log files record different logs, so CLI just use the first instance of the app can not satisfy this request.

magicwang-cn avatar May 22 '14 01:05 magicwang-cn

@w00204372 If you're using his to retrieve logs is there any reason you can't/don't want to use loggregator? Stdout/stderr for all application instances can be viewed via the CF cli (for a limited period time) or forwarded out to a syslog drain for longer term storage.

lcddave avatar May 22 '14 03:05 lcddave

Just going to a single instance might not be sufficient in cases where the app is behaving badly in one or few and we need to retrieve data from all instances. I just recently created a script that would retrieve data from all instances for a given app as I wanted to use this approach to trigger/collect data from all related instances (trigger thread dumps, collect stats etc). Let me know if this would help.

#Grab the appGuid and the instance ids for each of the running instances.

CF_TRACE=true cf app $appName >& $tmpFile

appGuid=grep summary $tmpFile | sed -e 's/summary.*//g;s/GET .*apps//g;s/\///g;'·

#echo "*** AppGuid is $appGuid"

The running instances id comes with special characters to make them appear with color like: A grep "running " $tmpFile | sed -e 's/ .*//g;s/^[^#]*#//g;s/\[.*//g;s/^[//g' > /tmp/foo

Once the running instances are identified, then you can create a url like following: Sample URL /v2/apps/38699180-05c1-4c15-af24-f6c3fce5b1dc/instances/0/files/tmp/dumpThread $completeUrl="/v2/apps/$appGuid/instances/$instanceId/files/MyFile.. cf curl $completeUrl

Would be great if the CLI allows users to retrieve files from all running instances using some additional option (like -a for all instances) rather than just instance-0.

-Sabha

sparameswaran avatar May 22 '14 05:05 sparameswaran

@lcddave should this be marked WONTFIX and closed?

Jesse

d avatar May 23 '14 23:05 d

@d Not yet... I need to confirm 1 or 2 things on this side. I'll update once we close on that.

lcddave avatar May 23 '14 23:05 lcddave

sweet, thanks david.

d avatar May 23 '14 23:05 d

@w00204372 This story has been created in the CLI backlog to address your issue.

The story has not yet been prioritized or scheduled. We would welcome a pull request from you if you're interested in implementing it.

Thanks @krishicks && @dliebreich CF Community Pair

dliebreich avatar Jul 15 '14 21:07 dliebreich