CF enable-service-access fails when already exists
- Command
cf enable-service-access myservice myorg - What occurred, incl. error and/or stack trace Exits with error code 1 when already exists
- What you expected to occur Because it already exists, the command has in fact succeeded, not failed
- CLI Version
6.21.1 - CC API Endpoint Version
2.57.0 - Platform & Shell Details
All - Any other relevant information
cf commands need to be idempotent and work as expected, current work around is we disable all prior to enabling otherwise we cannot reasonably check bash errors
Hi @sharms
What flags and arguments are you passing in to the command?
Can you attach the output of running the command with the -v option?
I can't reproduce the issue:
D:\Users\koperd\Downloads\bin>cf enable-service-access dummy-dev -o dies-test
Enabling access to all plans of service dummy-dev for the org dies-test as admin...
OK
D:\Users\koperd\Downloads\bin>cf enable-service-access dummy-dev -o dies-test
Enabling access to all plans of service dummy-dev for the org dies-test as admin...
OK
D:\Users\koperd\Downloads\bin>echo %ERRORLEVEL%
0
Closing. Feel free to reopen or submit a new issue if you can help us reproduce it.
jmcarp@Joshuas-MBP-3|~/code
) cf --version
cf version 6.21.1+6fd3c9f-2016-08-10
jmcarp@Joshuas-MBP-3|~/code
) cf enable-service-access mysql56-multinode -p persistent -o cloud-gov
Enabling access to plan persistent of service mysql56-multinode for org cloud-gov as services...
OK
jmcarp@Joshuas-MBP-3|~/code
) cf enable-service-access mysql56-multinode -p persistent -o cloud-gov
Enabling access to plan persistent of service mysql56-multinode for org cloud-gov as services...
FAILED
Server error, status code: 400, error code: 260002, message: This combination of ServicePlan and Organization is already taken: organization_id and service_plan_id unique
-> [1]
@dkoper: the snippet above should reproduce the error on the latest cli version. Can you reopen this?
Ping @dkoper
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/130226793
The labels on this github issue will be updated when the story is started.
@SocalNick Is this expected API output? I believe other CC APIs are idempotent and may at most return a warning?
I cannot reproduce. Can you tell us how the mysql56-multinode service offering was created?
$ cf --version
cf version 6.22.1+6b7af9c-2016-09-24
$ cf enable-service-access fake-service-a64c0e1b-0595-4e5c-bcd0-4abe8310b132 -o nick
Enabling access to all plans of service fake-service-a64c0e1b-0595-4e5c-bcd0-4abe8310b132 for the org nick as admin...
OK
$ cf enable-service-access fake-service-a64c0e1b-0595-4e5c-bcd0-4abe8310b132 -o nick
Enabling access to all plans of service fake-service-a64c0e1b-0595-4e5c-bcd0-4abe8310b132 for the org nick as admin...
OK
$ cf enable-service-access fake-service-a64c0e1b-0595-4e5c-bcd0-4abe8310b132 -o nick -p fake-plan
Enabling access to plan fake-plan of service fake-service-a64c0e1b-0595-4e5c-bcd0-4abe8310b132 for org nick as admin...
OK
$ cf enable-service-access fake-service-a64c0e1b-0595-4e5c-bcd0-4abe8310b132 -o nick -p fake-plan
Enabling access to plan fake-plan of service fake-service-a64c0e1b-0595-4e5c-bcd0-4abe8310b132 for org nick as admin...
OK
I have the issue as well. Why not just return 200 OK ?
` REQUEST: [2016-11-30T11:20:59+08:00] POST /v2/service_plan_visibilities HTTP/1.1 Host: .... Accept: application/json Authorization: [PRIVATE DATA HIDDEN] Connection: close Content-Type: application/json User-Agent: go-cli 6.22.1+6b7af9c / darwin
{"service_plan_guid":"f0613dcf-4d5b-4867-9d54-52f6a5919884", "organization_guid":"8a8610e1-ada4-4607-8f0a-d81f4b71cc94"}
RESPONSE: [2016-11-30T11:21:02+08:00] HTTP/1.1 400 Bad Request Connection: close Transfer-Encoding: chunked Content-Type: application/json Date: Wed, 30 Nov 2016 03:21:00 GMT Server: nginx X-Backside-Transport: FAIL FAIL X-Content-Type-Options: nosniff X-Global-Transaction-Id: 16543521
d0 { "code": 260002, "description": "This combination of ServicePlan and Organization is already taken: organization_id and service_plan_id unique", "error_code": "CF-ServicePlanVisibilityAlreadyExists" }
0
FAILED Server error, status code: 400, error code: 260002, message: This combination of ServicePlan and Organization is already taken: organization_id and service_plan_id unique `
Hi all,
I apologize, my reproduction attempt before wasn't valid. I was able to reproduce and I believe the API is responding appropriately. HTTP POST is not considered to be an idempotent operation. The relationship between service plan and organization already exists, so 400 is appropriate.
Yes, that is why this issue is filed under cli - while POST is not idempotent, I don't see why it wouldn't use PUT, furthermore I don't think the cf command should ever return an error to configure a service correctly which is configured correctly.
CLI could potentially look for existing visibility using GET /v2/service_plan_visibilities?q=organization_guid:<org_guid>&q=service_plan_guid:<service_plan_guid> before doing the POST.
Yes, agree. The cli should check the existing visibility with GET first, then return OK if the relationship is here. Another sample in cli is :
$cf create-service
In this implementation, cli do "get" services first, and return 0 when it exists
+1 ran into this issue recently as well and would love to idempotently enable-service-access.
Is this still in progress? I'd love to have an easy way to make sure in a script that a service is available for an org....
Hi @holgero thanks for reaching out. We still plan on reviewing this issue once we've had a chance to rewrite this command. We hope the rewrite will fix the issue but it does not, we will look into it separately. Thanks.
Hi,everyone: Execute command times following error. How do I fix it?
cf enable-service-access bookstore -o CrazyJvm-Org Enabling access to all plans of service bookstore for the org CrazyJvm-Org as [email protected]... Service Plan Visibility is invalid: service_plan is from a private broker FAILED
cf version 6.41.0+dd4c76cdd.2018-11-28
Hi @icodelabs - looks like you're trying to enable service access to a plan that's offered by a space-scoped broker, which isn't allowed. Space-scoped brokers can only expose their service offerings to the space to which they are scoped.
This area of code has been refactored. From looking through the code, it appears this bug would still occur, but we didn't get a chance to actually try repro-ing it.
@abbyachau I think we can pull this into our backlog (or SAPI can pull into theirs if they prefer to work on it @laurzca @williammartin ).
We're going to pull this into SAPI's backlog. Thanks!