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

feat: create manifest.wall #142

Merged
merged 88 commits into from
Sep 30, 2024
Merged

Conversation

letFunny
Copy link
Collaborator

@letFunny letFunny commented Jul 1, 2024

This commit adds support for the creation of the manifest.wall file. The manifest file(s) are generated at the specified paths, marked with the "generate: manifest" keyword. The files are ZSTD compressed and have the basename "manifest.wall". The format of the Chisel DB follows the RK009 spec.

  • Have you signed the CLA?

This commit adds support for the creation of the manifest.wall file. The
manifest file(s) are generated at the specified paths, marked with the
"generate: manifest" keyword. The files are ZSTD compressed and have the
basename "chisel.db". The format of the Chisel DB follows the RK009
spec.

Co-authored-by: Rafid Bin Mostofa <rafid.mostofa@canonical.com>
Copy link
Member

@rebornplusplus rebornplusplus left a comment

Choose a reason for hiding this comment

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

Looks quite nice to me! Thank you.

internal/manifest/manifest.go Outdated Show resolved Hide resolved
letFunny and others added 2 commits July 2, 2024 10:44
Co-authored-by: Rafid Bin Mostofa <rafid.mostofa@canonical.com>
@letFunny letFunny added the Blocked Waiting for something external label Jul 2, 2024
@letFunny
Copy link
Collaborator Author

letFunny commented Jul 2, 2024

After the meeting we agreed to split the PR into 2 that could go in in parallel and one last one. The downside is that we can no longer see the full picture at once, but we have discussed it enough that it is not needed.

Depends on #143 and #144.

@letFunny letFunny removed the Blocked Waiting for something external label Sep 26, 2024
Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Thanks Alberto. Final details below.

targetDir string
}

func generateManifests(options *generateManifestsOptions) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

The earlier comment was about generateManifest itself, not just LocateManifestSlices. Per earlier thread, that's also why I was mentioning that the testing of what is in here can be done in the manifest, so we don't need to involve the slicer on everything.

internal/archive/archive.go Show resolved Hide resolved
internal/manifest/report.go Outdated Show resolved Hide resolved
Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Much better, but still one pass to go I think. Details below:

internal/manifest/report.go Outdated Show resolved Hide resolved
internal/manifest/report_test.go Show resolved Hide resolved
internal/manifest/manifest.go Outdated Show resolved Hide resolved
@@ -158,6 +164,65 @@ func Validate(manifest *Manifest) (err error) {
return nil
}

// LocateManifestSlices finds the paths marked with "generate:manifest" and
// returns a map from the manifest path to all the slices that declare it.
func LocateManifestSlices(slices []*setup.Slice, manifestFileName string) map[string][]*setup.Slice {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's please rename this function to manifest.FindPaths (per docs), and have it taking the slices as its single argument. The manifest filename should be in this package since the slicer has no use for it given this function is the one pointing to the targets.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 087d09d.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The remaining part about the manifestFileName I wonder whether you should be able to customize it. If I want to write it to somewhere that is not manifest.wall then I should still be able to use this function. Maybe instead of taking manifestFileName we could return the directory and the caller is the one expected to concatenate the filename.

Copy link
Contributor

Choose a reason for hiding this comment

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

This function is pointing out what is the standard path given the following slices. We can write manifests anywhere using manifest.Write.

Do I misunderstand the issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, just that I thought the helper should be more generic and that in our previous conversations we said to move the manifest filename to slicer and keep manifest generic. I will move it back here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in 8445042.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the conversation was about moving the function itself to slicer, for reasons related to what we've been discussing in this iteration. The comment now was about the fact we chose not to move the function out of manifest, and yet the filename is still there.

internal/manifest/manifest.go Outdated Show resolved Hide resolved
err := dbw.Add(&Path{
Kind: "path",
Path: path,
Mode: fmt.Sprintf("0%o", unixPerm(manifestMode)),
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we know this mode? The answer is we don't, not here. That's a relatively small issue, but it's also a hint of a larger issue that is quite clear: there's an unfortunate cross-dependency and disconnect right now between the manifest package and the slicer package about how to write stuff to disk.

Let's please try to fix this by:

  1. Introduce fsutil.CreateWriter, which returns (io.WriterCloser, *Entry, error). Let's please do it right, in the sense that we'll have a writerProxy, similar to the readerProxy that we have today, to fill up the hash and size as we go, as that's trivial to do. We won't depend on it, though. See below.

  2. Add the *Entry to the actual Report as soon as we create the *Entry. At this point the entry will still be empty as far as the hash goes, and that's the way it should be as otherwise we'd need to add it at the end, which doesn't work since entries are sorted.

  3. Remove manifestAddManifestPaths and the respective field from the options type.

With these steps, there's nothing special anymore about manifest files here: the slicer cuts it, the report holds it, the manifest writes it down, just like everything else.

Copy link
Contributor

Choose a reason for hiding this comment

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

One extra detail here: CreateWriter can take the same Options parameter we have in the Create function.

Copy link
Collaborator Author

@letFunny letFunny Sep 30, 2024

Choose a reason for hiding this comment

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

Done in dad0ed7. Hopefully now everything should be unified and there is nothing special about manifest files.

internal/slicer/slicer.go Outdated Show resolved Hide resolved
Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

Very nice, thank you!

Just one detail missing from the prior review.

Selection []*setup.Slice
// Map manifest path to all the slices that declare it. See
// manifest.FindPaths.
ManifestSlices map[string][]*setup.Slice
Copy link
Contributor

Choose a reason for hiding this comment

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

Per earlier comments, it doesn't make sense to have this here anymore. See how it's being used below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done in a9ee6ac, my bad for missing it earlier.

@@ -270,6 +263,9 @@ func manifestAddSlices(dbw *jsonwall.DBWriter, slices []*setup.Slice) error {
}

func manifestAddReport(dbw *jsonwall.DBWriter, report *Report) error {
if report == nil {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Creating a manifest without a report looks like a bug. What code elsewhere is doing this and why?

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

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

That Write function is beautiful now. Thank you!

@niemeyer niemeyer merged commit 33bed22 into canonical:main Sep 30, 2024
14 checks passed
@letFunny letFunny deleted the chisel-db-create-manifest branch October 17, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority Look at me first
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants