Skip to content

[1.7] Unpacks should check and do fetch if content not present in all cases - #8877

Closed
skaegi wants to merge 1 commit into
containerd:release/1.7from
skaegi:release/1.7
Closed

skaegi wants to merge 1 commit into
containerd:release/1.7from
skaegi:release/1.7

Conversation

@skaegi

@skaegi skaegi commented Jul 26, 2023

Copy link
Copy Markdown
Contributor

This patch adds an additional check in the unpack logic to "always" fetch the content if not present. This handles a case that can lead to incomplete images (images that have the RootFs in the snapshot but have a different digest in their oci config) and prevent snapshotters other than the default from working.

In terms of code changes...

  1. extracts doFetchFn from existing fetch logic and pulls it up above doUnpackFn
  2. In do UnpackFn, after the sn.Stat check we also check cs.Info and if not found will call doFetchFn.
  3. Existing fetch logic later in UnpackFn is unchanged but instead called via doFetchFn.

Fixes #8674

Signed-off-by: Simon Kaegi [email protected]

@k8s-ci-robot

Copy link
Copy Markdown

Hi @skaegi. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@skaegi

skaegi commented Jul 26, 2023 •

Copy link
Copy Markdown
Contributor Author

I recognize this is on release/1.7 -- I can delete this PR and recreate a new one on main but was hoping for feedback.

Another possibility here is to always do the content check and fetch before the sn.Stat check and then remove the later fetch.

e.g.

if _, err := cs.Info(ctx, desc.Digest); err != nil {
	if errdefs.IsNotFound(err) {
		return doFetchFn(i)
	} else {
		return fmt.Errorf("failed to get content info %s: %w", desc.Digest.String(), err)
	}
}

if _, err := sn.Stat(ctx, chainID); err == nil {
	// no need to handle
	return nil
} else if !errdefs.IsNotFound(err) {
	return fmt.Errorf("failed to stat snapshot %s: %w", chainID, err)
}

@skaegi skaegi changed the title Unpacks should check and do fetch if content not present in all cases [1.7] Unpacks should check and do fetch if content not present in all cases Jul 26, 2023
This patch...
1) creates doFetchFn from existing fetch logic.
2) After the sn.Stat check we also check cs.Info and if not found will call doFetchFn.
3) Existing fetch later in this function is unchanged but instead calls doFetchFn.

Signed-off-by: Simon Kaegi [email protected]
@skaegi

skaegi commented Jul 26, 2023

Copy link
Copy Markdown
Contributor Author

Closing -- using #8878 instead as it is on main and easier to work with.

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