Fix dependency injection and shared cache #32
Merged
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.
Background
KSP-CKAN/CKAN-meta#1316 tried to update the download links for four mods, two of which are dependencies for the other two. The pull request validation failed, and then it got interesting.
Problem 1: Metadata injection
The URL that failed to download should not exist anymore, because it's overwritten as part of that pull request:
https://ci.ksp-ckan.org/job/CKAN-meta/886/consoleFull
Cause
This function is supposed to take care of that by replacing old metadata with the latest copy from the pull request:
xKAN-meta_testing/CKAN-meta/build.sh
Lines 169 to 173 in d63a88c
However, the line that does it copies the new metadata files to the root of the CKAN-meta-master directory:
xKAN-meta_testing/CKAN-meta/build.sh
Lines 193 to 197 in d63a88c
The old metadata is not in the root; it's in
identifier/identifier-version.ckan
. This means that the old metadata is not overwritten, and instead both the old and new metadata will be in the local repo. Which one will actually be used by ckan? Luck of the draw.Changes
Now we copy the new metadata to the exact location it will occupy once it is merged. This ensures that it will overwrite any files it is replacing, so old metadata will not be used for installation and testing. Both CKAN-meta and NetKAN are updated.
Problem 2: Shared download cache
In the process of investigating that, I noticed another issue. This line does not work as intended:
xKAN-meta_testing/CKAN-meta/build.sh
Lines 165 to 166 in d63a88c
This is supposed to make all instances of ckan use the same download directory, to save bandwidth and time. However, currently it doesn't work; for example, the script downloaded GPP 1.5.88 (and its dependencies) three times for this older pull request:
https://ci.ksp-ckan.org/job/CKAN-meta/880/consoleFull
They should have shown up as "(cached)" in download listings after the first and not been redownloaded. At nearly 300 MB per cycle, that's a lot of downloading.
Cause
What happens is hiding in plain sight in that log:
Before the
ln
command runs, ckan.exe adds the dummy instance to the list of known instances, and in the process it initializes the instance's CKAN folder, including creating thedownloads
folder.The
ln
command runs later, and its target folder already exists. When aln
command is given a destination folder argument that already exists, it creates a new sym link inside that folder; so what's happening is that we now have a symlink here:... which doesn't get used by ckan.exe. Instead the normal non-shared downloads folder is used and wiped between tests.
Changes
Now we create the download folder symlink before ckan.exe runs. This will ensure that it is shared across all tests for the same commit. Both CKAN-meta and NetKAN are updated.
Command verbosity
To make it easier to spot problems like these in the future, the
--verbose
flag is added to all standard Unix commands used in the scripts, such asrm
,mkdir
,cp
, etc. This generates an extra line of output per command that spells out the action being taken:This way we will be able to tell exactly which paths are being used, and any funny business will be more obvious.