Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
780bfe8
IGNITE-26748 Add commands for control.sh
chesnokoff Nov 4, 2025
3431693
IGNITE-26748 Small fixes
chesnokoff Nov 5, 2025
9b50aef
IGNITE-26748 Update javadoc
chesnokoff Nov 5, 2025
6a59cf1
IGNITE-26748 Remove useless class
chesnokoff Nov 5, 2025
eb71e24
IGNITE-26748 Add more asserts
chesnokoff Nov 5, 2025
9139c32
IGNITE-26748 Add doc
chesnokoff Nov 5, 2025
7732599
IGNITE-26748 Extract RU args
chesnokoff Nov 5, 2025
c1b20b1
IGNITE-26699 Add RollingUpgradeTaskResult
chesnokoff Nov 5, 2025
9d7732e
IGNITE-26699 Update target-version flag
chesnokoff Nov 5, 2025
08e7249
IGNITE-26748 Add experimental flag
chesnokoff Nov 5, 2025
ef3d269
IGNITE-26748 Fix style
chesnokoff Nov 5, 2025
47fd796
IGNITE-26748 Fix test
chesnokoff Nov 5, 2025
f91df3c
IGNITE-26748 Update exception to catch
chesnokoff Nov 6, 2025
010e244
IGNITE-26748 Update tests
chesnokoff Nov 6, 2025
ddf4b39
IGNITE-26748 Update nodes method
chesnokoff Nov 6, 2025
a8d30a2
IGNITE-26748 Split Enable and Disable tasks
chesnokoff Nov 6, 2025
dff10f5
IGNITE-26748 Add warning about same versions of nodes
chesnokoff Nov 6, 2025
9246c33
IGNITE-26748 Replace IgnitePair with two fields
chesnokoff Nov 6, 2025
d17a44e
IGNITE-26748 Fix help logs
chesnokoff Nov 6, 2025
94a396f
IGNITE-26748 Add more info about enable command
chesnokoff Nov 6, 2025
8f9c98a
IGNITE-26748 Make targetVersion positional
chesnokoff Nov 6, 2025
68c9f01
IGNITE-26748 Replace Throwable error with String errMsg
chesnokoff Nov 6, 2025
4afe3ab
IGNITE-26748 Remove target version flag from test
chesnokoff Nov 6, 2025
9443bc6
IGNITE-26748 Remove enabled field from result
chesnokoff Nov 6, 2025
db5e9a8
IGNITE-26748 Fix style
chesnokoff Nov 6, 2025
27762a2
IGNITE-26748 Fix style
chesnokoff Nov 6, 2025
40841dd
IGNITE-26748 Fix style
chesnokoff Nov 6, 2025
1ebca3d
Revert "IGNITE-26748 Add more info about enable command"
chesnokoff Nov 6, 2025
1db2c0f
IGNITE-26748 Add confirmationPrompt
chesnokoff Nov 6, 2025
ded0809
IGNITE-26748 Fix output
chesnokoff Nov 6, 2025
d7ce36b
IGNITE-26748 Add autoConf
chesnokoff Nov 6, 2025
2b488a7
IGNITE-26748 Fix descriptions
chesnokoff Nov 6, 2025
eac64bc
IGNITE-26748 Add more info for disable result
chesnokoff Nov 6, 2025
069262e
IGNITE-26748 Fix tests
chesnokoff Nov 6, 2025
a5e2562
IGNITE-26748 Update prompt
chesnokoff Nov 6, 2025
9c68bc4
IGNITE-26748 Fix checkParseAutoConfirmationFlag
chesnokoff Nov 6, 2025
c41d4dc
IGNITE-26748 Add details about target version
chesnokoff Nov 7, 2025
12d78c1
IGNITE-26748 Add details about target version (examples)
chesnokoff Nov 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import org.apache.ignite.internal.management.metric.MetricCommand;
import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand;
import org.apache.ignite.internal.management.property.PropertyCommand;
import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand;
import org.apache.ignite.internal.management.snapshot.SnapshotCommand;
import org.apache.ignite.internal.management.snapshot.SnapshotRestoreCommand;
import org.apache.ignite.internal.management.tx.TxCommand;
Expand Down Expand Up @@ -1391,6 +1392,7 @@ private boolean requireArgs(Class<?> cmd) {
cmd == MetaCommand.class ||
cmd == WarmUpCommand.class ||
cmd == PropertyCommand.class ||
cmd == RollingUpgradeCommand.class ||
cmd == SystemViewCommand.class ||
cmd == MetricCommand.class ||
cmd == DefragmentationCommand.class ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.apache.ignite.util.IdleVerifyDumpTest;
import org.apache.ignite.util.MetricCommandTest;
import org.apache.ignite.util.PerformanceStatisticsCommandTest;
import org.apache.ignite.util.RollingUpgradeCommandTest;
import org.apache.ignite.util.SystemViewCommandTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
Expand All @@ -63,6 +64,7 @@
GridCommandHandlerConsistencySensitiveTest.class,
GridCommandHandlerConsistencyRepairCorrectnessAtomicTest.class,

RollingUpgradeCommandTest.class,
SystemViewCommandTest.class,
MetricCommandTest.class,
PerformanceStatisticsCommandTest.class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.util;

import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand;
import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeTaskResult;
import org.apache.ignite.internal.util.lang.IgnitePair;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.lang.IgniteProductVersion;
import org.junit.Test;

import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_BUILD_VER;
import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK;

/** Tests {@link RollingUpgradeCommand} command. */
public class RollingUpgradeCommandTest extends GridCommandHandlerClusterByClassAbstractTest {
/** */
public static final String ENABLE = "enable";

/** */
public static final String DISABLE = "disable";

/** */
public static final String ROLLING_UPGRADE = "--rolling-upgrade";

/** */
public static final String TARGET_VERSION = "--target-version";

/** */
@Test
public void testEnableAndDisable() {
IgniteProductVersion curVer = IgniteProductVersion.fromString(crd.localNode().attribute(ATTR_BUILD_VER));

String targetVerStr = curVer.major() + "." + (curVer.minor() + 1) + ".0";
IgniteProductVersion targetVer = IgniteProductVersion.fromString(targetVerStr);

int res = execute(ROLLING_UPGRADE, ENABLE, TARGET_VERSION, targetVerStr);

assertEquals(EXIT_CODE_OK, res);

RollingUpgradeTaskResult taskRes = (RollingUpgradeTaskResult)lastOperationResult;

assertNotNull(taskRes);
assertNull(taskRes.exception());
assertTrue(taskRes.enabled());

IgnitePair<IgniteProductVersion> versions = taskRes.rollUpVers();

assertNotNull(versions);
assertEquals(curVer, versions.get1());
assertEquals(targetVer, versions.get2());

assertTrue(crd.context().rollingUpgrade().enabled());

res = execute(ROLLING_UPGRADE, DISABLE);

assertEquals(EXIT_CODE_OK, res);

taskRes = (RollingUpgradeTaskResult)lastOperationResult;

assertNotNull(taskRes);
assertFalse(taskRes.enabled());
assertNull(taskRes.exception());
assertNull(taskRes.rollUpVers());

assertFalse(crd.context().rollingUpgrade().enabled());
}

/** */
@Test
public void testDoubleDisable() {
int res = execute(ROLLING_UPGRADE, DISABLE);

assertEquals(EXIT_CODE_OK, res);
RollingUpgradeTaskResult taskRes = (RollingUpgradeTaskResult)lastOperationResult;

assertNotNull(taskRes);
assertFalse(taskRes.enabled());
assertNull(taskRes.exception());

res = execute(ROLLING_UPGRADE, DISABLE);

assertEquals(EXIT_CODE_OK, res);
taskRes = (RollingUpgradeTaskResult)lastOperationResult;

assertNotNull(taskRes);
assertFalse(taskRes.enabled());
assertNull(taskRes.exception());
assertNull(taskRes.rollUpVers());
assertFalse(crd.context().rollingUpgrade().enabled());
}

/** */
@Test
public void testEnableWithDifferentTargetVersions() {
IgniteProductVersion curVer = IgniteProductVersion.fromString(crd.localNode().attribute(ATTR_BUILD_VER));

String targetVerStr = curVer.major() + "." + (curVer.minor() + 1) + ".0";
IgniteProductVersion targetVer = IgniteProductVersion.fromString(targetVerStr);

execute(ROLLING_UPGRADE, ENABLE, TARGET_VERSION, targetVerStr);

String anotherTargetVerStr = curVer.major() + "." + curVer.minor() + "." + (curVer.maintenance() + 1);

int res = execute(ROLLING_UPGRADE, ENABLE, TARGET_VERSION, anotherTargetVerStr);

assertEquals(EXIT_CODE_OK, res);
RollingUpgradeTaskResult taskRes = (RollingUpgradeTaskResult)lastOperationResult;

assertNotNull(taskRes);
assertNotNull(taskRes.exception());
assertTrue(X.hasCause(taskRes.exception(),
"Rolling upgrade is already enabled with a different current and target version",
IgniteCheckedException.class));
assertTrue(taskRes.enabled());
assertEquals(targetVer, taskRes.rollUpVers().get2());

assertTrue(crd.context().rollingUpgrade().enabled());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.ignite.internal.management.performancestatistics.PerformanceStatisticsCommand;
import org.apache.ignite.internal.management.persistence.PersistenceCommand;
import org.apache.ignite.internal.management.property.PropertyCommand;
import org.apache.ignite.internal.management.rollingupgrade.RollingUpgradeCommand;
import org.apache.ignite.internal.management.snapshot.SnapshotCommand;
import org.apache.ignite.internal.management.tracing.TracingConfigurationCommand;
import org.apache.ignite.internal.management.tx.TxCommand;
Expand Down Expand Up @@ -67,6 +68,7 @@ public IgniteCommandRegistry() {
new TracingConfigurationCommand(),
new WarmUpCommand(),
new PropertyCommand(),
new RollingUpgradeCommand(),
new SystemViewCommand(),
new MetricCommand(),
new PersistenceCommand(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.management.rollingupgrade;

import org.apache.ignite.internal.management.api.CommandRegistryImpl;

/** Rolling upgrade commands. */
public class RollingUpgradeCommand extends CommandRegistryImpl {
/** */
public RollingUpgradeCommand() {
super(
new RollingUpgradeEnableCommand(),
new RollingUpgradeDisableCommand()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.management.rollingupgrade;

import java.util.Collection;
import java.util.function.Consumer;
import org.apache.ignite.IgniteException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.internal.management.api.ComputeCommand;
import org.apache.ignite.internal.management.api.NoArg;
import org.apache.ignite.lang.IgniteExperimental;

import static org.apache.ignite.internal.management.api.CommandUtils.coordinatorOrNull;

/** Command to disable rolling upgrade mode. */
@IgniteExperimental
public class RollingUpgradeDisableCommand implements ComputeCommand<NoArg, RollingUpgradeTaskResult> {
/** {@inheritDoc} */
@Override public String description() {
return "Disable rolling upgrade";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's mention that all nodes in cluster must be the same version.

}

/** {@inheritDoc} */
@Override public Class<NoArg> argClass() {
return NoArg.class;
}

/** {@inheritDoc} */
@Override public Class<RollingUpgradeDisableTask> taskClass() {
return RollingUpgradeDisableTask.class;
}

/** {@inheritDoc} */
@Override public void printResult(NoArg arg, RollingUpgradeTaskResult res, Consumer<String> printer) {
if (res.exception() != null) {
printer.accept("Failed to disable rolling upgrade: " + res.exception().getMessage());
return;
}

printer.accept("Rolling upgrade disabled");
}

/** {@inheritDoc} */
@Override public Collection<ClusterNode> nodes(Collection<ClusterNode> nodes, NoArg arg) {
Collection<ClusterNode> coordinator = coordinatorOrNull(nodes);

if (coordinator == null)
throw new IgniteException("Could not find coordinator among nodes: " + nodes);

return coordinator;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.ignite.internal.management.rollingupgrade;

import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteException;
import org.apache.ignite.internal.management.api.NoArg;
import org.apache.ignite.internal.processors.rollingupgrade.RollingUpgradeProcessor;
import org.apache.ignite.internal.processors.task.GridInternal;
import org.apache.ignite.internal.visor.VisorJob;
import org.apache.ignite.internal.visor.VisorOneNodeTask;

/** Task to disable rolling upgrade. */
@GridInternal
public class RollingUpgradeDisableTask extends VisorOneNodeTask<NoArg, RollingUpgradeTaskResult> {
/** */
private static final long serialVersionUID = 0L;

/** {@inheritDoc} */
@Override protected VisorJob<NoArg, RollingUpgradeTaskResult> job(NoArg arg) {
return new RollingUpgradeDisableJob(arg, debug);
}

/** */
private static class RollingUpgradeDisableJob extends VisorJob<NoArg, RollingUpgradeTaskResult> {
/** */
private static final long serialVersionUID = 0L;

/** */
protected RollingUpgradeDisableJob(NoArg arg, boolean debug) {
super(arg, debug);
}

/** {@inheritDoc} */
@Override protected RollingUpgradeTaskResult run(NoArg arg) throws IgniteException {
RollingUpgradeProcessor proc = ignite.context().rollingUpgrade();

try {
proc.disable();

return new RollingUpgradeTaskResult(proc.enabled(), proc.versions(), null);
}
catch (IgniteCheckedException e) {
return new RollingUpgradeTaskResult(proc.enabled(), proc.versions(), e);
}
}
}
}
Loading