Skip to content

Commit fd8db61

Browse files
committed
Fix Storm UI bundle cache-busting (#8518)
The ${packageTimestamp} token in WEB-INF/*.html was never substituted — no Maven resource filtering was configured for these files — so every deploy served `main.bundle.js?_ts=${packageTimestamp}` as a literal constant URL. Browsers held onto stale bundles across releases, and after the Bootstrap 5.3.8 / dark-mode rewrite (which touched both main.bundle.js and topology-page-template.html) cached clients hit "Invalid template! ... undefined" on the topology detail page because the cached bundle and the freshly served template no longer agreed on template element IDs.
1 parent 9c6e9cc commit fd8db61

12 files changed

Lines changed: 60 additions & 24 deletions

File tree

storm-webapp/cypress/test-server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ app.post('/api/v1/topology/:id/:action', (_req, res) => {
110110
});
111111

112112
// --- Serve HTML pages ---
113-
// The HTML files use ${packageTimestamp} which we replace on the fly
113+
// The HTML files use @packageTimestamp@ which we replace on the fly
114+
// (Maven's resource filter substitutes it at build time with the same
115+
// delimiter — see storm-webapp/pom.xml).
114116
function serveHtml(filePath, res) {
115117
let html = fs.readFileSync(filePath, 'utf8');
116-
html = html.replace(/\$\{packageTimestamp\}/g, 'test');
118+
html = html.replace(/@packageTimestamp@/g, 'test');
117119
res.type('html').send(html);
118120
}
119121

storm-webapp/pom.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@
3030
<name>Storm Webapp</name>
3131
<description>Webapp Servers for Apache Storm</description>
3232

33+
<properties>
34+
<!-- Substituted into WEB-INF/*.html as @packageTimestamp@ by
35+
maven-resources-plugin for bundle cache-busting. Also passed to
36+
webpack (see frontend-maven-plugin configuration below) so the
37+
PACKAGE_TIMESTAMP baked into the JS bundle matches the token
38+
served in the HTML pages. -->
39+
<packageTimestamp>${maven.build.timestamp}</packageTimestamp>
40+
</properties>
41+
3342
<dependencies>
3443
<!-- storm-webapp is based on storm-core -->
3544
<dependency>
@@ -145,6 +154,18 @@
145154
<includes>
146155
<include>WEB-INF/**/*.*</include>
147156
</includes>
157+
<excludes>
158+
<!-- Top-level HTML pages contain @packageTimestamp@ for bundle
159+
cache-busting and are filtered below. -->
160+
<exclude>WEB-INF/*.html</exclude>
161+
</excludes>
162+
</resource>
163+
<resource>
164+
<directory>${basedir}/src/main/java/org/apache/storm/daemon/ui</directory>
165+
<filtering>true</filtering>
166+
<includes>
167+
<include>WEB-INF/*.html</include>
168+
</includes>
148169
</resource>
149170
<resource>
150171
<directory>${basedir}/target/generated-resources</directory>
@@ -197,6 +218,19 @@
197218
</execution>
198219
</executions>
199220
</plugin>
221+
<plugin>
222+
<!-- Use @...@ delimiters only so JS/HTML ${...} (template
223+
literals, shell-style expressions, etc.) in filtered
224+
WEB-INF/*.html files are left untouched. -->
225+
<groupId>org.apache.maven.plugins</groupId>
226+
<artifactId>maven-resources-plugin</artifactId>
227+
<configuration>
228+
<useDefaultDelimiters>false</useDefaultDelimiters>
229+
<delimiters>
230+
<delimiter>@</delimiter>
231+
</delimiters>
232+
</configuration>
233+
</plugin>
200234
<plugin>
201235
<groupId>org.apache.maven.plugins</groupId>
202236
<artifactId>maven-surefire-report-plugin</artifactId>

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<script>!function(){var m=document.cookie.match(/(?:^|;\s*)stormTheme=([^;]*)/);var t=m?decodeURIComponent(m[1]):null;if(!t)t=window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";document.documentElement.setAttribute("data-bs-theme",t)}()</script>
2121
<meta name="viewport" content="width=device-width, initial-scale=1">
2222
<title>Storm UI</title>
23-
<link href="/dist/main.bundle.css?_ts=${packageTimestamp}" rel="stylesheet" type="text/css">
24-
<script src="/dist/main.bundle.js?_ts=${packageTimestamp}" type="text/javascript"></script>
23+
<link href="/dist/main.bundle.css?_ts=@packageTimestamp@" rel="stylesheet" type="text/css">
24+
<script src="/dist/main.bundle.js?_ts=@packageTimestamp@" type="text/javascript"></script>
2525
</head>
2626
<body>
2727
<div class="container-fluid">

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/deep_search_result.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<script>!function(){var m=document.cookie.match(/(?:^|;\s*)stormTheme=([^;]*)/);var t=m?decodeURIComponent(m[1]):null;if(!t)t=window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";document.documentElement.setAttribute("data-bs-theme",t)}()</script>
2020
<meta name="viewport" content="width=device-width, initial-scale=1">
2121
<title>Storm UI</title>
22-
<link href="/dist/main.bundle.css?_ts=${packageTimestamp}" rel="stylesheet" type="text/css">
23-
<script src="/dist/main.bundle.js?_ts=${packageTimestamp}" type="text/javascript"></script>
22+
<link href="/dist/main.bundle.css?_ts=@packageTimestamp@" rel="stylesheet" type="text/css">
23+
<script src="/dist/main.bundle.js?_ts=@packageTimestamp@" type="text/javascript"></script>
2424
</head>
2525
<body>
2626
<div class="container-fluid">

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/flux.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
border: 1px solid var(--bs-border-color);
4040
}
4141
</style>
42-
<link href="/dist/flux.bundle.css?_ts=${packageTimestamp}" rel="stylesheet" type="text/css">
43-
<script src="/dist/flux.bundle.js?_ts=${packageTimestamp}"></script>
42+
<link href="/dist/flux.bundle.css?_ts=@packageTimestamp@" rel="stylesheet" type="text/css">
43+
<script src="/dist/flux.bundle.js?_ts=@packageTimestamp@"></script>
4444
<script type="text/javascript">
4545
function toCytoscapeGraph(doc) {
4646
var nodes = [];

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<script>!function(){var m=document.cookie.match(/(?:^|;\s*)stormTheme=([^;]*)/);var t=m?decodeURIComponent(m[1]):null;if(!t)t=window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";document.documentElement.setAttribute("data-bs-theme",t)}()</script>
2121
<meta name="viewport" content="width=device-width, initial-scale=1">
2222
<title>Storm UI</title>
23-
<link href="/dist/main.bundle.css?_ts=${packageTimestamp}" rel="stylesheet" type="text/css">
24-
<script src="/dist/main.bundle.js?_ts=${packageTimestamp}" type="text/javascript"></script>
23+
<link href="/dist/main.bundle.css?_ts=@packageTimestamp@" rel="stylesheet" type="text/css">
24+
<script src="/dist/main.bundle.js?_ts=@packageTimestamp@" type="text/javascript"></script>
2525
</head>
2626
<body>
2727
<div class="container-fluid">

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/logviewer_search.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<script>!function(){var m=document.cookie.match(/(?:^|;\s*)stormTheme=([^;]*)/);var t=m?decodeURIComponent(m[1]):null;if(!t)t=window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";document.documentElement.setAttribute("data-bs-theme",t)}()</script>
2020
<meta name="viewport" content="width=device-width, initial-scale=1">
2121
<title>Storm UI</title>
22-
<link href="/dist/main.bundle.css?_ts=${packageTimestamp}" rel="stylesheet" type="text/css">
23-
<script src="/dist/main.bundle.js?_ts=${packageTimestamp}" type="text/javascript"></script>
22+
<link href="/dist/main.bundle.css?_ts=@packageTimestamp@" rel="stylesheet" type="text/css">
23+
<script src="/dist/main.bundle.js?_ts=@packageTimestamp@" type="text/javascript"></script>
2424
</head>
2525
<body>
2626
<div class="container-fluid">

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/owner.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<script>!function(){var m=document.cookie.match(/(?:^|;\s*)stormTheme=([^;]*)/);var t=m?decodeURIComponent(m[1]):null;if(!t)t=window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";document.documentElement.setAttribute("data-bs-theme",t)}()</script>
2222
<meta name="viewport" content="width=device-width, initial-scale=1">
2323
<title>Storm UI</title>
24-
<link href="/dist/main.bundle.css?_ts=${packageTimestamp}" rel="stylesheet" type="text/css">
25-
<script src="/dist/main.bundle.js?_ts=${packageTimestamp}" type="text/javascript"></script>
24+
<link href="/dist/main.bundle.css?_ts=@packageTimestamp@" rel="stylesheet" type="text/css">
25+
<script src="/dist/main.bundle.js?_ts=@packageTimestamp@" type="text/javascript"></script>
2626
</head>
2727

2828
<body>

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/search_result.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
<script>!function(){var m=document.cookie.match(/(?:^|;\s*)stormTheme=([^;]*)/);var t=m?decodeURIComponent(m[1]):null;if(!t)t=window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";document.documentElement.setAttribute("data-bs-theme",t)}()</script>
2020
<meta name="viewport" content="width=device-width, initial-scale=1">
2121
<title>Storm UI</title>
22-
<link href="/dist/main.bundle.css?_ts=${packageTimestamp}" rel="stylesheet" type="text/css">
23-
<script src="/dist/main.bundle.js?_ts=${packageTimestamp}" type="text/javascript"></script>
22+
<link href="/dist/main.bundle.css?_ts=@packageTimestamp@" rel="stylesheet" type="text/css">
23+
<script src="/dist/main.bundle.js?_ts=@packageTimestamp@" type="text/javascript"></script>
2424
</head>
2525
<body>
2626
<div class="container-fluid">

storm-webapp/src/main/java/org/apache/storm/daemon/ui/WEB-INF/supervisor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
<script>!function(){var m=document.cookie.match(/(?:^|;\s*)stormTheme=([^;]*)/);var t=m?decodeURIComponent(m[1]):null;if(!t)t=window.matchMedia&&window.matchMedia("(prefers-color-scheme:dark)").matches?"dark":"light";document.documentElement.setAttribute("data-bs-theme",t)}()</script>
2222
<meta name="viewport" content="width=device-width, initial-scale=1">
2323
<title>Storm UI</title>
24-
<link href="/dist/main.bundle.css?_ts=${packageTimestamp}" rel="stylesheet" type="text/css">
25-
<script src="/dist/main.bundle.js?_ts=${packageTimestamp}" type="text/javascript"></script>
24+
<link href="/dist/main.bundle.css?_ts=@packageTimestamp@" rel="stylesheet" type="text/css">
25+
<script src="/dist/main.bundle.js?_ts=@packageTimestamp@" type="text/javascript"></script>
2626
</head>
2727
<body>
2828
<div class="supervisor-page container-fluid">

0 commit comments

Comments
 (0)