cncf / landscapeapp

šŸŒ„Upstream landscape generation application
https://landscapes.dev/
Apache License 2.0
253 stars 124 forks source link

svg-autocrop-serverless should fail reliably with an error #511

Closed dankohn closed 4 years ago

dankohn commented 4 years ago

Try running these pathological cases against autocrop.cncf.io. I think we should reject any SVG greater than 1.5 MB as it's unlikely to be a real company logo. We also may want to time out at greater than 20 seconds, but in that case, we should probably post the offending SVG to Slack to evaluate what's happening.

The timeout needs to be more than 10 seconds, as @cjyabraham got this error: image

The Autocrop site works for me with this 1.1MB SVG: https://upload.wikimedia.org/wikipedia/commons/5/59/Usa_counties_large.svg

But it sometimes hangs on this 3.81MB one: https://upload.wikimedia.org/wikipedia/commons/6/63/A_large_blank_world_map_with_oceans_marked_in_blue.svg

@cjyabraham got an error on this 18kB image: https://upload.wikimedia.org/wikipedia/commons/6/67/Firefox_Logo%2C_2017.svg

The largest real company logo I'm aware of is https://github.com/cncf/landscape/blob/master/hosted_logos/babylon.svg at 842kB and https://github.com/AcademySoftwareFoundation/aswf-landscape/blob/master/cached_logos/open-vdb.svg at 1.06MB.

AndreyKozlov1984 commented 4 years ago

I've added a time limit to 20s and a size limit 1.5MB. Maximum time in google cloud functions had been increased to 30s, but after 20s the request will be stopped with an error message.

AndreyKozlov1984 commented 4 years ago

Still need to update docs and add a test for a maximum size. The timeout was tested locally with a small (1s) value

cjyabraham commented 4 years ago

Is the 20s time limit live yet? I'm still getting a 10s timeout error:

Screen Shot 2020-02-03 at 12 37 26 PM
AndreyKozlov1984 commented 4 years ago

Curl examples had been added.

AndreyKozlov1984 commented 4 years ago

@cjyabraham any chance to reproduce this again? I was not able to get a timeout, is it possible that cURL itself has a timeout ? Can you reproduce this on a autocrop web site ?

cjyabraham commented 4 years ago

I do not get the timeout on the https://autocrop.cncf.io/ website. It looks like the timeout is originating from curl. I increased it to 20s and now I hit this timeout when I try and upload the car, USA counties, and also for the openvdb logo. I then tried going to 30s. The car and usa counties now work, however, for the openvdb logo I just get this unhelpful message:

Screen Shot 2020-02-04 at 11 12 08 AM

It also doesn't seem to work on the web ui either. It just keeps saying "Work in progress. Please wait ...". Any thoughts on that?

AndreyKozlov1984 commented 4 years ago

Thanks for a great example. So far the problem is that it takes some time for SVGO to handle this example, I think it takes 30-40s locally on my mac. The solution would be to increase the timeout up to 60 seconds, then this example will work. Somehow just the svg file is heaving too much elements to process.

dankohn commented 4 years ago

We want it to time out after 20 seconds and produce a clear error.

AndreyKozlov1984 commented 4 years ago

Ok, I'll make the code a bit more complex and will run it in the background process, to guarantee that we return a clear error instead of cryptic 500 response from a google cloud.

cjyabraham commented 4 years ago

Should we set the timeout to 30s? I'm concerned our editors will get too many timeouts for complex logos and will have no plan B except for pinging me in Slack :P

dankohn commented 4 years ago

Slack? They can just call your cellphone to take advantage of your 24/7 SVG upload support.

AndreyKozlov1984 commented 4 years ago

I think everything works now. I made it running in the background process, so after 20 seconds, or may be a bit more, timeout occurs and an error message is returned.

AndreyKozlov1984 commented 4 years ago

@cjyabraham sadly, we can not easily increase a timeout to 60 seconds, because after 26 seconds netlify will cut off a request completely. If people demand this service to work on such complex SVG files, I'll have to add a CORS support for the google cloud functions and call it cross domain from our web page. Right now we use a Netlify proxy for a web site.

cjyabraham commented 4 years ago

Ok, thanks for checking out our options. @dankohn anything more you want before we close this issue?

dankohn commented 4 years ago

No. Note that all logos on all 11 landscapes process correctly with the given timeout. It's only the pathological ones you found that might cause a problem. We can obviously revisit if the Autocrop service proves unreliable.