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

reconstruct the content for newly committed image if compressed layers are missing #2297

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cardyok
Copy link

@cardyok cardyok commented Jun 13, 2023

implements #2295

@cardyok cardyok changed the title resume task before compressing new layer to decrease unavailable time reconstruct the content for newly committed image if compressed layers are missing Jun 13, 2023
@AkihiroSuda AkihiroSuda added this to the v1.5.0 milestone Jun 13, 2023
@cardyok cardyok changed the title reconstruct the content for newly committed image if compressed layers are missing [WIP] reconstruct the content for newly committed image if compressed layers are missing Jun 14, 2023
@cardyok cardyok force-pushed the reconstruct_content_for_missing_content branch from 1aa96b4 to 2a543a5 Compare June 14, 2023 01:50
@AkihiroSuda
Copy link
Member

Is this still WIP?

@cardyok
Copy link
Author

cardyok commented Jun 26, 2023

Is this still WIP?

yes, this pr includes 2 commits, current commit resumes container once upper layer finish committing to reduce the unavailable time for container
second commit includes reconstructing missing layers. Code has been finished and I am still locally testing, I think can be finished this week.

Signed-off-by: Cardy.Tang <zuniorone@gmail.com>
@cardyok cardyok force-pushed the reconstruct_content_for_missing_content branch from 2a543a5 to 02fe347 Compare June 27, 2023 13:09
if content is missing, compress and reconstruct it from unpacked data again

Signed-off-by: Cardy.Tang <zuniorone@gmail.com>
@cardyok cardyok changed the title [WIP] reconstruct the content for newly committed image if compressed layers are missing reconstruct the content for newly committed image if compressed layers are missing Jun 27, 2023
@cardyok
Copy link
Author

cardyok commented Jul 13, 2023

kindly ping @AkihiroSuda

@AkihiroSuda AkihiroSuda requested a review from ktock July 13, 2023 06:07
if !errdefs.IsNotFound(err) {
return fmt.Errorf("get layer %v failed: %w", layer.Digest.String(), err)
}
snapshotID := identity.ChainID(config.RootFS.DiffIDs[:i+1]).String()
Copy link
Member

Choose a reason for hiding this comment

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

Can we get the snapshot ID from the metadata store (e.g. containers.Container) rather than manually computing it here?

Copy link
Author

Choose a reason for hiding this comment

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

yea that works too. My concern is that since we are reconstructing layers (digest recorded in manifest is not found), we better rely on manifest/config which is image relevant instead of snapshotter plugin..

return fmt.Errorf("failed to compress layer for %v: %w", layer.Digest.String(), err)
}
if diffID != config.RootFS.DiffIDs[i] {
logrus.Infof("newly created Diff id %v does not match with diff id in config %v: %v", diffID, config.RootFS.DiffIDs[i], err)
Copy link
Member

Choose a reason for hiding this comment

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

This should be a warning. Also, it should be warned that the contents of the image has been changed by this diff computation.

Copy link
Author

@cardyok cardyok Jul 14, 2023

Choose a reason for hiding this comment

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

This func does not change content of the original image, it reconstructs the content for new image if original content is missing. So nothing is changed for original image consumers.

@ktock
Copy link
Member

ktock commented Jul 13, 2023

Could you add tests?

@cardyok
Copy link
Author

cardyok commented Jul 14, 2023

Could you add tests?

Sure thing! thx

@AkihiroSuda AkihiroSuda modified the milestones: v1.5.1, v1.5.2 Sep 11, 2023
@AkihiroSuda AkihiroSuda removed this from the v1.6.1 (tentative) milestone Oct 8, 2023
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

3 participants