This is an automated email from the ASF dual-hosted git repository.
kturner pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/2.1 by this push:
new 9fcadd263e fail upgrade prepare on table props and improve upgrade
help (#5888)
9fcadd263e is described below
commit 9fcadd263ef850f77a185907927506ac12db09b8
Author: Keith Turner <[email protected]>
AuthorDate: Thu Sep 18 17:05:44 2025 -0400
fail upgrade prepare on table props and improve upgrade help (#5888)
Co-authored-by: Dave Marion <[email protected]>
Co-authored-by: Christopher Tubbs <[email protected]>
---
.../java/org/apache/accumulo/core/cli/Help.java | 10 +++-
.../accumulo/core/conf/SiteConfiguration.java | 9 ++++
.../apache/accumulo/server/util/UpgradeUtil.java | 59 +++++++++++++++++++++-
3 files changed, 75 insertions(+), 3 deletions(-)
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/Help.java
b/core/src/main/java/org/apache/accumulo/core/cli/Help.java
index 6ba1d4c575..c5a4cb9f3d 100644
--- a/core/src/main/java/org/apache/accumulo/core/cli/Help.java
+++ b/core/src/main/java/org/apache/accumulo/core/cli/Help.java
@@ -18,6 +18,8 @@
*/
package org.apache.accumulo.core.cli;
+import java.util.function.Consumer;
+
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
@@ -26,8 +28,10 @@ public class Help {
@Parameter(names = {"-h", "-?", "--help", "-help"}, help = true)
public boolean help = false;
- public void parseArgs(String programName, String[] args, Object... others) {
+ public void parseArgs(Consumer<JCommander> jcConsumer, String programName,
String[] args,
+ Object... others) {
JCommander commander = new JCommander();
+ jcConsumer.accept(commander);
commander.addObject(this);
for (Object other : others) {
commander.addObject(other);
@@ -45,6 +49,10 @@ public class Help {
}
}
+ public void parseArgs(String programName, String[] args, Object... others) {
+ parseArgs(jCommander -> {}, programName, args, others);
+ }
+
public void exit(int status) {
System.exit(status);
}
diff --git
a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
index 2a54943217..bfb2501325 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/SiteConfiguration.java
@@ -32,6 +32,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Predicate;
+import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.configuration2.AbstractConfiguration;
@@ -214,6 +215,14 @@ public class SiteConfiguration extends
AccumuloConfiguration {
private SiteConfiguration(Map<String,String> config) {
ConfigCheckUtil.validate(config.entrySet(), "site config");
+ var tableProps =
+ config.keySet().stream().filter(prop ->
prop.startsWith(Property.TABLE_PREFIX.getKey()))
+ .collect(Collectors.toSet());
+ if (!tableProps.isEmpty()) {
+ log.warn(
+ "Setting table properties in accumulo.properties file or with -o
option is deprecated, saw: {}",
+ tableProps);
+ }
this.config = config;
}
diff --git
a/server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java
b/server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java
index 261377a742..b4d6002a36 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/UpgradeUtil.java
@@ -18,6 +18,9 @@
*/
package org.apache.accumulo.server.util;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.cli.ConfigOpts;
import org.apache.accumulo.core.conf.Property;
@@ -37,6 +40,7 @@ import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.beust.jcommander.DefaultUsageFormatter;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.google.auto.service.AutoService;
@@ -63,13 +67,44 @@ public class UpgradeUtil implements KeywordExecutable {
return "utility used to perform various upgrade steps for an Accumulo
instance";
}
+ private static class UpgradeUsageFormatter extends DefaultUsageFormatter {
+
+ public UpgradeUsageFormatter(JCommander commander) {
+ super(commander);
+ }
+
+ @Override
+ public void appendMainLine(StringBuilder out, boolean hasOptions, boolean
hasCommands,
+ int indentCount, String indent) {
+ super.appendMainLine(out, hasOptions, hasCommands, indentCount, indent);
+
+ out.append("\n");
+ out.append(indent)
+ .append(" The upgrade command is intended to be used in the
following way :\n");
+ out.append(indent).append(" 1. Stop older version of accumulo\n");
+ out.append(indent)
+ .append(" 2. Run 'accumulo upgrade --prepare' using the older
version of accumulo\n");
+ out.append(indent).append(" 3. Setup the newer version of the
accumulo software\n");
+ out.append(indent)
+ .append(" 4. Run 'accumulo upgrade --start' using the newer
version of accumulo\n");
+ out.append(indent).append(
+ " 5. Start accumulo using the newer version and let the manager
complete the upgrade\n");
+ out.append("\n");
+ }
+ }
+
@Override
public void execute(String[] args) throws Exception {
Opts opts = new Opts();
- opts.parseArgs(keyword(), args);
+ opts.parseArgs(
+ jCommander -> jCommander.setUsageFormatter(new
UpgradeUsageFormatter(jCommander)),
+ keyword(), args);
if (!opts.prepare) {
- new JCommander(opts).usage();
+ var jc = new JCommander(opts);
+ jc.setProgramName(keyword());
+ jc.setUsageFormatter(new UpgradeUsageFormatter(jc));
+ jc.usage();
return;
}
@@ -85,6 +120,26 @@ public class UpgradeUtil implements KeywordExecutable {
ZooReaderWriter zoo = new ZooReaderWriter(siteConf);
if (opts.prepare) {
+ SortedMap<String,String> tablePropsInSite = new TreeMap<>();
+ // get table props in site conf excluding default config
+ siteConf.getProperties(tablePropsInSite,
+ key -> key.startsWith(Property.TABLE_PREFIX.getKey()), false);
+
+ if (!tablePropsInSite.isEmpty()) {
+ LOG.warn("Saw table properties in accumulo.properties file : {} ",
+ tablePropsInSite.keySet());
+ throw new IllegalStateException("Did not start upgrade preparation
because table properties"
+ + " are present in the accumulo.properties which may cause later
versions to fail. Recommended action"
+ + " is to set these properties at the system, namespace, or table
level if still needed."
+ + " This can be done by starting accumulo and using the shell/api,
or using the 'accumulo"
+ + " zoo-prop-editor' command. The accumulo.properties file is the
lowest level of configuration, so when moving"
+ + " properties consider if they will override something at a
higher level. For example"
+ + " if moving a property to the namespace level, check if its set
at the system level.");
+ }
+ LOG.info(
+ "Please examine the the accumulo.properties files across your
cluster to ensure none "
+ + "have table properties that could cause later versions to
fail.");
+
final String zUpgradepath = Constants.ZROOT + "/" + iid +
Constants.ZPREPARE_FOR_UPGRADE;
try {
if (zoo.exists(zUpgradepath)) {