-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove references to LegacyESVersion.V_7x constants #2151
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,49 +26,23 @@ | |
|
||
package org.opensearch.security.configuration; | ||
|
||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
import org.opensearch.LegacyESVersion; | ||
import org.opensearch.cluster.ClusterChangedEvent; | ||
import org.opensearch.cluster.ClusterState; | ||
import org.opensearch.cluster.ClusterStateListener; | ||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.cluster.node.DiscoveryNodes; | ||
import org.opensearch.index.Index; | ||
|
||
public class ClusterInfoHolder implements ClusterStateListener { | ||
|
||
protected final Logger log = LogManager.getLogger(this.getClass()); | ||
private volatile Boolean has6xNodes = null; | ||
private volatile Boolean has6xIndices = null; | ||
private volatile DiscoveryNodes nodes = null; | ||
private volatile Boolean isLocalNodeElectedClusterManager = null; | ||
private volatile boolean initialized; | ||
|
||
@Override | ||
public void clusterChanged(ClusterChangedEvent event) { | ||
final boolean isTraceEnabled = log.isTraceEnabled(); | ||
if(has6xNodes == null || event.nodesChanged()) { | ||
has6xNodes = Boolean.valueOf(clusterHas6xNodes(event.state())); | ||
if (isTraceEnabled) { | ||
log.trace("has6xNodes: {}", has6xNodes); | ||
} | ||
} | ||
|
||
final List<String> indicesCreated = event.indicesCreated(); | ||
final List<Index> indicesDeleted = event.indicesDeleted(); | ||
if(has6xIndices == null || !indicesCreated.isEmpty() || !indicesDeleted.isEmpty()) { | ||
has6xIndices = Boolean.valueOf(clusterHas6xIndices(event.state())); | ||
if (isTraceEnabled) { | ||
log.trace("has6xIndices: {}", has6xIndices); | ||
} | ||
} | ||
|
||
if(nodes == null || event.nodesChanged()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only need to track when nodes change now not also when indices are created & deleted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose of this code is to log if there are 6.X nodes or indices in the cluster upon change (node was added/removed from the cluster or an index was created or deleted). If its not possible to run es 6.X nodes with os 3.X then this code will never be used. |
||
nodes = event.state().nodes(); | ||
if (log.isDebugEnabled()) { | ||
|
@@ -80,14 +54,6 @@ public void clusterChanged(ClusterChangedEvent event) { | |
isLocalNodeElectedClusterManager = event.localNodeClusterManager()?Boolean.TRUE:Boolean.FALSE; | ||
} | ||
|
||
public Boolean getHas6xNodes() { | ||
return has6xNodes; | ||
} | ||
|
||
public Boolean getHas6xIndices() { | ||
return has6xIndices; | ||
} | ||
|
||
public Boolean isLocalNodeElectedClusterManager() { | ||
return isLocalNodeElectedClusterManager; | ||
} | ||
|
@@ -106,19 +72,4 @@ public Boolean hasNode(DiscoveryNode node) { | |
|
||
return nodes.nodeExists(node)?Boolean.TRUE:Boolean.FALSE; | ||
} | ||
|
||
private static boolean clusterHas6xNodes(ClusterState state) { | ||
cliu123 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return state.nodes().getMinNodeVersion().before(LegacyESVersion.V_7_0_0); | ||
} | ||
|
||
private static boolean clusterHas6xIndices(ClusterState state) { | ||
final Iterator<IndexMetadata> indices = state.metadata().indices().valuesIt(); | ||
while (indices.hasNext()) { | ||
final IndexMetadata indexMetadata = indices.next(); | ||
if (indexMetadata.getCreationVersion().before(LegacyESVersion.V_7_0_0)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,11 +100,6 @@ protected void handlePost(RestChannel channel, RestRequest request, Client clien | |
|
||
final Version oldestNodeVersion = cs.state().getNodes().getMinNodeVersion(); | ||
|
||
if(oldestNodeVersion.before(LegacyESVersion.V_7_0_0)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of removing this, should we be replacing it with oldest that we currently support? |
||
badRequestResponse(channel, "Can not migrate configuration because cluster is not fully migrated."); | ||
return; | ||
} | ||
|
||
final SecurityDynamicConfiguration<?> loadedConfig = load(CType.CONFIG, true); | ||
|
||
if (loadedConfig.getVersion() != 1) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would this change achieve and does it break anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class was removed in 3.0.0. I followed the docstring
See: https://github.com/opensearch-project/OpenSearch/pull/4702/files#diff-a8affa0470501c9cb284bfbd66f00d493fc72bf05d12e4e2c89bfda6fe814371L47