Tamás Hanicz created KNOX-3528:
----------------------------------

             Summary: DeploymentFactory mutates the cached Topology, so 
topologies without an identity-assertion provider are marked UPDATED on every 
reload
                 Key: KNOX-3528
                 URL: https://issues.apache.org/jira/browse/KNOX-3528
             Project: Apache Knox
          Issue Type: Bug
          Components: Server
    Affects Versions: 3.0.0
            Reporter: Tamás Hanicz
            Assignee: Tamás Hanicz


When any file in the topologies directory changes, every topology that does not 
declare an \{{identity-assertion}} provider gets an UPDATED event and is 
reactivated, even if its file has not changed.

h3. Root cause

{\{DeploymentFactory.selectContextProviders()}} calls 
\{{addMissingDefaultProviders(topology)}}. If the topology has no 
\{{identity-assertion}} provider, that method adds a \{{Default}} one directly 
to \{{topology.getProviders()}}.

That \{{Topology}} instance is the same object \{{DefaultTopologyService}} 
stores in its in-memory topology map, because it is passed through the 
\{{TopologyEvent}} into \{{GatewayServer.handleCreateDeployment}} and 
\{{DeploymentFactory.createDeployment}}. After the first deployment, the stored 
copy has one more provider than a topology freshly parsed from the unchanged 
file.

On the next \{{reloadTopologies()}}, \{{shouldMarkTopologyUpdated()}} sees 
\{{!oldTopology.equals(newTopology)}} because \{{equalProviders}} fails, and 
emits UPDATED regardless of 
\{{gateway.topology.redeployment.requires.changes}}. The deployment directory 
already exists for the unchanged timestamp, so the gateway reactivates the 
topology ("Loading topology X from ...") rather than building a new one. That 
is still a deactivate/activate cycle for a topology that did not change.

h3. Example

{\{metadata.xml}} has not been modified since deployment and has no 
\{{identity-assertion}} provider. A change to \{{health.xml}} produces:
{noformat}
INFO  ... Loading topology metadata from 
.../data/deployments/metadata.topo.16fcdcdcfd8
INFO  ... Activating topology metadata
{noformat}

h3. Steps to reproduce

Deploy a topology with no \{{identity-assertion}} provider, for example the 
shipped \{{metadata.xml}}.

Modify a different topology.

The first topology is reactivated even though its file has not changed.

h3. Expected

A topology whose file has not changed is not marked UPDATED. Adding default 
providers at deploy time does not change the cached \{{Topology}} used for 
change detection.

h3. Possible fix

Do one of the following:
- Apply \{{addMissingDefaultProviders}} to a copy of the topology, or keep the 
added default provider in the deployment context only.
- Have \{{DefaultTopologyService}} keep its own parsed copy that is never 
handed out for deployment.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to