Skip to content

Commit d25dbaf

Browse files
committed
Sleep before requesting stylesheet
1 parent b875af4 commit d25dbaf

File tree

2 files changed

+14
-51
lines changed

2 files changed

+14
-51
lines changed

http-tests/admin/packages/install-package-stylesheet.sh

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,9 @@ curl -k -w "%{http_code}\n" -o /dev/null -f -s \
1919
"${ADMIN_BASE_URL}packages/install" \
2020
| grep -q "$STATUS_SEE_OTHER"
2121

22-
# Purge cache after install to clear any cached 404 responses
23-
purge_cache "$END_USER_VARNISH_SERVICE"
24-
purge_cache "$ADMIN_VARNISH_SERVICE"
25-
purge_cache "$FRONTEND_VARNISH_SERVICE"
26-
27-
# Wait for package installation to complete (poll for stylesheet availability)
28-
elapsed=0
29-
iteration=0
30-
while [ $(echo "$elapsed < 30" | bc) -eq 1 ]; do
31-
# Get status and headers via proxy in one request
32-
proxy_response=$(curl -k -s -I "${END_USER_BASE_URL}static/com/linkeddatahub/packages/skos/layout.xsl")
33-
stylesheet_status=$(echo "$proxy_response" | head -1 | grep -oE '[0-9]{3}')
34-
35-
iteration=$((iteration + 1))
36-
37-
# Only break on success after at least 2 iterations (to see Age > 0)
38-
if [ "$stylesheet_status" = "200" ] && [ $iteration -ge 2 ]; then
39-
break
40-
fi
41-
42-
echo "--- Waiting for stylesheet (${elapsed}s) ---"
43-
echo "Via proxy: HTTP $stylesheet_status"
44-
echo "$proxy_response" | grep -E "(Age|X-Cache|X-Varnish)" || echo "(no cache headers)"
45-
46-
# Check file on disk
47-
docker compose exec -T linkeddatahub ls -l webapps/ROOT/static/com/linkeddatahub/packages/skos || echo "Directory does not exist"
48-
49-
# Test direct access to Tomcat (bypasses Varnish/Nginx cache)
50-
internal_status=$(docker compose exec -T nginx curl -s -w "%{http_code}\n" -o /dev/null http://linkeddatahub:8080/static/com/linkeddatahub/packages/skos/layout.xsl)
51-
echo "Direct Tomcat: HTTP $internal_status"
52-
53-
sleep 0.5
54-
elapsed=$(echo "$elapsed + 0.5" | bc)
55-
done
56-
57-
if [ "$stylesheet_status" != "200" ]; then
58-
echo "--- Final check after timeout ---"
59-
docker compose exec -T linkeddatahub ls -l webapps/ROOT/static/com/linkeddatahub/packages/skos || echo "Directory does not exist"
60-
exit 1
61-
fi
22+
# the stylesheet is not available via URL right away. If we request it right away, Varnish will cache a 404 Not Found response for it
23+
# TO-DO: make sure the stylesheet URL is available immediately after installation
24+
sleep 1
6225

6326
# verify package stylesheet was installed (should return 200)
6427
curl -k -f -s -o /dev/null \

src/main/java/com/atomgraph/linkeddatahub/resource/admin/pkg/InstallPackage.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,12 @@ private void installStylesheet(Path stylesheetFile, String packagePath, String s
352352
if (log.isDebugEnabled()) log.debug("Installed package stylesheet at: {}", stylesheetFile);
353353

354354
// Purge stylesheet from frontend proxy cache to clear any cached 404 responses
355-
String stylesheetURL = "/static/" + packagePath + "/layout.xsl";
356-
if (endUserApp.getFrontendProxy() != null)
357-
{
358-
if (log.isDebugEnabled()) log.debug("Purging stylesheet from frontend proxy cache: {}", stylesheetURL);
359-
getSystem().ban(endUserApp.getFrontendProxy(), stylesheetURL, false);
360-
}
355+
// String stylesheetURL = "/static/" + packagePath + "/layout.xsl";
356+
// if (endUserApp.getFrontendProxy() != null)
357+
// {
358+
// if (log.isDebugEnabled()) log.debug("Purging stylesheet from frontend proxy cache: {}", stylesheetURL);
359+
// getSystem().ban(endUserApp.getFrontendProxy(), stylesheetURL, false);
360+
// }
361361
}
362362

363363
/**
@@ -389,11 +389,11 @@ private void regenerateMasterStylesheet(EndUserApplication app, com.atomgraph.li
389389
updater.regenerateMasterStylesheet(packagePaths);
390390

391391
// Purge master stylesheet from cache
392-
if (app.getFrontendProxy() != null)
393-
{
394-
if (log.isDebugEnabled()) log.debug("Purging master stylesheet from frontend proxy cache: {}", com.atomgraph.linkeddatahub.Application.MASTER_STYLESHEET_PATH);
395-
getSystem().ban(app.getFrontendProxy(), com.atomgraph.linkeddatahub.Application.MASTER_STYLESHEET_PATH, false);
396-
}
392+
// if (app.getFrontendProxy() != null)
393+
// {
394+
// if (log.isDebugEnabled()) log.debug("Purging master stylesheet from frontend proxy cache: {}", com.atomgraph.linkeddatahub.Application.MASTER_STYLESHEET_PATH);
395+
// getSystem().ban(app.getFrontendProxy(), com.atomgraph.linkeddatahub.Application.MASTER_STYLESHEET_PATH, false);
396+
// }
397397
}
398398

399399
/**

0 commit comments

Comments
 (0)