You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "sarvekshayr (via GitHub)" <gi...@apache.org> on 2026/05/15 08:55:18 UTC

[PR] HDDS-15281. Missing LifeCycleState codec in ScmCodecFactory [ozone]

sarvekshayr opened a new pull request, #10276:
URL: https://github.com/apache/ozone/pull/10276

   ## What changes were proposed in this pull request?
   `ContainerStateManager#transitionDeletingOrDeletedToTargetState` is annotated with `@Replicate` and takes `org.apache.hadoop.hdds.protocol.proto.HddsProtos.LifeCycleState` as a parameter. After [HDDS-14748](https://issues.apache.org/jira/browse/HDDS-14748) (non-reflection `ScmGeneratedMessageCodec` / explicit codec registration for Ratis serialization), callers need a `ScmCodec` registered for every protobuf-derived type used in replicated method arguments—including protobuf enums handled via `ScmEnumCodec`.
   
   `LifeCycleState` was not registered in `ScmCodecFactory`. That can cause `InvalidProtocolBufferException` (“Codec not found …”) when the leader submits or followers apply this Ratis transaction.
   
   ## What is the link to the Apache JIRA
   [HDDS-15281](https://issues.apache.org/jira/browse/HDDS-15281)
   
   ## How was this patch tested?
   Added a new test to scan every `@Replicate` method on known SCM handlers and asserts each parameter type resolves to a codec. 


-- 
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-15281. Missing LifeCycleState codec in ScmCodecFactory [ozone]

Posted by "adoroszlai (via GitHub)" <gi...@apache.org>.
adoroszlai commented on PR #10276:
URL: https://github.com/apache/ozone/pull/10276#issuecomment-4459493161

   Thanks @sarvekshayr for updating the patch.


-- 
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-15281. Missing LifeCycleState codec in ScmCodecFactory [ozone]

Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr merged PR #10276:
URL: https://github.com/apache/ozone/pull/10276


-- 
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-15281. Missing LifeCycleState codec in ScmCodecFactory [ozone]

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


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/io/TestScmCodecFactoryReplicateCoverage.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.hdds.scm.ha.io;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.StringJoiner;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.block.DeletedBlockLogStateManager;
+import org.apache.hadoop.hdds.scm.container.ContainerStateManager;
+import org.apache.hadoop.hdds.scm.ha.SCMRatisRequest;
+import org.apache.hadoop.hdds.scm.ha.StatefulServiceStateManager;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineStateManager;
+import org.apache.hadoop.hdds.scm.security.RootCARotationHandler;
+import org.apache.hadoop.hdds.scm.server.upgrade.FinalizationStateManager;
+import org.apache.hadoop.hdds.security.symmetric.SecretKeyState;
+import org.apache.hadoop.hdds.security.x509.certificate.authority.CertificateStore;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException;
+import org.junit.jupiter.api.Test;
+
+/**
+ * HA Ratis payloads use {@link ScmCodecFactory} inside {@link SCMRatisRequest}.
+ * Stub-based tests often skip {@link SCMRatisRequest#encode()}, so codec gaps go unnoticed.
+ * <p>
+ * Scan every {@link Replicate} method on known SCM handlers and asserts each parameter type resolves to a codec. 
+ * Add new handler interfaces to {@link #replicateHandlerTypes()} when they gain {@link Replicate} APIs.
+ */
+public class TestScmCodecFactoryReplicateCoverage {
+
+  private static final Class<?>[] REPLICATE_HANDLER_TYPES =
+      replicateHandlerTypes();
+
+  /** Extend when a new SCM component exposes {@link Replicate}-annotated APIs. */
+  private static Class<?>[] replicateHandlerTypes() {
+    try {
+      return new Class<?>[] {
+          ContainerStateManager.class,
+          DeletedBlockLogStateManager.class,
+          PipelineStateManager.class,
+          StatefulServiceStateManager.class,
+          SecretKeyState.class,
+          CertificateStore.class,
+          FinalizationStateManager.class,
+          RootCARotationHandler.class,

Review Comment:
   Would be nice to order ABC.



-- 
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-15281. Missing LifeCycleState codec in ScmCodecFactory [ozone]

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


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/io/TestScmCodecFactoryReplicateCoverage.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.hdds.scm.ha.io;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.StringJoiner;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.block.DeletedBlockLogStateManager;
+import org.apache.hadoop.hdds.scm.container.ContainerStateManager;
+import org.apache.hadoop.hdds.scm.ha.SCMRatisRequest;
+import org.apache.hadoop.hdds.scm.ha.StatefulServiceStateManager;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineStateManager;
+import org.apache.hadoop.hdds.scm.security.RootCARotationHandler;
+import org.apache.hadoop.hdds.scm.server.upgrade.FinalizationStateManager;
+import org.apache.hadoop.hdds.security.symmetric.SecretKeyState;
+import org.apache.hadoop.hdds.security.x509.certificate.authority.CertificateStore;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException;
+import org.junit.jupiter.api.Test;
+
+/**
+ * HA Ratis payloads use {@link ScmCodecFactory} inside {@link SCMRatisRequest}.
+ * Stub-based tests often skip {@link SCMRatisRequest#encode()}, so codec gaps go unnoticed.
+ * <p>
+ * Scan every {@link Replicate} method on known SCM handlers and asserts each parameter type resolves to a codec. 
+ * Add new handler interfaces to {@link #replicateHandlerTypes()} when they gain {@link Replicate} APIs.
+ */
+public class TestScmCodecFactoryReplicateCoverage {
+
+  private static final Class<?>[] REPLICATE_HANDLER_TYPES =
+      replicateHandlerTypes();
+
+  /** Extend when a new SCM component exposes {@link Replicate}-annotated APIs. */
+  private static Class<?>[] replicateHandlerTypes() {
+    try {
+      return new Class<?>[] {
+          ContainerStateManager.class,
+          DeletedBlockLogStateManager.class,
+          PipelineStateManager.class,
+          StatefulServiceStateManager.class,
+          SecretKeyState.class,
+          CertificateStore.class,
+          FinalizationStateManager.class,
+          RootCARotationHandler.class,
+          Class.forName("org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator$StateManager"),

Review Comment:
   Done.



-- 
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-15281. Missing LifeCycleState codec in ScmCodecFactory [ozone]

Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on PR #10276:
URL: https://github.com/apache/ozone/pull/10276#issuecomment-4460012745

   Thanks @sumitagrawl and @adoroszlai for the review. 


-- 
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-15281. Missing LifeCycleState codec in ScmCodecFactory [ozone]

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


##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/io/TestScmCodecFactoryReplicateCoverage.java:
##########
@@ -0,0 +1,160 @@
+/*
+ * 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.hdds.scm.ha.io;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Parameter;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.StringJoiner;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.block.DeletedBlockLogStateManager;
+import org.apache.hadoop.hdds.scm.container.ContainerStateManager;
+import org.apache.hadoop.hdds.scm.ha.SCMRatisRequest;
+import org.apache.hadoop.hdds.scm.ha.StatefulServiceStateManager;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineStateManager;
+import org.apache.hadoop.hdds.scm.security.RootCARotationHandler;
+import org.apache.hadoop.hdds.scm.server.upgrade.FinalizationStateManager;
+import org.apache.hadoop.hdds.security.symmetric.SecretKeyState;
+import org.apache.hadoop.hdds.security.x509.certificate.authority.CertificateStore;
+import org.apache.ratis.protocol.Message;
+import org.apache.ratis.thirdparty.com.google.protobuf.InvalidProtocolBufferException;
+import org.junit.jupiter.api.Test;
+
+/**
+ * HA Ratis payloads use {@link ScmCodecFactory} inside {@link SCMRatisRequest}.
+ * Stub-based tests often skip {@link SCMRatisRequest#encode()}, so codec gaps go unnoticed.
+ * <p>
+ * Scan every {@link Replicate} method on known SCM handlers and asserts each parameter type resolves to a codec. 
+ * Add new handler interfaces to {@link #replicateHandlerTypes()} when they gain {@link Replicate} APIs.
+ */
+public class TestScmCodecFactoryReplicateCoverage {
+
+  private static final Class<?>[] REPLICATE_HANDLER_TYPES =
+      replicateHandlerTypes();
+
+  /** Extend when a new SCM component exposes {@link Replicate}-annotated APIs. */
+  private static Class<?>[] replicateHandlerTypes() {
+    try {
+      return new Class<?>[] {
+          ContainerStateManager.class,
+          DeletedBlockLogStateManager.class,
+          PipelineStateManager.class,
+          StatefulServiceStateManager.class,
+          SecretKeyState.class,
+          CertificateStore.class,
+          FinalizationStateManager.class,
+          RootCARotationHandler.class,
+          Class.forName("org.apache.hadoop.hdds.scm.ha.SequenceIdGenerator$StateManager"),

Review Comment:
   Can we change `SequenceIdGenerator$StateManager` to `public` and use it statically here?  `StateManager` is already used in public methods like `createStateManager` (IDE warns that `Class 'StateManager' is exposed outside its defined visibility scope`).



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