cloudfoundry / cli

The official command line client for Cloud Foundry
https://docs.cloudfoundry.org/cf-cli
Apache License 2.0
1.75k stars 926 forks source link

cf share-service fails with exit code 1 if it is already shared #2669

Open svenXY opened 10 months ago

svenXY commented 10 months ago

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

Describe the bug and the command you saw an issue with

With cf cli v8, the command cf share-service srv-name -o org -s space fails (FAILED) and exits with 1 if the service is already shared with the org/space

Until recently, it just reported that it is already shared (OK) and ended with exitcode 0.

Looking at other cli commands like e.g. cf create-service, I'm under he impression that for idempotence reasons, commands that would only try to produce a state that already exists should not fail.

What happened

Gitlab pipelines fail all of a sudden due to new version of cf cli tools

Expected behavior

Pipelines should continue to work. If failing is going to be the new behaviou (to which I'd highly disagree!), it should at least be mentioned in the documentation (that does not make any mention of exit codes at all). Furthermore, there is no possibility to find out if a sharing is already in place except by grepping the output of cf service...

Exact Steps To Reproduce Steps to reproduce the behavior; include the exact CLI commands and verbose output:

  1. Run cf share-service srv-name -o org -s space on a service that is already shared with the named org/space
  2. See error
svenXY commented 10 months ago
RESPONSE: [2023-11-20T15:53:35+01:00]
HTTP/1.1 422 Unprocessable Entity
Content-Type: application/json; charset=utf-8
Date: Mon, 20 Nov 2023 14:53:35 GMT
Referrer-Policy: strict-origin-when-cross-origin
Server: nginx
Vary: Accept
X-B3-Spanid: 533b6174dda84c69
X-B3-Traceid: 3642895499764d5d533b6174dda84c69
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Runtime: 0.051301
X-Vcap-Request-Id: 36428954-9976-4d5d-533b-6174dda84c69::6c4c873b-d255-4110-a1e1-aa02b9c3c17d
X-Xss-Protection: 1; mode=block
{
  "errors": [
    {
      "code": 10008,
      "detail": "A service instance called wac-redis-rls has already been shared with cheba-public.",
      "title": "CF-UnprocessableEntity"
    }
  ]
}

A service instance called wac-redis-rls has already been shared with cheba-public.
FAILED
JakobFels commented 10 months ago

It seems like a similar issue was fixed for create-service in v8.3.0 https://github.com/cloudfoundry/cli/commit/2b4e14408be4e571fdb95ebbf4065433c5f10efe