Skip to content

cf push with multiple buildpacks / non-default stack specified does not work #1458

@tcdowney

Description

@tcdowney

Please fill out the issue checklist below and provide ALL the requested information.

  • I tried updating to the latest version of the CF CLI to see if it fixed my problem.
  • I attempted to run the command with CF_TRACE=1 to help debug the issue.
  • I am reporting a bug that others will be able to reproduce.

Describe the bug and the command you saw an issue with
This behavior was reported to CAPI last week. A user was trying to push an app using multiple buildpacks with a specific stack.

Example:

cf push bug -b ruby_buildpack -b php_buildpack -s cflinuxfs3

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.

See CAPI #160325184 for more information.

What happened
To get this to fail in a more obvious way, I first had to remove/rename the cflinuxfs2 Ruby buildpack:

  1. cf curl /v2/buildpacks?q:name=ruby_buildpack
  2. Find the one with "stack": "cflinuxfs2" and note its guid
  3. cf curl -X PUT /v2/buildpacks/<guid> -d '{"name": "ruby_buildpack_backup"}'

My installed buildpacks now looked like this:

cf buildpacks
Getting buildpacks...

buildpack               position   enabled   locked   filename                                      stack
staticfile_buildpack    1          true      false    staticfile-buildpack-cflinuxfs2-v1.4.31.zip   cflinuxfs2
java_buildpack          2          true      false    java-buildpack-cflinuxfs2-v4.15.zip           cflinuxfs2
ruby_buildpack_backup   3          true      false    ruby-buildpack-cflinuxfs2-v1.7.22.zip         cflinuxfs2
dotnet_core_buildpack   4          true      false    dotnet-core-buildpack-cflinuxfs2-v2.1.4.zip   cflinuxfs2
nodejs_buildpack        5          true      false    nodejs-buildpack-cflinuxfs2-v1.6.30.zip       cflinuxfs2
go_buildpack            6          true      false    go-buildpack-cflinuxfs2-v1.8.26.zip           cflinuxfs2
python_buildpack        7          true      false    python-buildpack-cflinuxfs2-v1.6.20.zip       cflinuxfs2
php_buildpack           8          true      false    php-buildpack-cflinuxfs2-v4.3.59.zip          cflinuxfs2
binary_buildpack        9          true      false    binary-buildpack-cflinuxfs2-v1.0.25.zip       cflinuxfs2
staticfile_buildpack    10         true      false    staticfile-buildpack-cflinuxfs3-v1.4.31.zip   cflinuxfs3
java_buildpack          11         true      false    java-buildpack-cflinuxfs3-v4.15.zip           cflinuxfs3
ruby_buildpack          12         true      false    ruby-buildpack-cflinuxfs3-v1.7.22.zip         cflinuxfs3
dotnet_core_buildpack   13         true      false    dotnet-core-buildpack-cflinuxfs3-v2.1.4.zip   cflinuxfs3
nodejs_buildpack        14         true      false    nodejs-buildpack-cflinuxfs3-v1.6.30.zip       cflinuxfs3
go_buildpack            15         true      false    go-buildpack-cflinuxfs3-v1.8.26.zip           cflinuxfs3
python_buildpack        16         true      false    python-buildpack-cflinuxfs3-v1.6.20.zip       cflinuxfs3
php_buildpack           17         true      false    php-buildpack-cflinuxfs3-v4.3.59.zip          cflinuxfs3
binary_buildpack        18         true      false    binary-buildpack-cflinuxfs3-v1.0.25.zip       cflinuxfs3

Then I attempted to push an app:

cf push bug -b ruby_buildpack -b php_buildpack -s cflinuxfs3

The push failed and said it was not able to find the ruby_buildpack I asked for.

{
  "errors": [
    {
      "code": 10008,
      "detail": "Buildpack \"ruby_buildpack\" must be an existing admin buildpack or a valid git URI",
      "title": "CF-UnprocessableEntity"
    }
  ]
}

The actual API request that CLI made omitted the stack so CC was falling back to the system default stack.

REQUEST: [2018-09-12T16:45:16-07:00]
PATCH /v3/apps/0e48abcf-d260-4c5b-9ba2-2039e9a31a37 HTTP/1.1
Host: api.plume-unicorn.capi.land
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Content-Type: application/json
User-Agent: cf/6.39.0+607d4f8be.2018-09-11 (go1.10.3; amd64 darwin)
{
  "lifecycle": {
    "data": {
      "buildpacks": [
        "ruby_buildpack",
        "php_buildpack"
      ]
    },
    "type": "buildpack"
  }
}

Expected behavior
I would have expected it to find and use the cflinuxfs3 versions of the specified buildpacks to stage.

I was able to get it to work with a manual curl like this:

cf curl /v3/apps/0e48abcf-d260-4c5b-9ba2-2039e9a31a37 -X PATCH -d '{"lifecycle": {"data": {"buildpacks": ["ruby_buildpack","php_buildpack"], "stack": "cflinuxfs3"},"type": "buildpack"}}'

To Reproduce
You can pretty much follow the steps above, but to reiterate them (copy pasta'd from CAPI #160325184):

  1. Deploy an environment with the cflinuxfs3 stack and cflinuxfs3-aware buildpacks: add-cflinuxfs3.yml.
  2. Rename or remove one of the cflinuxfs2 builpacks for which there is a corresponding cflinuxfs3 buildpack
  3. cf curl /v2/buildpacks?q:name=ruby_buildpack
  4. Find the one with "stack": "cflinuxfs2" and note its guid
  5. cf curl -X PUT /v2/buildpacks/<guid> -d '{"name": "ruby_buildpack_backup"}'
  6. 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
  7. This results in the error: Buildpack "ruby_buildpack" must be an existing admin buildpack or a valid git URI

See CAPI #160325184 for more information on repro steps.

Provide more context

  • Mac OS X 10.13 iTerm
  • 6.39.0+607d4f8be.2018-09-11
  • capi-release 1.68.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions