gazebosim / gz-fuel-tools

A client library and command line tools for interacting with Gazebo Fuel servers.
https://gazebosim.org
Apache License 2.0
12 stars 20 forks source link

gz fuel download returns 0, even when the download failed #349

Open dHofmeister opened 1 year ago

dHofmeister commented 1 year ago

Environment

Description

root@user-desktop:/gazebo# gz fuel download --url https://fuel.gazebosim.org/1.0/openrobotics/models/sydney_regatta
[Err] [FuelClient.cc:677] Failed to download model.
  Server: https://fuel.gazebosim.org
  Route: openrobotics/models/sydney_regatta/tip/sydney_regatta.zip
  REST response code: 504
Download failed.
root@user-desktop:/gazebo# echo $?
0

It would be nice to have a non-zero return code in the terminal, as it would make error handling and catching easier.

Greetings

M1chaelM commented 1 year ago

This bug is particularly bad when working with Docker images. Since resources are not typically downloaded and cached until the first time they are needed, users running gz sim commands from a Docker image have to download everything from fuel every time unless they use gz fuel download to build the cache into the image. However, Docker relies on the error code to determine whether a step in its build process has succeeded. So when gz fuel download returns 0 even though it has failed, the result is that Docker does not detect the error, and bakes the failed download into the image.

If the user is not actively reading the console output they will think they've cached the resource when they haven't. Further, to fix the problem, the user will have to manually add a cache-bust argument to the appropriate spot in the Dockerfile, since Docker has no way of knowing which layer to start from.