Catch exception for non-JSON items in Dashboard ZIP #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@harrysx had a use case where he'd taken a ZIP of dashboards originally created from
download_dashboards.py
, unzipped it to trim it down to a subset, then re-zipped it. Therestore_dashboards.py
script ultimately choked on this with the error:The contents of the repackaged ZIP:
The previous dumb version of the restore script just expects to find only valid JSON files in the ZIP. That's fine if one could assume only unmodified ZIPs that came from the
download
script, but this repackaging is innocent enough that we should be able to handle it.This repackaged ZIP tripped up the
restore
in a couple ways:k8s_dashboards/
. One could exclude such entries if repackaging with the-D
option, but it's not default behavior.._.DS_Store
are in there regardless.This PR gets around all these issues by simply catching the exception from any non-JSON junk found in the ZIP, then notes what it was and that it's being skipped.
While I was at it, I also added a line to print the name of each Dashboard successfully restored.