scrapinghub / shub

Scrapinghub Command Line Client
https://shub.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
125 stars 80 forks source link

Fail to find built image in a none Git initialized directory #362

Open tebesfinwo opened 5 years ago

tebesfinwo commented 5 years ago

If shub image push without an explicit versioning in a non Git intialized directory, shub fails to find the previously built image because I believed that it used the wrong version as shown in the following output.

$ shub image build foo
Building images.scrapinghub.com/project/xxx:1565968870.
Steps: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8
The image images.scrapinghub.com/project/xxx:1565968870 build is completed.
$ shub image push foo
Error: The image doesn't exist yet, please use build command at first.

$ shub image upload foo
Building images.scrapinghub.com/project/xxx:1565968989.
Steps: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8/8
The image images.scrapinghub.com/project/xxx:1565968989 build is completed.
Login to images.scrapinghub.com succeeded.
Pushing images.scrapinghub.com/project/xxx:1565968994 to the registry.
Layers:   0%|                                                                                                                                                                                                                            | 0/1
Error tag does not exist: images.scrapinghub.com/project/xxx:1565968994: {'message': 'tag does not exist: images.scrapinghub.com/project/xxx:1565968994'}
Error: Docker operation failed
vshlapakov commented 5 years ago

The reason is the function responsible for getting a version tag based on the existing files: it checks for any known VCS, and as a fallback uses current timestamp, which is obviously different for different commands. There's an easy work-around if you don't want to use any VCS - you can provide a version via setup.py file, or pass it explicitly for each command, this will work as expected:

$ shub image build foo -V version
$ shub image upload foo -V version   # or --version version

However, I must admit it's still a bug, I'd expect shub image upload to use the same version within all its sub-commands.

tebesfinwo commented 5 years ago

@vshlapakov Thanks for the explanation and workaround. 👍