{"action":"created","issue":{"url":"https://api.github.com/repos/cloudfoundry/cli/issues/1458","repository_url":"https://api.github.com/repos/cloudfoundry/cli","labels_url":"https://api.github.com/repos/cloudfoundry/cli/issues/1458/labels{/name}","comments_url":"https://api.github.com/repos/cloudfoundry/cli/issues/1458/comments","events_url":"https://api.github.com/repos/cloudfoundry/cli/issues/1458/events","html_url":"https://github.com/cloudfoundry/cli/issues/1458","id":359694668,"node_id":"MDU6SXNzdWUzNTk2OTQ2Njg=","number":1458,"title":"`cf push` with multiple buildpacks / non-default stack specified does not work","user":{"login":"tcdowney","id":2096955,"node_id":"MDQ6VXNlcjIwOTY5NTU=","avatar_url":"https://avatars2.githubusercontent.com/u/2096955?v=4","gravatar_id":"","url":"https://api.github.com/users/tcdowney","html_url":"https://github.com/tcdowney","followers_url":"https://api.github.com/users/tcdowney/followers","following_url":"https://api.github.com/users/tcdowney/following{/other_user}","gists_url":"https://api.github.com/users/tcdowney/gists{/gist_id}","starred_url":"https://api.github.com/users/tcdowney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcdowney/subscriptions","organizations_url":"https://api.github.com/users/tcdowney/orgs","repos_url":"https://api.github.com/users/tcdowney/repos","events_url":"https://api.github.com/users/tcdowney/events{/privacy}","received_events_url":"https://api.github.com/users/tcdowney/received_events","type":"User","site_admin":false},"labels":[{"id":371026368,"node_id":"MDU6TGFiZWwzNzEwMjYzNjg=","url":"https://api.github.com/repos/cloudfoundry/cli/labels/in%20progress","name":"in progress","color":"3461AD","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-09-13T00:01:59Z","updated_at":"2018-09-14T03:17:35Z","closed_at":null,"author_association":"MEMBER","body":"**Please fill out the issue checklist below and provide ALL the requested information.**\r\n\r\n- [x] I tried updating to the latest version of the CF CLI to see if it fixed my problem.\r\n- [x] I attempted to run the command with `CF_TRACE=1` to help debug the issue.\r\n- [x] I am reporting a bug that others will be able to reproduce.\r\n\r\n**Describe the bug and the command you saw an issue with**\r\nThis behavior was reported to CAPI last week. A user was trying to push an app using multiple buildpacks with a specific stack.\r\n\r\nExample:\r\n```\r\ncf push bug -b ruby_buildpack -b php_buildpack -s cflinuxfs3\r\n```\r\n\r\n~When those buildpacks exist for the default stack in the environment (in this case `cflinuxfs2`) it will actually stage with the `cflinuxfs2` buildpacks.~ (This was wrong, my app got in a weird state) If there are no `cflinuxfs2` buildpacks that match the requested names it will fail with a validation error.\r\n\r\n[See CAPI #160325184](https://www.pivotaltracker.com/story/show/160325184) for more information.\r\n\r\n**What happened**\r\nTo get this to fail in a more obvious way, I first had to remove/rename the `cflinuxfs2` Ruby buildpack:\r\n\r\n1. `cf curl /v2/buildpacks?q:name=ruby_buildpack`\r\n1. Find the one with `\"stack\": \"cflinuxfs2\"` and note its guid\r\n1. `cf curl -X PUT /v2/buildpacks/<guid> -d '{\"name\": \"ruby_buildpack_backup\"}'` \r\n\r\nMy installed buildpacks now looked like this:\r\n```\r\ncf buildpacks\r\nGetting buildpacks...\r\n\r\nbuildpack               position   enabled   locked   filename                                      stack\r\nstaticfile_buildpack    1          true      false    staticfile-buildpack-cflinuxfs2-v1.4.31.zip   cflinuxfs2\r\njava_buildpack          2          true      false    java-buildpack-cflinuxfs2-v4.15.zip           cflinuxfs2\r\nruby_buildpack_backup   3          true      false    ruby-buildpack-cflinuxfs2-v1.7.22.zip         cflinuxfs2\r\ndotnet_core_buildpack   4          true      false    dotnet-core-buildpack-cflinuxfs2-v2.1.4.zip   cflinuxfs2\r\nnodejs_buildpack        5          true      false    nodejs-buildpack-cflinuxfs2-v1.6.30.zip       cflinuxfs2\r\ngo_buildpack            6          true      false    go-buildpack-cflinuxfs2-v1.8.26.zip           cflinuxfs2\r\npython_buildpack        7          true      false    python-buildpack-cflinuxfs2-v1.6.20.zip       cflinuxfs2\r\nphp_buildpack           8          true      false    php-buildpack-cflinuxfs2-v4.3.59.zip          cflinuxfs2\r\nbinary_buildpack        9          true      false    binary-buildpack-cflinuxfs2-v1.0.25.zip       cflinuxfs2\r\nstaticfile_buildpack    10         true      false    staticfile-buildpack-cflinuxfs3-v1.4.31.zip   cflinuxfs3\r\njava_buildpack          11         true      false    java-buildpack-cflinuxfs3-v4.15.zip           cflinuxfs3\r\nruby_buildpack          12         true      false    ruby-buildpack-cflinuxfs3-v1.7.22.zip         cflinuxfs3\r\ndotnet_core_buildpack   13         true      false    dotnet-core-buildpack-cflinuxfs3-v2.1.4.zip   cflinuxfs3\r\nnodejs_buildpack        14         true      false    nodejs-buildpack-cflinuxfs3-v1.6.30.zip       cflinuxfs3\r\ngo_buildpack            15         true      false    go-buildpack-cflinuxfs3-v1.8.26.zip           cflinuxfs3\r\npython_buildpack        16         true      false    python-buildpack-cflinuxfs3-v1.6.20.zip       cflinuxfs3\r\nphp_buildpack           17         true      false    php-buildpack-cflinuxfs3-v4.3.59.zip          cflinuxfs3\r\nbinary_buildpack        18         true      false    binary-buildpack-cflinuxfs3-v1.0.25.zip       cflinuxfs3\r\n```\r\n\r\nThen I attempted to push an app:\r\n\r\n```\r\ncf push bug -b ruby_buildpack -b php_buildpack -s cflinuxfs3\r\n```\r\n\r\nThe push failed and said it was not able to find the `ruby_buildpack` I asked for.\r\n\r\n```\r\n{\r\n  \"errors\": [\r\n    {\r\n      \"code\": 10008,\r\n      \"detail\": \"Buildpack \\\"ruby_buildpack\\\" must be an existing admin buildpack or a valid git URI\",\r\n      \"title\": \"CF-UnprocessableEntity\"\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\nThe actual API request that CLI made omitted the stack so CC was falling back to the system default stack.\r\n\r\n```\r\nREQUEST: [2018-09-12T16:45:16-07:00]\r\nPATCH /v3/apps/0e48abcf-d260-4c5b-9ba2-2039e9a31a37 HTTP/1.1\r\nHost: api.plume-unicorn.capi.land\r\nAccept: application/json\r\nAuthorization: [PRIVATE DATA HIDDEN]\r\nContent-Type: application/json\r\nUser-Agent: cf/6.39.0+607d4f8be.2018-09-11 (go1.10.3; amd64 darwin)\r\n{\r\n  \"lifecycle\": {\r\n    \"data\": {\r\n      \"buildpacks\": [\r\n        \"ruby_buildpack\",\r\n        \"php_buildpack\"\r\n      ]\r\n    },\r\n    \"type\": \"buildpack\"\r\n  }\r\n}\r\n```\r\n\r\n**Expected behavior**\r\nI would have expected it to find and use the `cflinuxfs3` versions of the specified buildpacks to stage.\r\n\r\nI was able to get it to work with a manual curl like this:\r\n\r\n```\r\ncf curl /v3/apps/0e48abcf-d260-4c5b-9ba2-2039e9a31a37 -X PATCH -d '{\"lifecycle\": {\"data\": {\"buildpacks\": [\"ruby_buildpack\",\"php_buildpack\"], \"stack\": \"cflinuxfs3\"},\"type\": \"buildpack\"}}'\r\n```\r\n\r\n**To Reproduce**\r\nYou can pretty much follow the steps above, but to reiterate them (copy pasta'd from [CAPI #160325184](https://www.pivotaltracker.com/story/show/160325184)):\r\n\r\n1. Deploy an environment with the `cflinuxfs3` stack and `cflinuxfs3`-aware buildpacks: [add-cflinuxfs3.yml](https://github.com/cloudfoundry/cf-deployment/blob/release-candidate/operations/experimental/add-cflinuxfs3.yml).\r\n1. Rename or remove one of the `cflinuxfs2` builpacks for which there is a corresponding `cflinuxfs3` buildpack\r\n  1. `cf curl /v2/buildpacks?q:name=ruby_buildpack`\r\n  1. Find the one with `\"stack\": \"cflinuxfs2\"` and note its guid\r\n  1. `cf curl -X PUT /v2/buildpacks/<guid> -d '{\"name\": \"ruby_buildpack_backup\"}'` \r\n1. Attempt to push an application using multiple buildpacks (including `ruby_buildpack`) and stack `cflinuxfs3`: `cf push bug -b ruby_buildpack -b php_buildpack -s cflinuxfs3`\r\n1. This results in the error: `Buildpack \"ruby_buildpack\" must be an existing admin buildpack or a valid git URI`\r\n\r\n[See CAPI #160325184](https://www.pivotaltracker.com/story/show/160325184) for more information on repro steps.\r\n\r\n**Provide more context**\r\n- Mac OS X 10.13 iTerm\r\n- `6.39.0+607d4f8be.2018-09-11`\r\n- capi-release `1.68.0`\r\n"},"comment":{"url":"https://api.github.com/repos/cloudfoundry/cli/issues/comments/421218517","html_url":"https://github.com/cloudfoundry/cli/issues/1458#issuecomment-421218517","issue_url":"https://api.github.com/repos/cloudfoundry/cli/issues/1458","id":421218517,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTIxODUxNw==","user":{"login":"tcdowney","id":2096955,"node_id":"MDQ6VXNlcjIwOTY5NTU=","avatar_url":"https://avatars2.githubusercontent.com/u/2096955?v=4","gravatar_id":"","url":"https://api.github.com/users/tcdowney","html_url":"https://github.com/tcdowney","followers_url":"https://api.github.com/users/tcdowney/followers","following_url":"https://api.github.com/users/tcdowney/following{/other_user}","gists_url":"https://api.github.com/users/tcdowney/gists{/gist_id}","starred_url":"https://api.github.com/users/tcdowney/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcdowney/subscriptions","organizations_url":"https://api.github.com/users/tcdowney/orgs","repos_url":"https://api.github.com/users/tcdowney/repos","events_url":"https://api.github.com/users/tcdowney/events{/privacy}","received_events_url":"https://api.github.com/users/tcdowney/received_events","type":"User","site_admin":false},"created_at":"2018-09-14T03:17:35Z","updated_at":"2018-09-14T03:17:35Z","author_association":"MEMBER","body":"@tylerphelan I think I accidentally got my app in a weird state when I noticed that happen and got the app's stack set back to `cflinuxfs2`. As long as the CLI successfully sets the `stack` on the app itself it will behave as you described above because of this fallback:\r\n\r\nhttps://github.com/cloudfoundry/cloud_controller_ng/blob/ea0bf3387a069395377a9df0ef04cd29a482eb9b/lib/cloud_controller/diego/lifecycles/buildpack_lifecycle.rb#L39\r\n"}}
{"actor":{"display_login":"tcdowney"}}