From hdfs-issues-return-285161-archive-asf-public=cust-asf.ponee.io@hadoop.apache.org Wed Sep 25 20:06:03 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 353BB180637 for ; Wed, 25 Sep 2019 22:06:03 +0200 (CEST) Received: (qmail 45584 invoked by uid 500); 25 Sep 2019 20:06:02 -0000 Mailing-List: contact hdfs-issues-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list hdfs-issues@hadoop.apache.org Received: (qmail 45552 invoked by uid 99); 25 Sep 2019 20:06:02 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Sep 2019 20:06:02 +0000 Received: from jira-he-de.apache.org (static.172.67.40.188.clients.your-server.de [188.40.67.172]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 280D4E30C3 for ; Wed, 25 Sep 2019 20:06:01 +0000 (UTC) Received: from jira-he-de.apache.org (localhost.localdomain [127.0.0.1]) by jira-he-de.apache.org (ASF Mail Server at jira-he-de.apache.org) with ESMTP id 40A997807B0 for ; Wed, 25 Sep 2019 20:06:00 +0000 (UTC) Date: Wed, 25 Sep 2019 20:06:00 +0000 (UTC) From: "ASF GitHub Bot (Jira)" To: hdfs-issues@hadoop.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Work logged] (HDDS-2162) Make Kerberos related configuration support HA style config MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HDDS-2162?focusedWorklogId=3D3= 18558&page=3Dcom.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpan= el#worklog-318558 ] ASF GitHub Bot logged work on HDDS-2162: ---------------------------------------- Author: ASF GitHub Bot Created on: 25/Sep/19 20:05 Start Date: 25/Sep/19 20:05 Worklog Time Spent: 10m=20 Work Description: arp7 commented on pull request #1511: HDDS-2162. Ma= ke Kerberos related configuration support HA style config. URL: https://github.com/apache/hadoop/pull/1511#discussion_r328315080 =20 =20 ########## File path: hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozon= e/om/ha/OMHANodeDetails.java ########## @@ -0,0 +1,309 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with t= his + * 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 Lic= ense. + * 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,WITHOU= T + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See th= e + * License for the specific language governing permissions and limitations= under + * the License. + */ + +package org.apache.hadoop.ozone.om.ha; + +import com.google.common.base.Preconditions; +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.hadoop.net.NetUtils; +import org.apache.hadoop.ozone.OmUtils; +import org.apache.hadoop.ozone.OzoneConsts; +import org.apache.hadoop.ozone.OzoneIllegalArgumentException; +import org.apache.hadoop.ozone.om.OMConfigKeys; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY= ; +import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_NODES_KEY; +import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_NODE_ID_KEY= ; +import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RATIS_PORT_= DEFAULT; +import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RATIS_PORT_= KEY; +import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_SERVICE_IDS= _KEY; + +/** + * Class which maintains peer information and it's own OM node information= . + */ +public class OMHANodeDetails { + + public static final Logger LOG =3D + LoggerFactory.getLogger(OMHANodeDetails.class); + private final OMNodeDetails localNodeDetails; + private final List peerNodeDetails; + + public OMHANodeDetails(OMNodeDetails localNodeDetails, + List peerNodeDetails) { + this.localNodeDetails =3D localNodeDetails; + this.peerNodeDetails =3D peerNodeDetails; + } + + public OMNodeDetails getLocalNodeDetails() { + return localNodeDetails; + } + + public List< OMNodeDetails > getPeerNodeDetails() { + return peerNodeDetails; + } + + + /** + * Inspects and loads OM node configurations. + * + * If {@link OMConfigKeys#OZONE_OM_SERVICE_IDS_KEY} is configured with + * multiple ids and/ or if {@link OMConfigKeys#OZONE_OM_NODE_ID_KEY} is = not + * specifically configured , this method determines the omServiceId + * and omNodeId by matching the node's address with the configured + * addresses. When a match is found, it sets the omServicId and omNodeId= from + * the corresponding configuration key. This method also finds the OM pe= ers + * nodes belonging to the same OM service. + * + * @param conf + */ + public static OMHANodeDetails loadOMHAConfig(OzoneConfiguration conf) { + InetSocketAddress localRpcAddress =3D null; + String localOMServiceId =3D null; + String localOMNodeId =3D null; + int localRatisPort =3D 0; + Collection omServiceIds =3D conf.getTrimmedStringCollection( + OZONE_OM_SERVICE_IDS_KEY); + + String knownOMNodeId =3D conf.get(OZONE_OM_NODE_ID_KEY); + int found =3D 0; + boolean isOMAddressSet =3D false; + + for (String serviceId : omServiceIds) { + Collection omNodeIds =3D OmUtils.getOMNodeIds(conf, serviceI= d); + + if (omNodeIds.size() =3D=3D 0) { + String msg =3D "Configuration does not have any value set for " + + OZONE_OM_NODES_KEY + " for service ID " + serviceId + ". List = of " + + "OM Node ID's should be specified for the service ID"; + throw new OzoneIllegalArgumentException(msg); + } + + List peerNodesList =3D new ArrayList<>(); + boolean isPeer; + for (String nodeId : omNodeIds) { + if (knownOMNodeId !=3D null && !knownOMNodeId.equals(nodeId)) { + isPeer =3D true; + } else { + isPeer =3D false; + } + String rpcAddrKey =3D OmUtils.addKeySuffixes(OZONE_OM_ADDRESS_KEY, + serviceId, nodeId); + String rpcAddrStr =3D OmUtils.getOmRpcAddress(conf, rpcAddrKey); + if (rpcAddrStr =3D=3D null) { + String msg =3D "Configuration does not have any value set for " = + + rpcAddrKey + "." + "OM Rpc Address should be set for all nod= e " + + "IDs for a service ID."; + throw new OzoneIllegalArgumentException(msg); + } + + // If OM address is set for any node id, we will not fallback to t= he + // default + isOMAddressSet =3D true; + + String ratisPortKey =3D OmUtils.addKeySuffixes(OZONE_OM_RATIS_PORT= _KEY, + serviceId, nodeId); + int ratisPort =3D conf.getInt(ratisPortKey, OZONE_OM_RATIS_PORT_DE= FAULT); + + InetSocketAddress addr =3D null; + try { + addr =3D NetUtils.createSocketAddr(rpcAddrStr); + } catch (Exception e) { + LOG.warn("Exception in creating socket address " + addr, e); + continue; + } + if (!addr.isUnresolved()) { + if (!isPeer && OmUtils.isAddressLocal(addr)) { + localRpcAddress =3D addr; + localOMServiceId =3D serviceId; + localOMNodeId =3D nodeId; + localRatisPort =3D ratisPort; + found++; + } else { + // This OMNode belongs to same OM service as the current OMNod= e. + // Add it to peerNodes list. + // This OMNode belongs to same OM service as the current OMNod= e. + // Add it to peerNodes list. + peerNodesList.add(getHAOMNodeDetails(conf, serviceId, + nodeId, addr, ratisPort)); + } + } + } + if (found =3D=3D 1) { + LOG.debug("Found one matching OM address with service ID: {} and n= ode" + + " ID: {}", localOMServiceId, localOMNodeId); + + LOG.info("Found matching OM address with OMServiceId: {}, " + + "OMNodeId: {}, RPC Address: {} and Ratis port: {}", + localOMServiceId, localOMNodeId, + NetUtils.getHostPortString(localRpcAddress), localRatisPort); + + + setOMNodeSpecificConfigs(conf, localOMServiceId, localOMNodeId); + return new OMHANodeDetails(getHAOMNodeDetails(conf, localOMService= Id, + localOMNodeId, localRpcAddress, localRatisPort), peerNodesList= ); + + } else if (found > 1) { + String msg =3D "Configuration has multiple " + OZONE_OM_ADDRESS_KE= Y + + " addresses that match local node's address. Please configure = the" + + " system with " + OZONE_OM_SERVICE_IDS_KEY + " and " + + OZONE_OM_ADDRESS_KEY; + throw new OzoneIllegalArgumentException(msg); + } + } + + if (!isOMAddressSet) { + // No OM address is set. Fallback to default + InetSocketAddress omAddress =3D OmUtils.getOmAddress(conf); + int ratisPort =3D conf.getInt(OZONE_OM_RATIS_PORT_KEY, + OZONE_OM_RATIS_PORT_DEFAULT); + + LOG.info("Configuration either no {} set. Falling back to the defaul= t " + + "OM address {}", OZONE_OM_ADDRESS_KEY, omAddress); + + return new OMHANodeDetails(getOMNodeDetails(conf, null, + null, omAddress, ratisPort), new ArrayList<>()); + + } else { + String msg =3D "Configuration has no " + OZONE_OM_ADDRESS_KEY + " " = + + "address that matches local node's address. Please configure the= " + + "system with " + OZONE_OM_ADDRESS_KEY; + LOG.info(msg); + throw new OzoneIllegalArgumentException(msg); + } + } + + /** + * Create Local OM Node Details. + * @param serviceId - Service ID this OM belongs to, + * @param nodeId - Node ID of this OM. + * @param rpcAddress - Rpc Address of the OM. + * @param ratisPort - Ratis port of the OM. + * @return OMNodeDetails + */ + public static OMNodeDetails getOMNodeDetails(OzoneConfiguration conf, + String serviceId, String nodeId, InetSocketAddress rpcAddress, + int ratisPort) { + + if (serviceId =3D=3D null) { + // If no serviceId is set, take the default serviceID om-service + serviceId =3D OzoneConsts.OM_SERVICE_ID_DEFAULT; + LOG.info("OM Service ID is not set. Setting it to the default ID: {}= ", =20 Review comment: What is the benefit of setting the default service ID? =20 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. =20 For queries about this service, please contact Infrastructure at: users@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 318558) Time Spent: 1h 20m (was: 1h 10m) > Make Kerberos related configuration support HA style config > ----------------------------------------------------------- > > Key: HDDS-2162 > URL: https://issues.apache.org/jira/browse/HDDS-2162 > Project: Hadoop Distributed Data Store > Issue Type: Sub-task > Reporter: Bharat Viswanadham > Assignee: Bharat Viswanadham > Priority: Major > Labels: pull-request-available > Time Spent: 1h 20m > Remaining Estimate: 0h > > To have a single configuration to use across OM cluster, few of the confi= gs like=C2=A0 > OZONE_OM_KERBEROS_KEYTAB_FILE_KEY, > OZONE_OM_KERBEROS_PRINCIPAL_KEY, > OZONE_OM_HTTP_KERBEROS_KEYTAB_FILE, > OZONE_OM_HTTP_KERBEROS_PRINCIPAL_KEY need to support configs which append= with service id and node id. > =C2=A0 > Addressed OM_DB_DIRS, OZONE_OM_ADDRESS_KEY also in this patch. > =C2=A0 > This Jira is to fix the above configs. > =C2=A0 -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscribe@hadoop.apache.org For additional commands, e-mail: hdfs-issues-help@hadoop.apache.org