adoroszlai commented on code in PR #10011:
URL: https://github.com/apache/ozone/pull/10011#discussion_r3015480385


##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/upgrade/StatusSubCommand.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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
+ *
+ *      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,
+ * 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.ozone.admin.upgrade;
+
+import java.io.IOException;
+import java.util.UUID;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+/**
+ * Sub command to query the overall upgrade status of the cluster, returning 
information about the finalization
+ * status of SCM, the datanodes and OM.
+ */
[email protected](
+    name = "status",
+    description = "Upgrade status of the cluster",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class StatusSubCommand extends ScmSubcommand {
+
+  @Override
+  public void execute(ScmClient client) throws IOException {
+    String upgradeClientID = "Upgrade-Client-" + UUID.randomUUID();
+    HddsProtos.UpgradeStatus status = 
client.queryUpgradeStatus(upgradeClientID, true);
+
+    // Temporary output to validate the command is working.
+    System.out.println("Update status:");
+    System.out.println("    SCM Finalized: " + status.getScmFinalized());
+    System.out.println("    Datanodes finalized: " + 
status.getNumDatanodesFinalized());
+    System.out.println("    Total Datanodes: " + 
status.getNumDatanodesTotal());
+    System.out.println("    Should Finalize: " + status.getShouldFinalize());

Review Comment:
   nit: please use `out()` (inherited from `AbstractSubcommand`) instead of 
`System.out`.



##########
hadoop-hdds/interface-client/src/main/proto/hdds.proto:
##########
@@ -426,6 +426,13 @@ message UpgradeFinalizationStatus {
     repeated string messages = 2;
 }
 
+message UpgradeStatus {
+  required bool scmFinalized = 1;
+  required int32 numDatanodesFinalized = 2;
+  required int32 numDatanodesTotal = 3;
+  required bool shouldFinalize = 4;

Review Comment:
   Please add new fields as `optional`.
   
   https://protobuf.dev/programming-guides/proto2/#required-deprecated
   https://protobuf.dev/programming-guides/style/#required



##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/upgrade/UpgradeCommands.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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
+ *
+ *      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,
+ * 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.ozone.admin.upgrade;
+
+import org.apache.hadoop.hdds.cli.AdminSubcommand;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+/**
+ * Subcommand to group upgrade related operations.
+ */
[email protected](
+    name = "upgrade",
+    description = "Upgrade specific operations",

Review Comment:
   nit:
   
   ```suggestion
       description = "Operations related to cluster upgrade",
   ```



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -1148,6 +1148,30 @@ public StatusAndMessages 
queryUpgradeFinalizationProgress(
     }
   }
 
+  @Override
+  public HddsProtos.UpgradeStatus queryUpgradeStatus(String upgradeClientID, 
boolean readonly) throws IOException {
+    Map<String, String> auditMap = Maps.newHashMap();
+    auditMap.put("upgradeClientID", upgradeClientID);
+    auditMap.put("readonly", String.valueOf(readonly));
+
+    try {
+      if (!readonly) {
+        getScm().checkAdminAccess(getRemoteUser(), true);
+      }
+
+      // Returning a placeholder for now.
+      return HddsProtos.UpgradeStatus.newBuilder()
+          .setScmFinalized(true)
+          .setNumDatanodesFinalized(10)
+          .setNumDatanodesTotal(10)
+          .setShouldFinalize(true)
+          .build();
+    } catch (IOException ex) {
+      
AUDIT.logReadFailure(buildAuditMessageForFailure(SCMAction.QUERY_UPGRADE_STATUS,
 auditMap, ex));

Review Comment:
   `AUDIT.logReadSuccess` is missing.  Should be something like:
   
   ```java
   HddsProtos.UpgradeStatus response = ...
   AUDIT.logReadSuccess(...)
   return response
   ```



##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/upgrade/StatusSubCommand.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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
+ *
+ *      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,
+ * 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.ozone.admin.upgrade;
+
+import java.io.IOException;
+import java.util.UUID;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import picocli.CommandLine;
+
+/**
+ * Sub command to query the overall upgrade status of the cluster, returning 
information about the finalization
+ * status of SCM, the datanodes and OM.
+ */
[email protected](
+    name = "status",
+    description = "Upgrade status of the cluster",

Review Comment:
   nit:
   
   ```suggestion
       description = "Show status of cluster upgrade",
   ```



-- 
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]

Reply via email to