cloudfoundry / cli

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

parallel invocation of cf oauth-token sporadically leads to io errors #2989

Closed rlindner81 closed 3 months ago

rlindner81 commented 3 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 Provide details on what you were trying to do (and why).

I use cf-cli implicitly in other scripts that do more heavy duty work and these often run in parallel. For even low levels of concurrency, like 5--10 you sporadically see errors of the type:

error: caught error during cf oauth-token
non-zero return code 1
FAILED
Error read/writing config:  remove HOME/.cf/temp-config2869106190: no such file or directory

error: caught error during cf oauth-token
non-zero return code 1
FAILED
Error read/writing config:  remove HOME/.cf/temp-config2869106190: no such file or directory

The error occurs more reliably with more concurrency. For 16 or 20 parallel executions it happens every time on my machine. I suspect the temp filename generator is tied to something that doesn't handle parallel execution well, like a low-resolution timestamp.

What happened A clear and concise description of what happened.

See above.

Expected behavior A clear and concise description of what you expected to happen.

IMO there is no reason cf oauth-token should not work for, say 20 processes running in parallel.

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

I wrote a simple bash script to produce:

#!/bin/sh

concurrency=16
process_ids=()

for ((i = 0; i < concurrency; i++)); do
  cf oauth-token >/dev/null &
  process_ids+=($!)
done

wait "${process_ids[@]}"

Provide more context

Notes regarding V6 and V7 CLI support:

Samze commented 3 months ago

Hey @rlindner81

This should be fixed in the next version. See https://github.com/cloudfoundry/cli/pull/2931.

rlindner81 commented 3 months ago

Hey @rlindner81

This should be fixed in the next version. See #2931.

Yes that issue and fix look good. Sorry for double posting, I had not seen this one...