Skip to content

Core: ManifestListWriter cleanup around encryption keys - #18150

Merged
amogh-jahagirdar merged 1 commit into
apache:mainfrom
gaborkaszab:main_ManifestListWriter_cleanup
Sep 17, 2026
Merged

amogh-jahagirdar merged 1 commit into
apache:mainfrom
gaborkaszab:main_ManifestListWriter_cleanup

Conversation

@gaborkaszab

Copy link
Copy Markdown
Contributor

Problems this solves:

  • There is a dependency between toManifestFile() and encryptionKeys().
  • From toManifestFile()'s return type only keyId is used, but it's also present in the output of encryptionKeys()
  • manifestListFile member can be dropped
  • outputFile member can be dropped

Problems this solves:
 - There is a dependency between toManifestFile() and encryptionKeys().
 - From toManifestFile()'s return type only keyId is used, but it's also
   present in the output of encryptionKeys()
 - manifestListFile member can be dropped
 - outputFile member can be dropped
@github-actions github-actions Bot added the core label Sep 17, 2026
private final FileAppender<ManifestFile> writer;
private final StandardEncryptionManager standardEncryptionManager;
private final NativeEncryptionKeyMetadata manifestListKeyMetadata;
private final OutputFile outputFile;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The only usage of the outputFile member outside of the constructor was to create a ManifestListFile in toManifestListFile(), but then it was unused later on. Now that the functions are merged, no need for this member

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed, even if we do my proposed approach we can drop ManifestListFile. Though in my approach, we would need OutputFile, which I feel like is very reasonable and consistent with what we do for "regular" manifests

. The writer needs to have some reference to an output file

List<ManifestFile> manifests =
ManifestLists.read(
readingIO.newInputFile(
new BaseManifestListFile(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note, #17545 will get rid of BaseManifestListFile and use a more general version of newInputFile

@gaborkaszab

Copy link
Copy Markdown
Contributor Author

Hi @amogh-jahagirdar @smaheshwar-pltr @nssalian ,

I think #17984 was merged in a premature state and we could have made a final cleanup on the code on the area of ManifestListWriter. We introduced some redundancy and ambiguous responsibilities between functions IMO.
This is a follow-up for some cleanup. Please take a look!

return null;
}

public ManifestListFile toManifestListFile() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree that the dependency is weird, it's what I mentioned here already; we should clean that part up.

But I think there's a good argument for having a toManifestListFile API, it's consistent with what we have for manifest files (toManifestFile) and I think fundamentally a writer handing back a "This is the complete object" makes it easier for consumers to just use that as a source of truth (e.g. they can do manifestList.encryptionKeys(), manifestList.location() etc).

In our case the consumer is just SnapshotProducer

So what I was thinking was a good way to clean this up would be

EncryptionKeys encryptionKeys() {
   /// what you have now
}

ManifestListFile toManifestList() {
   EncryptionKeys encryptionKeys = encryptionKeys()
    return new ManifestListFile(location, encryptionKeys != null ? encryptionKeys.fileKey().keyId() : null):
}

So we get rid of the bad dependency ordering and still keep (imo) a useful API.

WDYT?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm fine as it is btw, we can always add functions later, but just wanted to point out that the toManifestListFile was something thought through and not rushed :) but agree on cleaning up the dependency/state, that's a good thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback, @amogh-jahagirdar !

As you pointed out SnapshotProducer is the only user of toManifestList(), but in practice the ManifestListFile return type is not needed there, just the key ID from it. In fact, I'm working on dropping this whole ManifestListFile abstraction because there is nothing specific to manifest files and we need a way to handle manifest files, root manifest, snapshot files in the same way in term of encryption.

}

ManifestListFile manifestListFile = writer.toManifestListFile();
this.manifestListEncryptionKeys = writer.encryptionKeys();

@amogh-jahagirdar amogh-jahagirdar Sep 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we do what I mentioned above, I think we can effectively get rid of this state on SnapshotProducer, and just pass in manifestListFile.encryptionKeys(). So it trades off more state in ManifestListFile (OutputFile) for getting rid of state in SnapshotProducer, which I think is better as as it really shouldn't be SnapshotProducer's responsibility imo.

}

ManifestListFile manifestListFile = writer.toManifestListFile();
assertThat(writer.toManifestListFile().encryptionKeyID())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One possible issue with removing this is that then we're not effectively testing the encryptionKeys == null which currently prevents registering 2 different keys for the same file. But fwiw the utility of testing this behavior is moot if we're only calling this from snapshot producer just once. So I'm good with the removal.

@amogh-jahagirdar amogh-jahagirdar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @gaborkaszab , While I still feel like a toManifestListFile is useful we can table that discussion point, the PR is a clear improvement over the current state (removing manifest list file state and not requiring toManifestListFile() in order to setup encryptionKeys) which is appreciated, so I'll go ahead and merge.

@amogh-jahagirdar
amogh-jahagirdar merged commit f2ed9b7 into apache:main Sep 17, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants