Tamás Hanicz created KNOX-3527:
----------------------------------
Summary: Auto-deploy topologies are not redeployed at startup
because the redeploy happens before the topology monitor starts
Key: KNOX-3527
URL: https://issues.apache.org/jira/browse/KNOX-3527
Project: Apache Knox
Issue Type: Bug
Components: Server
Affects Versions: 3.0.0
Reporter: Tamás Hanicz
Assignee: Tamás Hanicz
{code}gateway.auto.deploy.topologies\{code} (default: \{{admin,manager}}) is
supposed to force those topologies to redeploy when the gateway starts. In
practice they are not redeployed until the next unrelated reload of the
topologies directory.
h3. Root cause
In \{{GatewayServer.start()}}:
{\{monitor.reloadTopologies()}} loads every topology into the
\{{DefaultTopologyService}} in-memory map.
For each auto-deploy topology, \{{monitor.redeployTopology(name)}} rewrites
\{{<redeployTime>}} in the topology file (KNOX-2689).
{\{startMonitor()}} starts the \{{FileAlterationObserver}} on the topologies
directory later on. The observer takes its initial snapshot at that point, so
it already includes the step 2 write and never reports it as a change.
Nothing reloads the topologies between steps 2 and 3. The in-memory copies of
\{{admin}} and \{{manager}} keep their old timestamp and \{{redeployTime}}, and
the startup redeploy has no effect.
The next time anything changes in the topologies directory,
\{{reloadTopologies()}} finds that \{{admin}} and \{{manager}} differ from the
in-memory copies and redeploys them. That redeploy is unexpected and has
nothing to do with the change that triggered it.
h3. Example
{noformat}
12:46:19 Loading topologies from directory ...
12:46:25 admin.xml / manager.xml rewritten with
<redeployTime>1792665985876</redeployTime>
12:46:26 Started monitoring topologies
12:46:55 health.xml changed
12:46:56 Deploying topology admin to .../admin.topo.1a163382354 <-
timestamp 12:46:25
12:46:56 Deploying topology manager to .../manager.topo.1a163382351 <-
timestamp 12:46:25
{noformat}
h3. Steps to reproduce
Start the gateway with the default \{{gateway.auto.deploy.topologies}}.
Note that \{{admin.xml}} and \{{manager.xml}} now contain a new
\{{<redeployTime>}}, but no new deployment directory has been created for them.
Touch or edit any other topology.
{\{admin}} and \{{manager}} are redeployed as well.
h3. Expected
Auto-deploy topologies are redeployed during startup, and a later change to an
unrelated topology does not redeploy them.
h3. Possible fix
Do one of the following:
- Start the topology file monitor before the auto-deploy redeploy loop.
- Call \{{monitor.reloadTopologies()}} again after the loop.
- Have \{{redeployTopology}} refresh the in-memory entry after it writes the
file.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)