OPM index add and registry add with binary image option adds new layers with the index content
Adding bundles to an index using the --binary image option, new layers are added, increasing the size of the images exponentially. This only does not happen if the binary image does not have any layer with a database or an FBC catalog content. (this scenario is valid for FBC and SQL indexes formats).
Note that the layer added will have the new bundle. But the previous layer with the database or FBC content is not removed:
Following the commands where this scenario can be faced.
For SQLite
opm index add --enable-alpha --generate --bundles <bundle> --binary-image <binary-image> --from-index <index-mage>
For FBC
opm registry add --database <database> --enable-alpha --bundle-images <budlle> --overwrite-latest
opm migrate <index.db> <path>
opm alpha generate dockerfile <path>. --binary-image <binnary-image>
How to reproduce:
- Check the image layers
- Add the bundle using the binary image with a database or an FBC catalog content
- docker save -o test.tar
- open the test.tar and check the content layers
c/c @joelanford wdyt?
@camilamacedo86 What image is being used for <binary-image> in these scenarios? I would expect that to be the base opm image that does not include any catalog content.
@camilamacedo86 is there any additional information for this issue?
Hi @exdx,
We discuss this topic. The convoy is that the binary image field should not be used with existing/populated index images. It should just be the base opm image.
By default, that base image is the upstream quay.io/operator-framework/opm:latest image: https://github.com/operator-framework/operator-registry/blob/5566e4b6832a7fc08c12d3c79fc0a0b8c6a2e7aa/pkg/containertools/dockerfilegenerator.go#L11
See that:
- The --binary-image flag is set to base image here: https://github.com/operator-framework/operator-registry/blob/5566e4b6832a7fc08c12d3c79fc0a0b8c6a2e7aa/cmd/opm/generate/cmd.go#L85
- And then that base image is used in the dockerfile as the FROM image here: https://github.com/operator-framework/operator-registry/blob/5566e4b6832a7fc08c12d3c79fc0a0b8c6a2e7aa/alpha/action/generate_dockerfile.go#L44
So, it shows that what we could do here is just try to improve the help to clarifies it:
https://github.com/operator-framework/operator-registry/blob/5566e4b6832a7fc08c12d3c79fc0a0b8c6a2e7aa/cmd/opm/generate/cmd.go#L85