errose28 commented on code in PR #10889:
URL: https://github.com/apache/ozone/pull/10889#discussion_r3687121582


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/upgrade/ClearPreparedStateOmUpgradeAction.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.om.upgrade;
+
+import static org.apache.hadoop.ozone.OzoneManagerVersion.ZDU;
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.hadoop.hdds.server.ServerUtils;
+import org.apache.hadoop.ozone.common.Storage;
+import org.apache.hadoop.ozone.om.OzoneManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Removes leftover OM "prepare for upgrade" state written by pre-ZDU code.
+ * It is idempotent (delete-if-exists), so it is a no-op on clusters that were 
never prepared and
+ * on fresh ZDU clusters that never finalize.
+ */
+@OmUpgradeActionForVersion(version = ZDU)
+public class ClearPreparedStateOmUpgradeAction implements OmUpgradeAction {
+  private static final Logger LOG = 
LoggerFactory.getLogger(ClearPreparedStateOmUpgradeAction.class);
+
+  // On-disk marker written by pre-ZDU OM prepare code; removed on ZDU 
finalization.
+  private static final String LEGACY_PREPARE_MARKER = "prepareMarker";
+  // transactionInfoTable key written by pre-ZDU OM prepare code.
+  private static final String LEGACY_PREPARE_MARKER_KEY = "#PREPAREDINFO";
+
+  @Override
+  public void execute(OzoneManager om) throws Exception {
+    // Reproduces the removed getPrepareMarkerFile() logic: <metadata 
dir>/current/prepareMarker.
+    File markerDir = new 
File(ServerUtils.getOzoneMetaDirPath(om.getConfiguration()),
+        Storage.STORAGE_DIR_CURRENT);
+    File marker = new File(markerDir, LEGACY_PREPARE_MARKER);
+    if (marker.exists()) {
+      if (!marker.delete()) {
+        throw new IOException("Failed to delete leftover OM prepare marker 
file " + marker);
+      }

Review Comment:
   It turns out OM and SCM were crashing if upgrade actions failed, because an 
`UpgradeException` is mapped to an `INTERNAL_ERROR` result code which will 
crash each service. I added tests for this, although they look different due to 
the differences in how Ratis requests are processed on each service.
   
   DNs are expected to keep retrying finalization as instructed by SCM, since 
they do not need to match with a quorum.



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