Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no start time and end time for volume expansion progress #8797

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading