KSP-SpaceDock / SpaceDock

Current Codebase (Python /Flask)
https://spacedock.info
Other
73 stars 33 forks source link

SpaceDock serving corrupt zip files #375

Closed Shades-McGee closed 3 years ago

Shades-McGee commented 3 years ago

Description (What went wrong?):

While attempting to install the mod 'Near Future Spacecraft 1.4.1', a popup 'Error!' window appears with the following text...

CKAN.InvalidModuleFileKraken: NearFutureSpacecraft 1.4.1: C:\Users\First Last\AppData\Local\Temp\tmpA984.tmp is not a valid ZIP file: Error in step EntryData for GameData/NearFutureProps/Props/Plants/PlantPlanters01.dds: CRC mismatch
   at CKAN.NetModuleCache.Store(CkanModule module, String path, String description, Boolean move)
   at CKAN.NetAsyncModulesDownloader.ModuleDownloadComplete(Uri url, String filename, Exception error)

... and then the following text appears in the 'Status log' tab in the CKAN window

About to install:

 * Near Future Spacecraft 1.4.1 (spacedock.info, 87.0 MiB)
Downloading "https://spacedock.info/mod/708/Near%20Future%20Spacecraft/download/1.4.1"
Trying to install NearFutureSpacecraft 1.4.1, but it's not downloaded or download is corrupted
Error during installation!
If the above message indicates a download error, please try again. Otherwise, please open an issue for us to investigate.
If you suspect a metadata problem: https://github.com/KSP-CKAN/NetKAN/issues/new/choose
If you suspect a bug in the client: https://github.com/KSP-CKAN/CKAN/issues/new/choose

Please note (from DasSkelett of KSP-CKAN/NetKAN) ticket #8590 - https://github.com/KSP-CKAN/NetKAN/issues/8590:

It's also still failing for me. But it's definitely not a CKAN problem, the archive is also corrupted when downloading and extracting/checking manually, with e.g. 7zip:

$ 7z t Near_Future_Spacecraft-1.4.1.zip 
Scanning the drive for archives:
1 file, 91193997 bytes (87 MiB)

Testing archive: Near_Future_Spacecraft-1.4.1.zip
--
Path = Near_Future_Spacecraft-1.4.1.zip
Type = zip
Physical Size = 91193997

ERROR: CRC Failed : GameData/NearFutureProps/Props/Plants/PlantPlanters01.dds
ERROR: CRC Failed : GameData/NearFutureProps/Props/Tanks/TankGeneric01.dds
ERROR: CRC Failed : GameData/NearFutureProps/Props/Habitation/HabitationProps2.dds
ERROR: Data Error : GameData/NearFutureProps/Props/Seats/KerbalSeat02.dds
ERROR: CRC Failed : GameData/NearFutureProps/Props/Gym/GymProps01.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Parts/FuelTank/service-tank/servicetank-375.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Parts/FuelTank/monoprop-tank/mono-tank-125-1-n.dds
ERROR: Headers Error : GameData/NearFutureSpacecraft/Parts/Engine/landing-engine
ERROR: Headers Error : GameData/NearFutureSpacecraft/Parts/Engine/orbital-engine
ERROR: Headers Error : GameData/NearFutureSpacecraft/Parts/Engine/orbital-engine/orbital-engine-375-1.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Parts/Engine/orbital-engine/orbital-engine-375.mu
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Parts/Command/command-pods/utility-pod-25.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Parts/Command/command-pods/command-pod-375-biconic-1.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Parts/Command/command-pods/mk3-9pod-new.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Parts/Command/command-pods/command-mk4-1.mu
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Spaces/command-375/command-25-iva-window-1.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Spaces/command-375/command-375-biconic-iva-2.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Spaces/mk3-9pod/mk39int_part1-n.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Spaces/command-125/command-125-orbit-iva-1.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Spaces/command-125/command-125-landing-iva-1.dds
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Spaces/command-125/command-125-orbit-iva-1.mu
ERROR: CRC Failed : GameData/NearFutureSpacecraft/Spaces/command-25/command-25-iva-window-1.dds
ERROR: Data Error : GameData/NearFutureSpacecraft/Spaces/command-25/command-25-landing-iva-1.dds

Sub items Errors: 23
Archives with Errors: 1
Sub items Errors: 23

And I still believe it's a SpaceDock problem, because this release has been created 6 months ago, we should've gotten a report in the meantime if it was broken all along. And the bot, which has the zip cached from before, doesn't report any inflation error.

Reproduction Steps (What did you do?):

Go to 'Manage mods' tab in CKAN then select & attempt to install 'Near Future Spacecraft'

Expected Behavior (What do you think should have happened instead?):

