You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Gargi-jais11 (via GitHub)" <gi...@apache.org> on 2025/09/04 09:16:59 UTC

[PR] HDDS-13592. Make InfoSubcommand validate all container IDs before proceeding [ozone]

Gargi-jais11 opened a new pull request, #9001:
URL: https://github.com/apache/ozone/pull/9001

   ## What changes were proposed in this pull request?
   [HDDS-12078](https://issues.apache.org/jira/browse/HDDS-12078) added a method ContainerIDParameters#getValidatedIDs to validate and convert container IDs passed from the command line, and fail the command quickly if IDs with invalid syntax are used. This was added for ozone admin container reconcile but should be used for ozone admin container info as well.
   
   ## What is the link to the Apache JIRA
   https://issues.apache.org/jira/browse/HDDS-13592
   
   ## How was this patch tested?
   
   Added robot test and new unit tests to `TestInfoSubCommand`.
   Below is the output after local check on docker cluster.
   
   ```
   bash-5.1$ ozone admin container info 13 -2  
   Container IDs must be positive integers. Invalid container IDs: -2
   
   bash-5.1$ ozone admin container info 14 abc
   Container IDs must be positive integers. Invalid container IDs: abc
   
   bash-5.1$ ozone admin container info 1 23 45  
   Container id: 1
   Pipeline id: cf19c04e-f553-4d38-ab65-0418cb18a3dd
   Write PipelineId: 744e21de-3b8c-465e-89c9-76ae5dbb6b29
   Write Pipeline State: OPEN
   Container State: CLOSED
   Datanodes: [ba8cbb1f-8932-4bf7-94bb-df3101063236/ozone-datanode-3.ozone_default]
   Replicas: [State: CLOSED; ReplicaIndex: 0; Origin: ba8cbb1f-8932-4bf7-94bb-df3101063236; Location: ba8cbb1f-8932-4bf7-94bb-df3101063236/ozone-datanode-3.ozone_default]
   
   Container id: 23
   Pipeline id: 80991d77-4fe5-44cb-a589-774d88921444
   Write PipelineId: 744e21de-3b8c-465e-89c9-76ae5dbb6b29
   Write Pipeline State: OPEN
   Container State: CLOSED
   Datanodes: [ba8cbb1f-8932-4bf7-94bb-df3101063236/ozone-datanode-3.ozone_default]
   Replicas: [State: CLOSED; ReplicaIndex: 0; Origin: ba8cbb1f-8932-4bf7-94bb-df3101063236; Location: ba8cbb1f-8932-4bf7-94bb-df3101063236/ozone-datanode-3.ozone_default]
   
   Container id: 45
   Pipeline id: 61f615a0-f572-4e59-a44c-0f981f4d84ec
   Write PipelineId: 744e21de-3b8c-465e-89c9-76ae5dbb6b29
   Write Pipeline State: OPEN
   Container State: CLOSED
   Datanodes: [ba8cbb1f-8932-4bf7-94bb-df3101063236/ozone-datanode-3.ozone_default]
   Replicas: [State: CLOSED; ReplicaIndex: 0; Origin: ba8cbb1f-8932-4bf7-94bb-df3101063236; Location: ba8cbb1f-8932-4bf7-94bb-df3101063236/ozone-datanode-3.ozone_default]
   ```
   


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


Re: [PR] HDDS-13592. Make InfoSubcommand validate all container IDs before proceeding [ozone]

Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on code in PR #9001:
URL: https://github.com/apache/ozone/pull/9001#discussion_r2329909174


##########
hadoop-ozone/dist/src/main/smoketest/admincli/container.robot:
##########
@@ -93,6 +93,11 @@ Container info
                         Should contain   ${output}   Pipeline id
                         Should contain   ${output}   Datanodes
 
+Container info should fail with invalid container ID
+    ${output} =         Execute And Ignore Error          ozone admin container info "${CONTAINER}" -2 0.5 abc
+                        Should contain   ${output}        Container IDs must be positive integers.
+                        Should contain   ${output}        Invalid container IDs: -2 0.5 abc

Review Comment:
   Just noticed that "${CONTAINER}" corresponds to valid container ID. You can ignore my comment.



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


Re: [PR] HDDS-13592. Make InfoSubcommand validate all container IDs before proceeding [ozone]

Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on code in PR #9001:
URL: https://github.com/apache/ozone/pull/9001#discussion_r2329909174


##########
hadoop-ozone/dist/src/main/smoketest/admincli/container.robot:
##########
@@ -93,6 +93,11 @@ Container info
                         Should contain   ${output}   Pipeline id
                         Should contain   ${output}   Datanodes
 
+Container info should fail with invalid container ID
+    ${output} =         Execute And Ignore Error          ozone admin container info "${CONTAINER}" -2 0.5 abc
+                        Should contain   ${output}        Container IDs must be positive integers.
+                        Should contain   ${output}        Invalid container IDs: -2 0.5 abc

Review Comment:
   Just noticed that "${CONTAINER}" corresponds to valid container ID. You can ignore my comment.



##########
hadoop-ozone/dist/src/main/smoketest/admincli/container.robot:
##########
@@ -93,6 +93,11 @@ Container info
                         Should contain   ${output}   Pipeline id
                         Should contain   ${output}   Datanodes
 
+Container info should fail with invalid container ID
+    ${output} =         Execute And Ignore Error          ozone admin container info "${CONTAINER}" -2 0.5 abc
+                        Should contain   ${output}        Container IDs must be positive integers.
+                        Should contain   ${output}        Invalid container IDs: -2 0.5 abc

Review Comment:
   Could you also include a valid container ID along with the invalid ones to verify that it’s skipped during validation?



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


Re: [PR] HDDS-13592. Make InfoSubcommand validate all container IDs before proceeding [ozone]

Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on code in PR #9001:
URL: https://github.com/apache/ozone/pull/9001#discussion_r2329903412


##########
hadoop-ozone/dist/src/main/smoketest/admincli/container.robot:
##########
@@ -93,6 +93,11 @@ Container info
                         Should contain   ${output}   Pipeline id
                         Should contain   ${output}   Datanodes
 
+Container info should fail with invalid container ID
+    ${output} =         Execute And Ignore Error          ozone admin container info "${CONTAINER}" -2 0.5 abc
+                        Should contain   ${output}        Container IDs must be positive integers.
+                        Should contain   ${output}        Invalid container IDs: -2 0.5 abc

Review Comment:
   Could you also include a valid container ID along with the invalid ones to verify that it’s skipped during validation?



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


Re: [PR] HDDS-13592. Make InfoSubcommand validate all container IDs before proceeding [ozone]

Posted by "errose28 (via GitHub)" <gi...@apache.org>.
errose28 commented on code in PR #9001:
URL: https://github.com/apache/ozone/pull/9001#discussion_r2344803601


##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java:
##########
@@ -65,30 +65,23 @@ public class InfoSubcommand extends ScmSubcommand {
 
   @Override
   public void execute(ScmClient scmClient) throws IOException {
+    // validate all container IDs and fail fast
+    List<Long> containerIDs = containerList.getValidatedIDs();
+
     boolean first = true;
-    multiContainer = containerList.size() > 1;
+    multiContainer = containerIDs.size() > 1;
 
     printHeader();
-    // TODO HDDS-13592: Use ContainerIDParameters#getValidatedIDs to automatically handle type conversion and fail fast.
-    for (String id : containerList) {
-      printOutput(scmClient, id, first);
+    for (Long containerID : containerIDs) {
+      if (!first) {
+        printBreak();
+      }
+      printDetails(scmClient, containerID, first);

Review Comment:
   nit. the `first` parameter in `printDetails` is no longer needed.



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