You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/06/01 20:53:09 UTC

[GitHub] [ozone] sokui commented on a diff in pull request #3186: HDDS-5916. Datanodes stuck in leader election in Kubernetes

sokui commented on code in PR #3186:
URL: https://github.com/apache/ozone/pull/3186#discussion_r887290332


##########
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
   The problem is that pipeline is using IP address. The datanode host name config only impact the ratis address. Ideally I think we should use hostname in pipeline. However, pipeline info is kept in persistent, if we we change the code to only support the hostname, then it will be not backward compatible with the pipelines already in the DB. If we decide to support both hostname and IP address, then the logic would be more complex:  we should figure out one IP is corresponding to one hostname so that pipeline will not be created duplicately. Use hostname in pipeline is a big change. We need to consider more about it. Therefore, I think it should be another PR if we decide to make the change.
   
   > 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.
   
   Is this a question or statement?



##########
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
   
   The problem is that pipeline is using IP address. The datanode host name config only impact the ratis address. Ideally I think we should use hostname in pipeline. However, pipeline info is kept in persistent, if we we change the code to only support the hostname, then it will be not backward compatible with the pipelines already in the DB. If we decide to support both hostname and IP address, then the logic would be more complex:  we should figure out one IP is corresponding to one hostname so that pipeline will not be created duplicately. Use hostname in pipeline is a big change. We need to consider more about it. Therefore, I think it should be another PR if we decide to make the change.
   
   > 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.
   
   Is this a question or statement?



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org