linode-cli
linode-cli copied to clipboard
Non-zero return value
When using an old version of the cli, you get the message below. However it exits with 0 (success). It should return a non-zero value.
The API responded with version 4.80.0, which is newer than the CLI's version of 4.76.1. Please update the CLI to get access to the newest features. You can update with a simple pip install --upgrade linode-cli
I'm seeing this message too. I think it can be suppressed with the --suppress-warnings
flag. I think the current behavior is correct: the command should return 0 or non-0 according to whether the command succeeded or failed, not according to whether the API version was slightly behind. Otherwise, scripts would break whenever Linode pushes a new API version to their servers.
However, I think this issue raises a point that perhaps there should be something like a linode-cli is-cli-latest-api
command which would check the API version used on the server and return 0 or 1 if the CLI is using the latest API version.
This is working as intended; the CLI exits with 0 if the command you attempted to run succeeds - the message about the API version is intended to prompt interactive users to upgrade the CLI, and can be disabled with --suppress-warnings
. If it exited with a non-zero code in those cases, scripts running passively may break if the API updated its version while they were running, which would be a hinderance to many CLI users.
I've got nothing against a command that exits with an error if the CLI isn't up to date if that's useful. I could envision a script that automatically updates the CLI in those cases, although personally, despite the CLI's relative stability, I wouldn't do automatic upgrades of it if it was running something unsupervised.
Let me give you more context. I have a cron job that's doing a SSL certificate update once a week.
linode-cli nodebalancers config-update ...
The command was failing to do the certificate update because I was using an old version of the CLI. I would get the message asking me to upgrade and the command did not perform the certificate update as requested. From my script point of view the operation looked successful because the command exited with 0. A non zero exit value would have warned me that something was not working.
That's not something I'd expect to see happening. If you don't mind my asking, in what way was it failing to update the certificate? If the operation the CLI performs fails, it should exit with a non-zero status code, so I think that in any case the fact that the CLI was exiting with status 0 after failing to do something is a problem, and i'd like to make sure that doesn't happen.
Instead of updating the certificate, it would do nothing and just display the "you have to update" message. And it would exit with 0.
Command executed:
linode-cli nodebalancers config-update 1234 1234 --ssl_cert /path/to/file.pem --ssl_key /path/to/file.pem
Flagged as "won't do".