Repository: apecloud/kubeblocks

Issue:
[BUG] reconfigure ops phase is incorrect
![Image](https://github.com/user-attachments/assets/da411194-9773-47f3-9d2f-41087ae37638)

Hints from issue comments:

Solution patch:
diff --git a/controllers/apps/operations/reconfigure.go b/controllers/apps/operations/reconfigure.go
index 6ca4c139d..65858f222 100644
--- a/controllers/apps/operations/reconfigure.go
+++ b/controllers/apps/operations/reconfigure.go
@@ -236,6 +236,10 @@ func (r *reconfigureAction) doSyncReconfigureStatus(params reconfigureParams) (a
 		return appsv1alpha1.OpsFailedPhase,
 			syncStatus(params.configurationStatus, params.resource, itemStatus, phase)
 	case appsv1alpha1.CFinishedPhase:
+		params.reqCtx.Log.Info("reconfigure operation has been completed",
+			"config detail", *item,
+			"config status", *itemStatus,
+			"updated parameters", resolveUpdateParameters(params))
 		return appsv1alpha1.OpsSucceedPhase,
 			syncStatus(params.configurationStatus, params.resource, itemStatus, phase)
 	default:
@@ -331,7 +335,15 @@ func reconfiguringPhase(resource *configctrl.Fetcher,
 	if status.ReconcileDetail == nil || status.ReconcileDetail.CurrentRevision != status.UpdateRevision {
 		return appsv1alpha1.CPendingPhase
 	}
-	return intctrlutil.GetConfigSpecReconcilePhase(resource.ConfigMapObj, detail, status)
+	phase := intctrlutil.GetConfigSpecReconcilePhase(resource.ConfigMapObj, detail, status)
+	if phase == appsv1alpha1.CFinishedPhase {
+		// Check if the last configuration subresource (status) is the last version.
+		lastRevision, ok := resource.ConfigMapObj.Annotations[constant.ConfigurationRevision]
+		if !ok || status.UpdateRevision != lastRevision {
+			return appsv1alpha1.CRunningPhase
+		}
+	}
+	return phase
 }
 
 func isExpectedPhase(condition metav1.Condition, expectedTypes []string, expectedStatus metav1.ConditionStatus) bool {
@@ -364,3 +376,22 @@ func initReconfigureStatus(opsRequest *appsv1alpha1.OpsRequest, componentName st
 	}
 	return status.ReconfiguringStatusAsComponent[componentName]
 }
+
+func resolveUpdateParameters(params reconfigureParams) map[string]map[string]*string {
+	parameters := make(map[string]map[string]*string, len(params.configurationItem.Keys))
+	for _, config := range params.configurationItem.Keys {
+		if len(config.Parameters) == 0 {
+			continue
+		}
+		parameters[config.Key] = parameterAsMap(config.Parameters)
+	}
+	return parameters
+}
+
+func parameterAsMap(parameters []appsv1alpha1.ParameterPair) map[string]*string {
+	paramsMap := make(map[string]*string, len(parameters))
+	for _, parameter := range parameters {
+		paramsMap[parameter.Key] = parameter.Value
+	}
+	return paramsMap
+}



Test patch:
diff --git a/controllers/apps/operations/reconfigure_test.go b/controllers/apps/operations/reconfigure_test.go
index cb8644998..7f2a88297 100644
--- a/controllers/apps/operations/reconfigure_test.go
+++ b/controllers/apps/operations/reconfigure_test.go
@@ -275,6 +275,7 @@ var _ = Describe("Reconfigure OpsRequest", func() {
 						Policy:     "simple",
 						ExecResult: "none",
 					})
+					cm.Annotations[constant.ConfigurationRevision] = "1"
 					Expect(err).ShouldNot(HaveOccurred())
 					cm.Annotations[core.GenerateRevisionPhaseKey("1")] = string(b)
 				})).Should(Succeed())