<div dir="ltr"><div>We should not raise a validation exception because due to semver we can't stop raising that exception later. Specifically if we want to ever allow double checksum being specified in the future.<br><br></div><div>For the MVP, I think the choices are: only respect sha256 and ignore the rest OR do as many standard validators as they specify. I'm ok with either of these with a slight preference for validating as many of them as are specified would be the best. Since we're already handling all of the data at save time, pushing it through additional digest validators will cost a bit of cpu but not much additional I/O. Also if the user asked us to do that validation then having it demand some additional resources is OK. Also having feature parity with the changesets is good. The changesets can validate all standard digest validators so having uploads do the same would be consistent.<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 10, 2017 at 5:11 PM, Jeff Ortel <span dir="ltr"><<a href="mailto:jortel@redhat.com" target="_blank">jortel@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
On 07/10/2017 02:36 PM, Dennis Kliban wrote:<br>
> On Mon, Jul 10, 2017 at 3:26 PM, Michael Hrivnak <<a href="mailto:mhrivnak@redhat.com">mhrivnak@redhat.com</a> <mailto:<a href="mailto:mhrivnak@redhat.com">mhrivnak@redhat.com</a>>> wrote:<br>
<span class="">><br>
><br>
><br>
>     On Mon, Jul 10, 2017 at 3:06 PM, Dennis Kliban <<a href="mailto:dkliban@redhat.com">dkliban@redhat.com</a> <mailto:<a href="mailto:dkliban@redhat.com">dkliban@redhat.com</a>>> wrote:<br>
><br>
>         The upload API for Artifacts is going to allow users to specify the artifact size and a digest. The<br>
>         Artifact model currently supports  'md5', 'sha1', 'sha224', 'sha256', 'sha384', and 'sha512' digests.<br>
><br>
>         Do we want to let users specify more than one digest per upload? e.g. md5 and sha256?<br>
><br>
><br>
>     There may be no harm in this, but it would add complexity to the verification and not add much value. I'd<br>
>     stick with just one unless there's a compelling reason for multiple.<br>
><br>
><br>
> I agree. The API is going to raise a validation exception when more than 1 digest is provided.<br>
<br>
</span>+1<br>
<span class=""><br>
><br>
><br>
><br>
><br>
><br>
>         Do we want to store all 6 digests for each Artifact?<br>
><br>
><br>
>     The expensive part of calculating the digests is reading the file. As long as you're already reading the<br>
>     entire file, which we will during verification, you may as well stuff the bits through multiple hashers<br>
>     (digesters?) and get all the digests. Pulp 2 has a function that does this:<br>
><br>
>     <a href="https://github.com/pulp/pulp/blob/2.13-release/server/pulp/server/util.py#L327-L353" rel="noreferrer" target="_blank">https://github.com/pulp/pulp/<wbr>blob/2.13-release/server/pulp/<wbr>server/util.py#L327-L353</a><br>
>     <<a href="https://github.com/pulp/pulp/blob/2.13-release/server/pulp/server/util.py#L327-L353" rel="noreferrer" target="_blank">https://github.com/pulp/pulp/<wbr>blob/2.13-release/server/pulp/<wbr>server/util.py#L327-L353</a>><br>
><br>
>     But we can't always guarantee that we'll have all the checksums available, for at least two reasons. 1) If<br>
>     in the future if we want to use yet another algorithm, we probably won't want to run a migration that<br>
>     re-reads every file and calculates the additional digest. 2) For on-demand content, we don't have it<br>
>     locally, so we can't calculate any additional checksums until it gets fetched.<br>
><br>
>     So this may be one of those times where we use a good-ole-fashioned getter method that returns the<br>
>     requested digest if it's on the artifact, calculates it if not, or raises an exception if the value isn't<br>
>     available and can't be calculated.<br>
><br>
><br>
> For uploaded Artifacts, all of the digests will be calculated as the file is being processed during the<br>
> upload. So I don't think calculating all of them should incur significantly more cost than just one. The code<br>
> snippet from Pulp 2 looks similar to what I am doing.<br>
<br>
</span>This functionality should be a method on the Artifact and not a util function somewhere.<br>
<span class=""><br>
><br>
> I haven't given much thought to the getter, but your idea sounds fine to me.<br>
> Thanks,<br>
> Dennis<br>
><br>
><br>
><br>
><br>
>     --<br>
><br>
>     Michael Hrivnak<br>
><br>
>     Principal Software Engineer, RHCE<br>
><br>
>     Red Hat<br>
><br>
><br>
><br>
><br>
</span>> ______________________________<wbr>_________________<br>
> Pulp-dev mailing list<br>
> <a href="mailto:Pulp-dev@redhat.com">Pulp-dev@redhat.com</a><br>
> <a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/pulp-dev</a><br>
><br>
<br>
<br>______________________________<wbr>_________________<br>
Pulp-dev mailing list<br>
<a href="mailto:Pulp-dev@redhat.com">Pulp-dev@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pulp-dev" rel="noreferrer" target="_blank">https://www.redhat.com/<wbr>mailman/listinfo/pulp-dev</a><br>
<br></blockquote></div><br></div>