Skip to content
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

HDDS-2064. OzoneManagerRatisServer#newOMRatisServer throws NPE when OM HA is configured incorrectly #1398

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -279,6 +279,45 @@ public void testWrongConfiguration() throws Exception {
}
}

/**
* A configuration with an empty node list while service ID is configured
* Should successfully start with no NPEs.
* @throws Exception
*/
@Test
public void testNoOMNodes() throws Exception {
String omServiceId = "om-service-test1";
conf.set(OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY, omServiceId);
// Deliberately skip OZONE_OM_NODES_KEY and OZONE_OM_ADDRESS_KEY config

// Should successfully start with no NPEs
startCluster();
}

/**
* A configuration with no OM addresses while service ID is configured.
* Should successfully start with no NPEs.
* @throws Exception
*/
@Test
public void testNoOMAddrs() throws Exception {
String omServiceId = "om-service-test1";

String omNode1Id = "omNode1";
String omNode2Id = "omNode2";
String omNode3Id = "omNode3";
String omNodesKeyValue = omNode1Id + "," + omNode2Id + "," + omNode3Id;
String omNodesKey = OmUtils.addKeySuffixes(
OMConfigKeys.OZONE_OM_NODES_KEY, omServiceId);

conf.set(OMConfigKeys.OZONE_OM_SERVICE_IDS_KEY, omServiceId);
conf.set(omNodesKey, omNodesKeyValue);
// Deliberately skip OZONE_OM_ADDRESS_KEY config

// Should successfully start with no NPEs
startCluster();
}

/**
* Test multiple OM service configuration.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,10 @@ private void loadOMHAConfigs(Configuration conf) {
InetSocketAddress omAddress = OmUtils.getOmAddress(conf);
int ratisPort = conf.getInt(OZONE_OM_RATIS_PORT_KEY,
OZONE_OM_RATIS_PORT_DEFAULT);
// HDDS-2064: this.peerNodes would be null at this point because
// it is not initialized, we want to initialize it as an empty list
// to prevent NPE in OzoneManagerRatisServer#newOMRatisServer.
this.peerNodes = new ArrayList<>();

LOG.info("Configuration either no {} set. Falling back to the default " +
"OM address {}", OZONE_OM_ADDRESS_KEY, omAddress);
Expand Down