Skip to content

Commit fbd0613

Browse files
authored
IGNITE-26991 Disable distributed processes during rolling upgrade (#12511)
1 parent 5657fc2 commit fbd0613

File tree

5 files changed

+134
-2
lines changed

5 files changed

+134
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.compatibility.testframework.plugins;
19+
20+
import org.apache.ignite.cluster.ClusterNode;
21+
import org.apache.ignite.internal.GridKernalContext;
22+
import org.apache.ignite.internal.processors.rollingupgrade.RollingUpgradeProcessor;
23+
import org.apache.ignite.spi.IgniteNodeValidationResult;
24+
import org.jetbrains.annotations.Nullable;
25+
26+
/** Disabled rolling upgrade processor. */
27+
public class DisabledRollingUpgradeProcessor extends RollingUpgradeProcessor {
28+
/**
29+
* @param ctx Kernal context.
30+
*/
31+
public DisabledRollingUpgradeProcessor(GridKernalContext ctx) {
32+
super(ctx);
33+
}
34+
35+
/** {@inheritDoc} */
36+
@Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode node) {
37+
return null;
38+
}
39+
}

modules/compatibility/src/test/java/org/apache/ignite/compatibility/testframework/plugins/TestCompatibilityPluginProvider.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,14 @@ public class TestCompatibilityPluginProvider implements PluginProvider {
105105
/** {@inheritDoc} */
106106
@Nullable @Override public Object createComponent(PluginContext ctx, Class cls) {
107107
if (DiscoveryNodeValidationProcessor.class == cls)
108-
return new DisabledValidationProcessor(kCtx);
108+
try {
109+
Class.forName("org.apache.ignite.internal.processors.rollingupgrade.RollingUpgradeProcessor");
110+
111+
return new DisabledRollingUpgradeProcessor(kCtx);
112+
}
113+
catch (ClassNotFoundException ignore) {
114+
return new DisabledValidationProcessor(kCtx);
115+
}
109116

110117
return null;
111118
}

modules/core/src/main/java/org/apache/ignite/internal/util/distributed/DistributedProcess.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.function.BiFunction;
2828
import java.util.function.Function;
2929
import org.apache.ignite.IgniteCheckedException;
30+
import org.apache.ignite.IgniteException;
3031
import org.apache.ignite.IgniteLogger;
3132
import org.apache.ignite.cluster.ClusterNode;
3233
import org.apache.ignite.failure.FailureContext;
@@ -38,6 +39,7 @@
3839
import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
3940
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager;
4041
import org.apache.ignite.internal.util.GridConcurrentHashSet;
42+
import org.apache.ignite.internal.util.future.GridFinishedFuture;
4143
import org.apache.ignite.internal.util.future.GridFutureAdapter;
4244
import org.apache.ignite.internal.util.typedef.CI3;
4345
import org.apache.ignite.internal.util.typedef.F;
@@ -150,7 +152,14 @@ public DistributedProcess(
150152
initCoordinator(p, topVer);
151153

152154
try {
153-
IgniteInternalFuture<R> fut = exec.apply((I)msg.request());
155+
IgniteInternalFuture<R> fut;
156+
157+
if (ctx.rollingUpgrade().enabled()) {
158+
fut = new GridFinishedFuture<>(new IgniteException("Failed to start distributed process "
159+
+ type + ": rolling upgrade is enabled"));
160+
}
161+
else
162+
fut = exec.apply((I)msg.request());
154163

155164
fut.listen(() -> {
156165
if (fut.error() != null)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.ignite.internal.processors.cache.persistence.snapshot;
19+
20+
import org.apache.ignite.IgniteException;
21+
import org.apache.ignite.cluster.ClusterState;
22+
import org.apache.ignite.configuration.DataRegionConfiguration;
23+
import org.apache.ignite.configuration.DataStorageConfiguration;
24+
import org.apache.ignite.configuration.IgniteConfiguration;
25+
import org.apache.ignite.internal.IgniteEx;
26+
import org.apache.ignite.lang.IgniteProductVersion;
27+
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
28+
import org.junit.Test;
29+
30+
import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause;
31+
32+
/** */
33+
public class IgniteSnapshotRollingUpgradeTest extends GridCommonAbstractTest {
34+
/** {@inheritDoc} */
35+
@Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
36+
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
37+
38+
cfg.setDataStorageConfiguration(new DataStorageConfiguration()
39+
.setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
40+
41+
return cfg;
42+
}
43+
44+
/** {@inheritDoc} */
45+
@Override protected void afterTest() throws Exception {
46+
stopAllGrids();
47+
48+
cleanPersistenceDir();
49+
}
50+
51+
/** Tests that snapshot creation fails when rolling upgrade is enabled. */
52+
@Test
53+
public void testSnapshotCreationFailsDuringRollingUpgrade() throws Exception {
54+
IgniteEx srv = startGrid(0);
55+
56+
srv.cluster().state(ClusterState.ACTIVE);
57+
58+
IgniteProductVersion curVer = srv.context().discovery().localNode().version();
59+
60+
IgniteProductVersion targetVer = IgniteProductVersion.fromString(curVer.major()
61+
+ "." + curVer.minor()
62+
+ "." + curVer.maintenance() + 1);
63+
64+
srv.context().rollingUpgrade().enable(targetVer, false);
65+
66+
assertTrue(srv.context().rollingUpgrade().enabled());
67+
68+
Throwable ex = assertThrowsWithCause(
69+
() -> srv.snapshot().createSnapshot("test").get(getTestTimeout()),
70+
IgniteException.class
71+
);
72+
73+
assertTrue(ex.getMessage().contains("Failed to start distributed process START_SNAPSHOT: rolling upgrade is enabled"));
74+
}
75+
}

modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSnapshotTestSuite.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManagerSelfTest;
2929
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotRemoteRequestTest;
3030
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotRestoreFromRemoteTest;
31+
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotRollingUpgradeTest;
3132
import org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotWithMetastorageTest;
3233
import org.apache.ignite.testframework.GridTestUtils;
3334
import org.apache.ignite.testframework.junits.DynamicSuite;
@@ -56,5 +57,6 @@ public static void addSnapshotTests(List<Class<?>> suite, Collection<Class> igno
5657
GridTestUtils.addTestIfNeeded(suite, IgniteClusterSnapshotRestoreSelfTest.class, ignoredTests);
5758
GridTestUtils.addTestIfNeeded(suite, IgniteClusterSnapshotHandlerTest.class, ignoredTests);
5859
GridTestUtils.addTestIfNeeded(suite, IgniteSnapshotRestoreFromRemoteTest.class, ignoredTests);
60+
GridTestUtils.addTestIfNeeded(suite, IgniteSnapshotRollingUpgradeTest.class, ignoredTests);
5961
}
6062
}

0 commit comments

Comments
 (0)