I've successfully installed 'Near Future Construction/Electrical/Propulsion/etc.' with no issues.

Environment (OS/Browser/Plugins/etc):

Win 10 'Near Future Spacecraft 1.4.1'

DasSkelett commented 3 years ago

In the meantime I've confirmed that this zip is only corrupted in the version that's still in the ATS cache, if you bypass the ATS cache you get a zip that passes integrity checks:

$ curl https://spacedock.info/content/Nertea_200/Near_Future_Spacecraft/Near_Future_Spacecraft-1.4.1.zip -o Near_Future_Spacecraft-1.4.1.cached.zip
$ curl https://spacedock.info/content/Nertea_200/Near_Future_Spacecraft/Near_Future_Spacecraft-1.4.1.zip?uncached=$(date +%s) -o Near_Future_Spacecraft-1.4.1.uncached.zip
$ sha256sum Near_Future_Spacecraft-1.4.1.*zip
9392823e6690b412dc2c186df27f7bc226c2742f25d547482f40a5e20bf09360  Near_Future_Spacecraft-1.4.1.cached.zip
bd38e60132d72b3e6e8766eb583681b118f0c3946517711271a39502177fd739  Near_Future_Spacecraft-1.4.1.uncached.zip

A restart of ATS might be enough to fix this, especially with the storage problem solved, but this probably won't happen before tomorrow morning when @V1TA5 is back up again.

Shades-McGee commented 3 years ago

Hiya DasSkelett, thanks for the update :) Sounds like it might be an easy-fix(tm), fingers crossed. Good news hopefully.

HebaruSan commented 3 years ago

Apologies for the tangent, @DasSkelett, but what do you think about adding a new Type: label for outer layer infrastructure and reserving Backend for Python code stuff inside of gunicorn?

DasSkelett commented 3 years ago

Let's do that. Thought the same while picking labels, but was busy with other stuff and didn't want to spend much time organizing labels, so I picked the one that fitted best. While we're on it, we could split the Type: labels into to groups, I consider Backend / Frontend / Migration / Email / TheNewInfraOne different from Improvement / Bug / Feature / Question. Maybe the first group could be Area:? Or we remove the prefixes from the second group completely?

DasSkelett commented 3 years ago

Ha, I found a way to purge the zip from the ATS cache for all users! We can do it with a curl PURGE request from alpha or beta, apparently ATS doesn't care about where it's coming from. It should now serve the real, uncorrupted zip:

$ sha256sum Near_Future_Spacecraft-1.4.1.*zip
9392823e6690b412dc2c186df27f7bc226c2742f25d547482f40a5e20bf09360  Near_Future_Spacecraft-1.4.1.cached.zip
bd38e60132d72b3e6e8766eb583681b118f0c3946517711271a39502177fd739  Near_Future_Spacecraft-1.4.1.uncached.zip
bd38e60132d72b3e6e8766eb583681b118f0c3946517711271a39502177fd739  Near_Future_Spacecraft-1.4.1.now.zip

@Shades-McGee, please re-try the installation in CKAN, it should work now.

Shades-McGee commented 3 years ago

Well done @DasSkelett, it works... we're good to go. Thank you for the assist :)

HebaruSan commented 3 years ago

We can do it with a curl PURGE request from alpha or beta

Now that's a neat trick! Did you just use curl?

HebaruSan commented 3 years ago

While we're on it, we could split the Type: labels into to groups, I consider Backend / Frontend / Migration / Email / TheNewInfraOne different from Improvement / Bug / Feature / Question. Maybe the first group could be Area:? Or we remove the prefixes from the second group completely?

Makes sense to me, Type is now Area for those and Area: Infrastructure now exists.

DasSkelett commented 3 years ago

Now that's a neat trick! Did you just use curl?

Yup. I've extended it a bit and put it in a script now (/home/DasSkelett/bin/purge.sh):

#!/bin/bash
ID=$@
CONTENT_URL=$(curl -ILs -o /dev/null -w %{url_effective} https://spacedock.info/mod/$ID/download)

CDN_IP=$(getent hosts web.52k | awk '{ print $1 }')
curl -IX PURGE --resolve spacedock.info:443:${CDN_IP} ${CONTENT_URL}

I want to put it somewhere in this repo or wiki to preserve it, just need to find a place.

Shutch commented 3 years ago

The same corruption bug is also occurring with the following mods:

Near Future Aeronautics 2.1.0 (spacedock.info, 38.2 MiB) Near Future Launch Vehicles 2.1.3 (spacedock.info, 161.3 MiB)

DasSkelett commented 3 years ago

Thanks, those two should be taken care of. Still hoping that @V1TA5 is going to restart ATS when he's online again, there might be many more hidden in the cache.