Skip to content
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 @@ -51,6 +51,7 @@
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_ACL_ENABLED;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_OPEN_KEY_EXPIRE_THRESHOLD_SECONDS;
import static org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_SECURITY_ENABLED_KEY;
import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
import static org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod.KERBEROS;
import static org.apache.hadoop.test.GenericTestUtils.*;

Expand Down Expand Up @@ -221,4 +222,20 @@ public void testSecureOmInitFailures() throws Exception {
omLogs.clearOutput();
}

/**
* Test om bind socket address.
*/
@Test
public void testSecureOmInitFailure() throws Exception {
OzoneConfiguration config = new OzoneConfiguration(conf);
OMStorage omStorage = new OMStorage(config);
omStorage.setClusterId(clusterId);
omStorage.setScmId(scmId);
omStorage.setOmId(omId);
config.set(OZONE_OM_ADDRESS_KEY, "om-unknown");
LambdaTestUtils.intercept(RuntimeException.class, "Can't get SCM signed" +
" certificate",
() -> OzoneManager.initializeSecurity(config, omStorage));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1373,8 +1373,12 @@ private static void getSCMSignedCert(CertificateClient client,
KeyPair keyPair = new KeyPair(client.getPublicKey(),
client.getPrivateKey());
InetSocketAddress omRpcAdd;

omRpcAdd = OmUtils.getOmAddress(config);
if (omRpcAdd == null || omRpcAdd.getAddress() == null) {
LOG.error("Incorrect om rpc address. omRpcAdd:{}", omRpcAdd);
throw new RuntimeException("Can't get SCM signed certificate. " +
"omRpcAdd: " + omRpcAdd);
}
// Get host name.
String hostname = omRpcAdd.getAddress().getHostName();

Expand All @@ -1387,7 +1391,7 @@ private static void getSCMSignedCert(CertificateClient client,
.setScmID(omStore.getScmId())
.setClusterID(omStore.getClusterID())
.setSubject(subject)
.addIpAddress(omRpcAdd.getAddress().getHostAddress());
.addIpAddress(hostname);

LOG.info("Creating csr for OM->dns:{},ip:{},scmId:{},clusterId:{}," +
"subject:{}", hostname, omRpcAdd.getAddress().getHostAddress(),
Expand All @@ -1396,7 +1400,7 @@ private static void getSCMSignedCert(CertificateClient client,
HddsProtos.OzoneManagerDetailsProto.Builder omDetailsProtoBuilder =
HddsProtos.OzoneManagerDetailsProto.newBuilder()
.setHostName(omRpcAdd.getHostName())
.setIpAddress(omRpcAdd.getAddress().getHostAddress())
.setIpAddress(hostname)
.setUuid(omStore.getOmId())
.addPorts(HddsProtos.Port.newBuilder()
.setName(RPC_PORT)
Expand Down