chesnokoff commented on code in PR #12301:
URL: https://github.com/apache/ignite/pull/12301#discussion_r2426726665


##########
modules/core/src/main/java/org/apache/ignite/internal/processors/nodevalidation/OsDiscoveryNodeValidationProcessor.java:
##########
@@ -32,42 +38,85 @@
  * Node validation.
  */
 public class OsDiscoveryNodeValidationProcessor extends GridProcessorAdapter 
implements DiscoveryNodeValidationProcessor {
+    /** Key for the distributed property that holds current and target 
versions. */
+    public static final String ROLL_UP_VERSIONS = "rolling.upgrade.versions";
+
+    /** Distributed property that holds current and target version. */
+    private final AtomicReference<IgnitePair<IgniteProductVersion>> 
verPairHolder = new AtomicReference<>();
+
     /**
      * @param ctx Kernal context.
      */
     public OsDiscoveryNodeValidationProcessor(GridKernalContext ctx) {
         super(ctx);
+
+        
ctx.internalSubscriptionProcessor().registerDistributedMetastorageListener(new 
DistributedMetastorageLifecycleListener() {
+            @Override public void 
onReadyForRead(ReadableDistributedMetaStorage metastorage) {
+                try {
+                    IgnitePair<IgniteProductVersion> pair = 
metastorage.read(ROLL_UP_VERSIONS);
+
+                    if (verPairHolder.compareAndSet(null, pair) && 
log.isDebugEnabled())
+                        log.debug("Read current and target versions from 
metastore: " + pair);
+                }
+                catch (IgniteCheckedException e) {
+                    if (log.isDebugEnabled())
+                        log.debug("Could not read current and target versions: 
" + e.getMessage());
+                }
+
+                metastorage.listen(ROLL_UP_VERSIONS::equals, (key, oldVal, 
newVal) ->
+                    
verPairHolder.compareAndSet((IgnitePair<IgniteProductVersion>)oldVal, 
(IgnitePair<IgniteProductVersion>)newVal)
+                );
+            }
+        });
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public IgniteNodeValidationResult 
validateNode(ClusterNode node) {
         ClusterNode locNode = ctx.discovery().localNode();
 
-        // Check version.
         String locBuildVer = locNode.attribute(ATTR_BUILD_VER);
         String rmtBuildVer = node.attribute(ATTR_BUILD_VER);
 
-        if (!Objects.equals(rmtBuildVer, locBuildVer)) {
-            // OS nodes don't support rolling updates.
-            if (!locBuildVer.equals(rmtBuildVer)) {
-                String errMsg = "Local node and remote node have different 
version numbers " +
-                    "(node will not join, Ignite does not support rolling 
updates, " +
-                    "so versions must be exactly the same) " +
-                    "[locBuildVer=" + locBuildVer + ", rmtBuildVer=" + 
rmtBuildVer +
-                    ", locNodeAddrs=" + U.addressesAsString(locNode) +
-                    ", rmtNodeAddrs=" + U.addressesAsString(node) +
-                    ", locNodeId=" + locNode.id() + ", rmtNodeId=" + node.id() 
+ ']';
+        IgniteProductVersion rmtVer = 
IgniteProductVersion.fromString(rmtBuildVer);
 
-                LT.warn(log, errMsg);
+        IgnitePair<IgniteProductVersion> pair = verPairHolder.get();
 
-                // Always output in debug.
-                if (log.isDebugEnabled())
-                    log.debug(errMsg);
+        if (pair == null)
+            pair = F.pair(IgniteProductVersion.fromString(locBuildVer), null);

Review Comment:
   My suggestion is to implement logic with locNodeVer + loc store before the 
Processor



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to