feat: Track and emit per-layer history annotations#454
Conversation
Previously there was some support for tracking history from non-bazel defined layers. This PR expands that to automatically add history from layer targets. We write that history out to a new file and then used that in img_tool to add it to the final image spec. I'm not sure if this is better or worse than trying to track the history information in each per-layer file.
|
For context, I was working with another tool that requires each layer have a valid history entry, which I don't think is required by the OCI spec, but the changes to rules_img seemed small enough that I've just been carrying the patch internally. I'm not 100% sure if using a separate history file is better than tracking a per-layer history attribute. I'm also not sure if this should be the default behavior since it does embed the bazel target into the metadata. |
|
That looks good to me, but I'd like to see at least one test for this in tests/img_toolchain/testcases. You can create a new one or extend an existing one. The important thing is to check the digest of the generated config given a history.json. As an aside: I believe users may wish to control the history message at some point, but that is an additional feature to be added if (and only if) someone actually needs it. |
|
@malt3 Thanks for the feedback! I've updated one of the manifest test cases to use the new flag, and changed the hashes to match the new expected output. |
|
During the merge queue, one of the integration tests failed with: something is not up do dockers standards I think. https://github.com/bazel-contrib/rules_img/actions/runs/24441866086/job/71408550535 probably hitting this: https://github.com/moby/moby/blob/f4825907aeb98d634ab238234ee3abfb77449b07/daemon/images/image_history.go#L36 |
|
I think we need to track the history from base images specially. Right now we add the history from pulled images twice:
|
|
Maybe it would be better if we tracked history as part of each layer. rules_img/img/private/import.bzl Line 53 in 898ae50 In the image_layer rule, we emit the history for the current layer. This also opens up the path to customize the history in the future. The history belongs into the "metadata" file of the LayerInfo provider. |
|
hm yeah, let me go back to the drawing board on this and see if I can make docker happy |
|
Superseded by #568 |
Previously there was some support for tracking history from non-bazel defined layers. This PR expands that to automatically add history from all bazel layer targets.
We write that history out to a new file and then used that in img_tool to add it to the final image spec.