Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop caching encrypted layers in docker destination #1314

Closed
wants to merge 1 commit into from

Conversation

hshiina
Copy link

@hshiina hshiina commented Jul 26, 2021

In a case where a non-encrypted images is committed to a registry after
an encrypted image is committed, this library may try to reuse
encrypted layers for the non-encrypted images if the images have common
layers. When the non-encrypted image is committed, there is no
information to recognize that cached layers are encrypted. As a result,
the non-encrypted image has encrypted layers unexpectedly in the
registry. This causes an error when the non-encrypted image is pulled
from the registry.

To avoid reusing encrypted layers for another image, this change stops
caching a layer if it is encrypted.

Signed-off-by: Hironori Shiina shiina.hironori@jp.fujitsu.com

In a case where a non-encrypted images is committed to a registry after
an encrypted image is committed, this library may try to reuse
encrypted layers for the non-encrypted images if the images have common
layers. When the non-encrypted image is committed, there is no
information to recognize that cached layers are encrypted. As a result,
the non-encrypted image has encrypted layers unexpectedly in the
registry. This causes an error when the non-encrypted image is pulled
from the registry.

To avoid reusing encrypted layers for another image, this change stops
caching a layer if it is encrypted.

Signed-off-by: Hironori Shiina <shiina.hironori@jp.fujitsu.com>
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

Targeting RecordKnownLocation like this seems unlikely to be correct

  • As a trivial matter, RecordKnownLocation is called elsewhere for other reasons; e.g. just copying an encrypted image from one registry to another can create a record, so this fix doesn’t work.
  • Layer reuse can happen without a RecordKnownLocation at all.
  • It’s awkward for the transport to deal with this; this should be handled in the transport-independent copy logic, somehow.
  • Conceptually, the location record is not the issue at all; we want to avoid the reuse of encrypted layers when the original is not encrypted (or differently-encrypted); i.e. the issue is the digest/uncompressed-digest associations don’t record the information.

@mtrmac
Copy link
Collaborator

mtrmac commented Jul 26, 2021

we want to avoid the reuse of encrypted layers when the original is not encrypted (or differently-encrypted); i.e. the issue is the digest/uncompressed-digest associations don’t record the information.

E.g. consider what happens when an already-encrypted image is copied to a registry (which does not trigger this code path at all); and then is copied decrypting it, into a docker-archive: destination; that might create a digest/uncompressed record as well, and a known location. Copying the same image back into the same repo could again trigger reuse.

I haven’t really thought about how to actually cleanly fix this yet, though, I’m afraid.

@mtrmac
Copy link
Collaborator

mtrmac commented Apr 27, 2022

I haven’t really thought about how to actually cleanly fix this yet, though, I’m afraid.

#1533 is probably not the most accurate logic possible, but it at least seems to conservatively avoid the problematic layer reuse (after one-time manual removal of the blob info cache).

@mtrmac
Copy link
Collaborator

mtrmac commented May 2, 2022

#1533 was merged, and is effectively a superset of this PR. Thanks!

@mtrmac mtrmac closed this May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants