adoroszlai commented on code in PR #3186:
URL: https://github.com/apache/ozone/pull/3186#discussion_r886904261
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManagerImpl.java:
##########
@@ -419,6 +420,45 @@ public void closePipeline(Pipeline pipeline, boolean
onTimeout)
}
}
+ /** close the pipelines whose nodes' IPs are stale.
+ *
+ * @param datanodeDetails new datanodeDetails
+ */
+ @Override
+ public void closeStalePipelines(DatanodeDetails datanodeDetails) {
+ List<Pipeline> pipelinesWithStaleIpOrHostname =
+ getStalePipelines(datanodeDetails);
+ if (pipelinesWithStaleIpOrHostname.isEmpty()) {
+ LOG.info("No stale pipelines");
+ return;
+ }
+ LOG.info("Pipelines with stale IP or Host name: {}",
+ pipelinesWithStaleIpOrHostname);
Review Comment:
Since we log closing each pipeline separately, it may be enough to print the
number of pipelines here?
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/node/NodeAddressUpdateHandler.java:
##########
@@ -0,0 +1,69 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.hadoop.hdds.scm.node;
+
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.scm.ha.SCMService;
+import org.apache.hadoop.hdds.scm.ha.SCMServiceManager;
+import org.apache.hadoop.hdds.scm.node.states.NodeNotFoundException;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineManager;
+import org.apache.hadoop.hdds.server.events.EventHandler;
+import org.apache.hadoop.hdds.server.events.EventPublisher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Handles datanode ip or hostname change event.
+ */
+public class NodeAddressUpdateHandler
+ implements EventHandler<DatanodeDetails> {
+ private static final Logger LOG =
+ LoggerFactory.getLogger(NodeAddressUpdateHandler.class);
+
+ private final PipelineManager pipelineManager;
+ private final NodeDecommissionManager decommissionManager;
+ private final SCMServiceManager serviceManager;
+
+ public NodeAddressUpdateHandler(PipelineManager pipelineManager,
+ NodeDecommissionManager
+ decommissionManager,
+ SCMServiceManager serviceManager) {
+ this.pipelineManager = pipelineManager;
+ this.decommissionManager = decommissionManager;
+ this.serviceManager = serviceManager;
+ }
+
+ @Override
+ public void onMessage(DatanodeDetails datanodeDetails,
+ EventPublisher publisher) {
+ try {
+ LOG.info("Closing stale pipelines for datanode: {}", datanodeDetails);
+ pipelineManager.closeStalePipelines(datanodeDetails);
Review Comment:
Is closing pipelines necessary even if using datanode hostname instead of
IP? If two or three datanodes of some pipeline are restarted, a new pipeline
is created as they register, and the first one or two pipelines are then closed
very soon.
```
2022-06-01 10:01:03 INFO PipelineStateManagerImpl:101 - Created pipeline
Pipeline[ Id: 56d494b4-9faf-47ca-ab77-585281316c58, Nodes:
06b25030-0703-4edf-83bb-26fd94666a0d{ip: 10.42.0.40, host:
datanode-2.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec:
0}76504e44-bd67-405b-9d90-95cb8e20dfd9{ip: 10.42.0.36, host:
datanode-0.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec:
0}2f2163ec-bb96-4432-8418-dcfd7b829cbf{ip: 10.42.0.38, host:
datanode-1.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, c
ertSerialId: null, persistedOpState: IN_SERVICE,
persistedOpStateExpiryEpochSec: 0}, ReplicationConfig: RATIS/THREE,
State:ALLOCATED, leaderId:, CreationTimestamp2022-06-01T10:01:03.639Z[UTC]].
2022-06-01 10:02:15 INFO SCMNodeManager:433 - Updated Datanode to:
76504e44-bd67-405b-9d90-95cb8e20dfd9{ip: 10.42.0.41, host:
datanode-0.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec: 0}
2022-06-01 10:02:15 INFO PipelineManagerImpl:461 - Closed pipeline:
PipelineID=56d494b4-9faf-47ca-ab77-585281316c58
2022-06-01 10:02:15 INFO PipelineStateManagerImpl:101 - Created pipeline
Pipeline[ Id: 98579454-a0cd-49a0-b5b4-3c0a2a2376ef, Nodes:
2f2163ec-bb96-4432-8418-dcfd7b829cbf{ip: 10.42.0.38, host:
datanode-1.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec:
0}76504e44-bd67-405b-9d90-95cb8e20dfd9{ip: 10.42.0.41, host:
datanode-0.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec:
0}06b25030-0703-4edf-83bb-26fd94666a0d{ip: 10.42.0.40, host:
datanode-2.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, c
ertSerialId: null, persistedOpState: IN_SERVICE,
persistedOpStateExpiryEpochSec: 0}, ReplicationConfig: RATIS/THREE,
State:ALLOCATED, leaderId:, CreationTimestamp2022-06-01T10:02:15.319Z[UTC]].
2022-06-01 10:02:17 INFO SCMNodeManager:433 - Updated Datanode to:
2f2163ec-bb96-4432-8418-dcfd7b829cbf{ip: 10.42.0.42, host:
datanode-1.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec: 0}
2022-06-01 10:02:17 INFO PipelineManagerImpl:461 - Closed pipeline:
PipelineID=98579454-a0cd-49a0-b5b4-3c0a2a2376ef
2022-06-01 10:02:17 INFO PipelineStateManagerImpl:101 - Created pipeline
Pipeline[ Id: 62cfbe84-ea34-49f9-992a-6ab42ba74e0f, Nodes:
06b25030-0703-4edf-83bb-26fd94666a0d{ip: 10.42.0.40, host:
datanode-2.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec:
0}2f2163ec-bb96-4432-8418-dcfd7b829cbf{ip: 10.42.0.42, host:
datanode-1.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec:
0}76504e44-bd67-405b-9d90-95cb8e20dfd9{ip: 10.42.0.41, host:
datanode-0.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, c
ertSerialId: null, persistedOpState: IN_SERVICE,
persistedOpStateExpiryEpochSec: 0}, ReplicationConfig: RATIS/THREE,
State:ALLOCATED, leaderId:, CreationTimestamp2022-06-01T10:02:17.105Z[UTC]].
2022-06-01 10:02:25 INFO SCMNodeManager:433 - Updated Datanode to:
06b25030-0703-4edf-83bb-26fd94666a0d{ip: 10.42.0.43, host:
datanode-2.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec: 0}
2022-06-01 10:02:25 INFO PipelineManagerImpl:461 - Closed pipeline:
PipelineID=62cfbe84-ea34-49f9-992a-6ab42ba74e0f
2022-06-01 10:02:25 INFO PipelineStateManagerImpl:101 - Created pipeline
Pipeline[ Id: 86d151b0-0b6f-486e-904f-772d8a0b4131, Nodes:
2f2163ec-bb96-4432-8418-dcfd7b829cbf{ip: 10.42.0.42, host:
datanode-1.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec:
0}06b25030-0703-4edf-83bb-26fd94666a0d{ip: 10.42.0.43, host:
datanode-2.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, certSerialId: null, persistedOpState:
IN_SERVICE, persistedOpStateExpiryEpochSec:
0}76504e44-bd67-405b-9d90-95cb8e20dfd9{ip: 10.42.0.41, host:
datanode-0.datanode.default.svc.cluster.local, ports: [REPLICATION=9886,
RATIS=9858, RATIS_ADMIN=9857, RATIS_SERVER=9856, STANDALONE=9859],
networkLocation: /default-rack, c
ertSerialId: null, persistedOpState: IN_SERVICE,
persistedOpStateExpiryEpochSec: 0}, ReplicationConfig: RATIS/THREE,
State:ALLOCATED, leaderId:, CreationTimestamp2022-06-01T10:02:25.141Z[UTC]].
```
##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/ratis/RatisHelper.java:
##########
@@ -97,7 +101,18 @@ public static UUID toDatanodeId(RaftProtos.RaftPeerProto
peerId) {
}
private static String toRaftPeerAddress(DatanodeDetails id, Port.Name port) {
- return id.getIpAddress() + ":" + id.getPort(port).getValue();
+ if (datanodeUseHostName()) {
+ final String address =
+ id.getHostName() + ":" + id.getPort(port).getValue();
+ LOG.info("Datanode is using hostname for raft peer address: {}",
Review Comment:
Ideally these should be logged only once. If you don't feel like
implementing that in this PR, I think these can be changed back to debug for
now.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java:
##########
@@ -124,7 +120,27 @@ public ContainerInfo getContainer(final long size,
} catch (SCMException se) {
LOG.warn("Pipeline creation failed for repConfig {} " +
"Datanodes may be used up.", repConfig, se);
- break;
+ LOG.info("Try to see if any pipeline is in ALLOCATED state, " +
+ "and then will wait for it to be OPEN");
+ List<Pipeline> allocatedPipelines = findPipelinesByState(repConfig,
+ excludeList,
+ Pipeline.PipelineState.ALLOCATED);
+ if (!allocatedPipelines.isEmpty()) {
+ // wait until the oldest allocated pipeline is ready
+ Pipeline oldestAllocatedPipeline =
+ allocatedPipelines
+ .stream()
+ .min(Comparator
+ .comparing(p -> p.getCreationTimestamp()))
+ .get();
+ try {
+ pipelineManager
+ .waitPipelineReady(oldestAllocatedPipeline.getId(), 0);
Review Comment:
I'm not sure it's OK to make SCM wait here. Maybe it's better to let client
retry in case of failure.
But if we do wait, it would be better to wait for any of the allocated
pipelines to open, not just a specific one.
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelineManagerImpl.java:
##########
@@ -419,6 +420,45 @@ public void closePipeline(Pipeline pipeline, boolean
onTimeout)
}
}
+ /** close the pipelines whose nodes' IPs are stale.
+ *
+ * @param datanodeDetails new datanodeDetails
+ */
+ @Override
+ public void closeStalePipelines(DatanodeDetails datanodeDetails) {
+ List<Pipeline> pipelinesWithStaleIpOrHostname =
+ getStalePipelines(datanodeDetails);
+ if (pipelinesWithStaleIpOrHostname.isEmpty()) {
+ LOG.info("No stale pipelines");
Review Comment:
This can be debug level message. It would be useful to also include the
datanode ID.
```
2022-06-01 10:00:59 INFO PipelineManagerImpl:452 - No stale pipelines
```
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/WritableRatisContainerProvider.java:
##########
@@ -124,7 +120,27 @@ public ContainerInfo getContainer(final long size,
} catch (SCMException se) {
LOG.warn("Pipeline creation failed for repConfig {} " +
"Datanodes may be used up.", repConfig, se);
- break;
+ LOG.info("Try to see if any pipeline is in ALLOCATED state, " +
+ "and then will wait for it to be OPEN");
Review Comment:
I think we should log only one message here.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]