[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-07-18 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=792391=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-792391
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 18/Jul/22 23:50
Start Date: 18/Jul/22 23:50
Worklog Time Spent: 10m 
  Work Description: ZanderXu commented on code in PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#discussion_r923945338


##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:
##
@@ -1899,6 +1899,9 @@ synchronized void transitionToStandby() throws 
IOException {
   synchronized void transitionToObserver() throws IOException {
 String operationName = "transitionToObserver";
 namesystem.checkSuperuserPrivilege(operationName);
+if (notBecomeActiveInSafemode && isInSafeMode()) {

Review Comment:
   Can we use a common flag?  `notBecomeActiveInSafemode` is used to control 
Active. 





Issue Time Tracking
---

Worklog Id: (was: 792391)
Time Spent: 1h 50m  (was: 1h 40m)

> [SBN read] Namenode in safe mode should not be transfered to observer state
> ---
>
> Key: HDFS-16547
> URL: https://issues.apache.org/jira/browse/HDFS-16547
> Project: Hadoop HDFS
>  Issue Type: Improvement
>Reporter: Tao Li
>Assignee: Tao Li
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> Currently, when a Namenode is in safemode(under starting or enter safemode 
> manually), we can transfer this Namenode to Observer by command. This 
> Observer node may receive many requests and then throw a SafemodeException, 
> this causes unnecessary failover on the client.
> So Namenode in safe mode should not be transfer to observer state.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

-
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org



[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-07-18 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=792380=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-792380
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 18/Jul/22 22:45
Start Date: 18/Jul/22 22:45
Worklog Time Spent: 10m 
  Work Description: xkrogen commented on code in PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#discussion_r923907353


##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSHAAdmin.java:
##
@@ -262,8 +262,13 @@ private int transitionToObserver(final CommandLine cmd)
 if (!checkManualStateManagementOK(target)) {
   return -1;
 }
-HAServiceProtocol proto = target.getProxy(getConf(), 0);
-HAServiceProtocolHelper.transitionToObserver(proto, createReqInfo());
+try {
+  HAServiceProtocol proto = target.getProxy(getConf(), 0);
+  HAServiceProtocolHelper.transitionToObserver(proto, createReqInfo());
+} catch (IOException e) {
+  errOut.println("TransitionToObserver failed! " + e.getMessage());

Review Comment:
   minor nit: `TransitionToObserver` -> `transitionToObserver` for consistency 
with other prints e.g. L254
   
   Also `getMessage()` -> `getLocalizedMessage()`



##
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSHAAdminMiniCluster.java:
##
@@ -161,7 +164,28 @@ public void testObserverIllegalTransition() throws 
Exception {
 assertEquals(-1, runTool("-transitionToActive", "nn1"));
 assertFalse(nnode1.isActiveState());
   }
-  
+
+  /**
+   * Tests that a Namenode in safe mode should not be transfer to observer.
+   */
+  @Test
+  public void testObserverTransitionInSafeMode() throws Exception {
+NameNodeAdapter.enterSafeMode(cluster.getNameNode(0), false);
+DFSHAAdmin tool = new DFSHAAdmin();
+tool.setConf(conf);
+System.setIn(new ByteArrayInputStream("yes\n".getBytes()));
+int result = tool.run(
+new String[]{"-transitionToObserver", "-forcemanual", "nn1"});

Review Comment:
   minor nit: indentation should be 4 spaces



##
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java:
##
@@ -977,4 +977,31 @@ public void testTransitionToActiveWhenSafeMode() throws 
Exception {
   () -> miniCluster.transitionToActive(0));
 }
   }
+
+  /**
+   * Test transition to observer when namenode in safemode.
+   *
+   * @throws IOException

Review Comment:
   this is inaccurate, it throws `Exception`
   but this annotation isn't really necessary IMO? it's just a test



##
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHASafeMode.java:
##
@@ -977,4 +977,31 @@ public void testTransitionToActiveWhenSafeMode() throws 
Exception {
   () -> miniCluster.transitionToActive(0));
 }
   }
+
+  /**
+   * Test transition to observer when namenode in safemode.
+   *
+   * @throws IOException
+   */
+  @Test
+  public void testTransitionToObserverWhenSafeMode() throws Exception {
+Configuration config = new Configuration();
+config.setBoolean(DFS_HA_NN_NOT_BECOME_ACTIVE_IN_SAFEMODE, true);
+try (MiniDFSCluster miniCluster = new MiniDFSCluster.Builder(config,
+new File(GenericTestUtils.getRandomizedTempPath()))
+.nnTopology(MiniDFSNNTopology.simpleHATopology())
+.numDataNodes(1)
+.build()) {
+  miniCluster.waitActive();
+  miniCluster.transitionToStandby(0);
+  miniCluster.transitionToStandby(1);
+  NameNode namenode0 = miniCluster.getNameNode(0);
+  NameNode namenode1 = miniCluster.getNameNode(1);
+  NameNodeAdapter.enterSafeMode(namenode0, false);
+  NameNodeAdapter.enterSafeMode(namenode1, false);
+  LambdaTestUtils.intercept(ServiceFailedException.class,
+  "NameNode still not leave safemode",
+  () -> miniCluster.transitionToObserver(0));

Review Comment:
   minor nit: indentation should be 4 spaces



##
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSHAAdminMiniCluster.java:
##
@@ -161,7 +164,28 @@ public void testObserverIllegalTransition() throws 
Exception {
 assertEquals(-1, runTool("-transitionToActive", "nn1"));
 assertFalse(nnode1.isActiveState());
   }
-  
+
+  /**
+   * Tests that a Namenode in safe mode should not be transfer to observer.
+   */
+  @Test
+  public void testObserverTransitionInSafeMode() throws Exception {
+NameNodeAdapter.enterSafeMode(cluster.getNameNode(0), false);
+DFSHAAdmin tool = new DFSHAAdmin();
+tool.setConf(conf);
+System.setIn(new ByteArrayInputStream("yes\n".getBytes()));
+int result = tool.run(
+new String[]{"-transitionToObserver", "-forcemanual", "nn1"});

[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-05-03 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=765294=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765294
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 03/May/22 06:19
Start Date: 03/May/22 06:19
Worklog Time Spent: 10m 
  Work Description: hadoop-yetus commented on PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#issuecomment-1115773778

   :broken_heart: **-1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime |  Logfile | Comment |
   |::|--:|:|::|:---:|
   | +0 :ok: |  reexec  |   0m 45s |  |  Docker mode activated.  |
    _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  |  No case conflicting files 
found.  |
   | +0 :ok: |  codespell  |   0m  0s |  |  codespell was not available.  |
   | +1 :green_heart: |  @author  |   0m  1s |  |  The patch does not contain 
any @author tags.  |
   | +1 :green_heart: |  test4tests  |   0m  0s |  |  The patch appears to 
include 3 new or modified test files.  |
    _ trunk Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  39m  2s |  |  trunk passed  |
   | +1 :green_heart: |  compile  |   1m 44s |  |  trunk passed with JDK 
Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1  |
   | +1 :green_heart: |  compile  |   1m 39s |  |  trunk passed with JDK 
Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07  |
   | +1 :green_heart: |  checkstyle  |   1m 25s |  |  trunk passed  |
   | +1 :green_heart: |  mvnsite  |   1m 43s |  |  trunk passed  |
   | +1 :green_heart: |  javadoc  |   1m 25s |  |  trunk passed with JDK 
Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1  |
   | +1 :green_heart: |  javadoc  |   1m 48s |  |  trunk passed with JDK 
Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07  |
   | +1 :green_heart: |  spotbugs  |   3m 43s |  |  trunk passed  |
   | +1 :green_heart: |  shadedclient  |  23m 15s |  |  branch has no errors 
when building and testing our client artifacts.  |
    _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |   1m 25s |  |  the patch passed  |
   | +1 :green_heart: |  compile  |   1m 26s |  |  the patch passed with JDK 
Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1  |
   | +1 :green_heart: |  javac  |   1m 26s |  |  the patch passed  |
   | +1 :green_heart: |  compile  |   1m 19s |  |  the patch passed with JDK 
Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07  |
   | +1 :green_heart: |  javac  |   1m 19s |  |  the patch passed  |
   | +1 :green_heart: |  blanks  |   0m  0s |  |  The patch has no blanks 
issues.  |
   | -0 :warning: |  checkstyle  |   1m  1s | 
[/results-checkstyle-hadoop-hdfs-project_hadoop-hdfs.txt](https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4201/2/artifact/out/results-checkstyle-hadoop-hdfs-project_hadoop-hdfs.txt)
 |  hadoop-hdfs-project/hadoop-hdfs: The patch generated 2 new + 200 unchanged 
- 0 fixed = 202 total (was 200)  |
   | +1 :green_heart: |  mvnsite  |   1m 29s |  |  the patch passed  |
   | +1 :green_heart: |  javadoc  |   0m 58s |  |  the patch passed with JDK 
Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1  |
   | +1 :green_heart: |  javadoc  |   1m 32s |  |  the patch passed with JDK 
Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07  |
   | +1 :green_heart: |  spotbugs  |   3m 23s |  |  the patch passed  |
   | +1 :green_heart: |  shadedclient  |  22m 41s |  |  patch has no errors 
when building and testing our client artifacts.  |
    _ Other Tests _ |
   | -1 :x: |  unit  | 257m 19s | 
[/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt](https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4201/2/artifact/out/patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt)
 |  hadoop-hdfs in the patch passed.  |
   | +1 :green_heart: |  asflicense  |   1m  5s |  |  The patch does not 
generate ASF License warnings.  |
   |  |   | 368m  4s |  |  |
   
   
   | Reason | Tests |
   |---:|:--|
   | Failed junit tests | hadoop.cli.TestHDFSCLI |
   
   
   | Subsystem | Report/Notes |
   |--:|:-|
   | Docker | ClientAPI=1.41 ServerAPI=1.41 base: 
https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4201/2/artifact/out/Dockerfile
 |
   | GITHUB PR | https://github.com/apache/hadoop/pull/4201 |
   | Optional Tests | dupname asflicense compile javac javadoc mvninstall 
mvnsite unit shadedclient spotbugs checkstyle codespell |
   | uname | Linux 55ed82edadc8 4.15.0-156-generic #163-Ubuntu SMP Thu Aug 19 
23:31:58 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev-support/bin/hadoop.sh |
   | git revision | trunk / 476d38b7e22c47e12ac6aac5e472a6fbf6289e2f |
   | Default Java | Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07 |
   | Multi-JDK versions | /usr/lib/jvm/java-11-openjdk-amd64:Private 
Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1 

[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-05-02 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=765221=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765221
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 02/May/22 23:57
Start Date: 02/May/22 23:57
Worklog Time Spent: 10m 
  Work Description: tomscut commented on code in PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#discussion_r863251873


##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:
##
@@ -1899,6 +1899,10 @@ synchronized void transitionToStandby() throws 
IOException {
   synchronized void transitionToObserver() throws IOException {
 String operationName = "transitionToObserver";
 namesystem.checkSuperuserPrivilege(operationName);
+if (namesystem.isInSafeMode()) {

Review Comment:
   Thank you @xkrogen very much for the review and careful suggestions. 
   
   The intent here is really the same as 
`dfs.ha.nn.not-become-active-in-safemode`. It's just that the configuration 
name looks a bit conflicting.





Issue Time Tracking
---

Worklog Id: (was: 765221)
Time Spent: 1h 20m  (was: 1h 10m)

> [SBN read] Namenode in safe mode should not be transfered to observer state
> ---
>
> Key: HDFS-16547
> URL: https://issues.apache.org/jira/browse/HDFS-16547
> Project: Hadoop HDFS
>  Issue Type: Improvement
>Reporter: Tao Li
>Assignee: Tao Li
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Currently, when a Namenode is in safemode(under starting or enter safemode 
> manually), we can transfer this Namenode to Observer by command. This 
> Observer node may receive many requests and then throw a SafemodeException, 
> this causes unnecessary failover on the client.
> So Namenode in safe mode should not be transfer to observer state.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org



[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-05-02 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=765220=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765220
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 02/May/22 23:56
Start Date: 02/May/22 23:56
Worklog Time Spent: 10m 
  Work Description: tomscut commented on code in PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#discussion_r863251873


##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:
##
@@ -1899,6 +1899,10 @@ synchronized void transitionToStandby() throws 
IOException {
   synchronized void transitionToObserver() throws IOException {
 String operationName = "transitionToObserver";
 namesystem.checkSuperuserPrivilege(operationName);
+if (namesystem.isInSafeMode()) {

Review Comment:
   Thank you @xkrogen very much for the review and careful suggestions. 
   
   The intent here is really the same as 
`dfs.ha.nn.not-become-active-in-safemode`. It's just that the configuration 
name looks a bit conflicting.
   
   A more appropriate name would be 
dfs.ha.nn.do.not-accept-requests-in-safemode. Maybe we can change it later.



##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:
##
@@ -1899,6 +1899,10 @@ synchronized void transitionToStandby() throws 
IOException {
   synchronized void transitionToObserver() throws IOException {
 String operationName = "transitionToObserver";
 namesystem.checkSuperuserPrivilege(operationName);
+if (namesystem.isInSafeMode()) {

Review Comment:
   Thank you @xkrogen very much for the review and careful suggestions. 
   
   The intent here is really the same as 
`dfs.ha.nn.not-become-active-in-safemode`. It's just that the configuration 
name looks a bit conflicting.
   
   A more appropriate name would be 
`dfs.ha.nn.do.not-accept-requests-in-safemode`. Maybe we can change it later.





Issue Time Tracking
---

Worklog Id: (was: 765220)
Time Spent: 1h 10m  (was: 1h)

> [SBN read] Namenode in safe mode should not be transfered to observer state
> ---
>
> Key: HDFS-16547
> URL: https://issues.apache.org/jira/browse/HDFS-16547
> Project: Hadoop HDFS
>  Issue Type: Improvement
>Reporter: Tao Li
>Assignee: Tao Li
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> Currently, when a Namenode is in safemode(under starting or enter safemode 
> manually), we can transfer this Namenode to Observer by command. This 
> Observer node may receive many requests and then throw a SafemodeException, 
> this causes unnecessary failover on the client.
> So Namenode in safe mode should not be transfer to observer state.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org



[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-05-02 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=765199=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765199
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 02/May/22 23:13
Start Date: 02/May/22 23:13
Worklog Time Spent: 10m 
  Work Description: tomscut commented on code in PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#discussion_r863251873


##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:
##
@@ -1899,6 +1899,10 @@ synchronized void transitionToStandby() throws 
IOException {
   synchronized void transitionToObserver() throws IOException {
 String operationName = "transitionToObserver";
 namesystem.checkSuperuserPrivilege(operationName);
+if (namesystem.isInSafeMode()) {

Review Comment:
   Thank you @xkrogen very much for the review and careful suggestions. 
   
   The intent here is really the same as 
`dfs.ha.nn.not-become-active-in-safemode`. It's just that the configuration 
name looks a bit conflicting.





Issue Time Tracking
---

Worklog Id: (was: 765199)
Time Spent: 1h  (was: 50m)

> [SBN read] Namenode in safe mode should not be transfered to observer state
> ---
>
> Key: HDFS-16547
> URL: https://issues.apache.org/jira/browse/HDFS-16547
> Project: Hadoop HDFS
>  Issue Type: Improvement
>Reporter: Tao Li
>Assignee: Tao Li
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
> Currently, when a Namenode is in safemode(under starting or enter safemode 
> manually), we can transfer this Namenode to Observer by command. This 
> Observer node may receive many requests and then throw a SafemodeException, 
> this causes unnecessary failover on the client.
> So Namenode in safe mode should not be transfer to observer state.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org



[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-05-02 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=765117=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-765117
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 02/May/22 20:16
Start Date: 02/May/22 20:16
Worklog Time Spent: 10m 
  Work Description: xkrogen commented on code in PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#discussion_r863153584


##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:
##
@@ -1899,6 +1899,10 @@ synchronized void transitionToStandby() throws 
IOException {
   synchronized void transitionToObserver() throws IOException {
 String operationName = "transitionToObserver";
 namesystem.checkSuperuserPrivilege(operationName);
+if (namesystem.isInSafeMode()) {

Review Comment:
   I think we can guard this by `notBecomeActiveInSafemode`. Though the config 
claims to be about "active" status, the logic in `monitorHealth` just generally 
considers a standby NN as unhealthy if it's in safemode, and I think the intent 
here is the same as with that config.
   
   
   Also: `namesystem.isInSafeMode()` -> `isInSafeMode()` (`NameNode` redefines 
this method)



##
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSZKFailoverController.java:
##
@@ -301,6 +304,40 @@ public void testManualFailoverWithDFSHAAdmin() throws 
Exception {
 waitForHAState(1, HAServiceState.STANDBY);
   }
 
+  /**
+   * Tests that a Namenode in safe mode should not be transfer to observer 
state.
+   */
+  @Test
+  public void testManualFailoverWithDFSHAAdminInSafemode() throws Exception {
+startCluster();
+NamenodeProtocols nn1 = cluster.getNameNode(1).getRpcServer();
+
+// Enter safe mode.
+nn1.setSafeMode(HdfsConstants.SafeModeAction.SAFEMODE_ENTER, false);
+// Test NameNodeRpcServer.
+LambdaTestUtils.intercept(SafeModeException.class,
+"Cannot transition to observer. Name node is in safe mode",
+() -> nn1.transitionToObserver(
+new StateChangeRequestInfo(RequestSource.REQUEST_BY_USER_FORCED)));
+
+// Test DFSHAAdmin.
+DFSHAAdmin tool = new DFSHAAdmin();
+tool.setConf(conf);
+System.setIn(new ByteArrayInputStream("yes\n".getBytes()));
+int result = tool.run(
+new String[]{"-transitionToObserver", "-forcemanual", "nn2"});
+assertEquals("State transition returned: " + result, -1, result);

Review Comment:
   This should be in `TestDFSHAAdminMiniCluster`



##
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/TestDFSZKFailoverController.java:
##
@@ -301,6 +304,40 @@ public void testManualFailoverWithDFSHAAdmin() throws 
Exception {
 waitForHAState(1, HAServiceState.STANDBY);
   }
 
+  /**
+   * Tests that a Namenode in safe mode should not be transfer to observer 
state.
+   */
+  @Test
+  public void testManualFailoverWithDFSHAAdminInSafemode() throws Exception {
+startCluster();
+NamenodeProtocols nn1 = cluster.getNameNode(1).getRpcServer();
+
+// Enter safe mode.
+nn1.setSafeMode(HdfsConstants.SafeModeAction.SAFEMODE_ENTER, false);
+// Test NameNodeRpcServer.
+LambdaTestUtils.intercept(SafeModeException.class,
+"Cannot transition to observer. Name node is in safe mode",
+() -> nn1.transitionToObserver(
+new StateChangeRequestInfo(RequestSource.REQUEST_BY_USER_FORCED)));

Review Comment:
   This should probably be in `TestHASafeMode`, where we already have 
`testTransitionToActiveWhenSafeMode`



##
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java:
##
@@ -1899,6 +1899,10 @@ synchronized void transitionToStandby() throws 
IOException {
   synchronized void transitionToObserver() throws IOException {
 String operationName = "transitionToObserver";
 namesystem.checkSuperuserPrivilege(operationName);
+if (namesystem.isInSafeMode()) {
+  throw namesystem.newSafemodeException("Cannot transition to " +
+  OBSERVER_STATE);

Review Comment:
   Consolidate this logic with the exception from `transitionToActive`:
   ```java
   if (notBecomeActiveInSafemode && isInSafeMode()) {
 throw new ServiceFailedException(getRole() + " still not leave 
safemode");
   }
   ```
   I don't think we need to make `newSafemodeException` public, seems fine to 
just throw a new exception here?





Issue Time Tracking
---

Worklog Id: (was: 765117)
Time Spent: 50m  (was: 40m)

> [SBN read] Namenode in safe mode should not be transfered to observer state
> ---
>
> Key: HDFS-16547
> URL: 

[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-04-26 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=762645=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-762645
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 27/Apr/22 01:29
Start Date: 27/Apr/22 01:29
Worklog Time Spent: 10m 
  Work Description: tomscut commented on PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#issuecomment-1110433872

   Hi @sunchao @xkrogen , could you please take a look? Thanks a lot.




Issue Time Tracking
---

Worklog Id: (was: 762645)
Time Spent: 40m  (was: 0.5h)

> [SBN read] Namenode in safe mode should not be transfered to observer state
> ---
>
> Key: HDFS-16547
> URL: https://issues.apache.org/jira/browse/HDFS-16547
> Project: Hadoop HDFS
>  Issue Type: Improvement
>Reporter: Tao Li
>Assignee: Tao Li
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> Currently, when a Namenode is in safemode(under starting or enter safemode 
> manually), we can transfer this Namenode to Observer by command. This 
> Observer node may receive many requests and then throw a SafemodeException, 
> this causes unnecessary failover on the client.
> So Namenode in safe mode should not be transfer to observer state.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org



[jira] [Work logged] (HDFS-16547) [SBN read] Namenode in safe mode should not be transfered to observer state

2022-04-21 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/HDFS-16547?focusedWorklogId=760550=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-760550
 ]

ASF GitHub Bot logged work on HDFS-16547:
-

Author: ASF GitHub Bot
Created on: 22/Apr/22 01:48
Start Date: 22/Apr/22 01:48
Worklog Time Spent: 10m 
  Work Description: tomscut commented on PR #4201:
URL: https://github.com/apache/hadoop/pull/4201#issuecomment-1105921682

   Hi @sunchao @xkrogen , could you please take a look. Thank you very much.




Issue Time Tracking
---

Worklog Id: (was: 760550)
Time Spent: 0.5h  (was: 20m)

> [SBN read] Namenode in safe mode should not be transfered to observer state
> ---
>
> Key: HDFS-16547
> URL: https://issues.apache.org/jira/browse/HDFS-16547
> Project: Hadoop HDFS
>  Issue Type: Improvement
>Reporter: tomscut
>Assignee: tomscut
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Currently, when a Namenode is in safemode(under starting or enter safemode 
> manually), we can transfer this Namenode to Observer by command. This 
> Observer node may receive many requests and then throw a SafemodeException, 
> this causes unnecessary failover on the client.
> So Namenode in safe mode should not be transfer to observer state.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

-
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org