Skip to content

Fix 'ocitool push' for oci_images based on other oci_images - #141

Merged
BryceBeagle merged 1 commit into
mainfrom
bryce.beagle/fix-ocitool-push-for-layered-rules_oci-images
Sep 9, 2026
Merged

BryceBeagle merged 1 commit into
mainfrom
bryce.beagle/fix-ocitool-push-for-layered-rules_oci-images

Conversation

@BryceBeagle

Copy link
Copy Markdown
Contributor

There's been a bug in the OCILayout implementation where it did not
contain the correct metadata for pushing an oci_image where the base
is another oci_image.

The way rules_oci works is it build each blob in the bazel build dir,
and then creates a blob -> path mapping called blob_index that is used
at push time.

The previous implementation naively assumed that an image would only
ever have one blob_index map, but this isn't the case. Every image has
one for itself and its base(s).

This hasn't been an issue because the push operation short-circuits: if
a blob is already in the registry, it doesn't try to push the blob
again. If it doesn't try to push the blob, it doesn't try to find the
blob in the blob_index.

This was fine because until now all bases for images we had been using
were "remote" ones (i.e. already pushed to the registry). But I'm trying
to create an oci_image target that bases itself on another in-repo
oci_image target.

In this case, the base's blobs aren't in the registry, the push
operation tries to push them, and then freaks out because the
blob_index doesn't have the metadata.

This PR fixes this so that blob_index is turned into
direct_blob_index (for the current image) and
transitive_blob_indices, a superset that also includes the index/es
for the base.

These indices are then all provided to the push tool, we can properly
find the blobs at push time.

There's been a bug in the `OCILayout` implementation where it did not
contain the correct metadata for pushing an `oci_image` where the base
is another `oci_image`.

The way `rules_oci` works is it build each blob in the bazel build dir,
and then creates a blob -> path mapping called `blob_index` that is used
at push time.

The previous implementation naively assumed that an image would only
ever have one `blob_index` map, but this isn't the case. Every image has
one for itself and its base(s).

This hasn't been an issue because the push operation short-circuits: if
a blob is already in the registry, it doesn't try to push the blob
again. If it doesn't try to push the blob, it doesn't try to find the
blob in the `blob_index`.

This was fine because until now all `base`s for images we had been using
were "remote" ones (i.e. already pushed to the registry). But I'm trying
to create an `oci_image` target that bases itself on another in-repo
`oci_image` target.

In this case, the base's blobs _aren't_ in the registry, the push
operation tries to push them, and then freaks out because the
`blob_index` doesn't have the metadata.

This PR fixes this so that `blob_index` is turned into
`direct_blob_index` (for the current image) and
`transitive_blob_indices`, a superset that also includes the index/es
for the base.

These indices are then _all_ provided to the push tool, we can properly
find the blobs at push time.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@BryceBeagle
BryceBeagle marked this pull request as ready for review September 9, 2026 12:30
@BryceBeagle

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Sep 9, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-09-09 13:48:41 UTC ℹ️ Start processing command /merge


2026-09-09 13:48:47 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in main is approximately 0s (p90).


2026-09-09 14:06:51 UTC ⚠️ MergeQueue: This merge request build was cancelled

bryce.beagle@datadoghq.com cancelled this merge request build

@BryceBeagle
BryceBeagle merged commit c030beb into main Sep 9, 2026
2 of 3 checks passed
@BryceBeagle
BryceBeagle deleted the bryce.beagle/fix-ocitool-push-for-layered-rules_oci-images branch September 9, 2026 14:07
BryceBeagle added a commit that referenced this pull request Sep 9, 2026
…pport (#142)

#141 forgot to add the new files to the runfiles... oops.

This breaks at build time with the following error:
```
failed to load layout (../python_3_12_8/layout.layout.json):
couldn't open index: open ../python_3_12_8/layout.layout.json: no such file or directory
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants