Skip to content

Commit

Permalink
fix: no start time and end time for volume expansion progress (#8797)
Browse files Browse the repository at this point in the history
(cherry picked from commit 982672d)
  • Loading branch information
wangyelei committed Jan 13, 2025
1 parent 864ded8 commit c1e8e32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/operations/volume_expansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,7 @@ func (ve volumeExpansionOpsHandler) handleVCTExpansionProgress(reqCtx intctrluti
continue
}
objectKey := getPVCProgressObjectKey(v.Name)
progressDetail := findStatusProgressDetail(compStatus.ProgressDetails, objectKey)
if progressDetail == nil {
progressDetail = &opsv1alpha1.ProgressStatusDetail{ObjectKey: objectKey, Group: veHelper.vctName}
}
progressDetail := ve.getProgressDetail(veHelper, compStatus, objectKey)
if progressDetail.Status == opsv1alpha1.FailedProgressStatus {
completedCount += 1
continue
Expand All @@ -373,7 +370,7 @@ func (ve volumeExpansionOpsHandler) handleVCTExpansionProgress(reqCtx intctrluti
completedCount += 1
message := fmt.Sprintf("Successfully expand volume: %s in component: %s", objectKey, veHelper.compOps.GetComponentName())
progressDetail.SetStatusAndMessage(opsv1alpha1.SucceedProgressStatus, message)
setComponentStatusProgressDetail(opsRes.Recorder, opsRes.OpsRequest, &compStatus.ProgressDetails, *progressDetail)
setComponentStatusProgressDetail(opsRes.Recorder, opsRes.OpsRequest, &compStatus.ProgressDetails, progressDetail)
continue
}
if ve.pvcIsResizing(&v) {
Expand All @@ -383,11 +380,19 @@ func (ve volumeExpansionOpsHandler) handleVCTExpansionProgress(reqCtx intctrluti
message := fmt.Sprintf("Waiting for an external controller to process the pvc: %s in component: %s", objectKey, veHelper.compOps.GetComponentName())
progressDetail.SetStatusAndMessage(opsv1alpha1.PendingProgressStatus, message)
}
setComponentStatusProgressDetail(opsRes.Recorder, opsRes.OpsRequest, &compStatus.ProgressDetails, *progressDetail)
setComponentStatusProgressDetail(opsRes.Recorder, opsRes.OpsRequest, &compStatus.ProgressDetails, progressDetail)
}
return succeedCount, completedCount, nil
}

func (ve volumeExpansionOpsHandler) getProgressDetail(veHelper volumeExpansionHelper, compStatus *opsv1alpha1.OpsRequestComponentStatus, objectKey string) opsv1alpha1.ProgressStatusDetail {
progressDetail := findStatusProgressDetail(compStatus.ProgressDetails, objectKey)
if progressDetail == nil {
return opsv1alpha1.ProgressStatusDetail{ObjectKey: objectKey, Group: veHelper.vctName}
}
return *progressDetail
}

func getComponentVCTKey(compoName, insTemplateName, vctName string) string {
var instanceNameKey string
if insTemplateName != "" {
Expand Down
7 changes: 7 additions & 0 deletions pkg/operations/volume_expansion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ var _ = Describe("OpsRequest Controller Volume Expansion Handler", func() {
progressDetails := tmpOps.Status.Components[consensusCompName].ProgressDetails
progressDetail := findStatusProgressDetail(progressDetails, getPVCProgressObjectKey(pvcName))
g.Expect(progressDetail != nil && progressDetail.Status == opsv1alpha1.ProcessingProgressStatus).Should(BeTrue())
g.Expect(progressDetail.StartTime.IsZero()).Should(BeFalse())
})).Should(Succeed())

By("mock pvc resizing succeed")
Expand All @@ -199,6 +200,12 @@ var _ = Describe("OpsRequest Controller Volume Expansion Handler", func() {
// waiting for OpsRequest.status.phase is succeed
_, err := GetOpsManager().Reconcile(reqCtx, k8sClient, opsRes)
Expect(err).Should(BeNil())
Eventually(testapps.CheckObj(&testCtx, client.ObjectKeyFromObject(newOps), func(g Gomega, tmpOps *opsv1alpha1.OpsRequest) {
progressDetails := tmpOps.Status.Components[consensusCompName].ProgressDetails
progressDetail := findStatusProgressDetail(progressDetails, getPVCProgressObjectKey(pvcNames[0]))
g.Expect(progressDetail != nil && progressDetail.Status == opsv1alpha1.SucceedProgressStatus).Should(BeTrue())
g.Expect(progressDetail.EndTime.IsZero()).Should(BeFalse())
})).Should(Succeed())
Expect(opsRes.OpsRequest.Status.Phase).Should(Equal(opsv1alpha1.OpsSucceedPhase))
}

Expand Down

0 comments on commit c1e8e32

Please sign in to comment.