Skip to content

Commit

Permalink
Improve log during restore PVs and PVS for VolRep to reflect the core…
Browse files Browse the repository at this point in the history
… error

Signed-off-by: Elena Gershkovich <[email protected]>
  • Loading branch information
ELENAGER committed Jul 1, 2024
1 parent e63e695 commit 2417800
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions controllers/vrg_volrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -1847,6 +1847,7 @@ func (v *VRGInstance) restorePVsAndPVCsForVolRep(result *ctrl.Result) (int, erro
return count, nil
}

//nolint:funlen
func (v *VRGInstance) restorePVsAndPVCsFromS3(result *ctrl.Result) (int, error) {
err := errors.New("s3Profiles empty")
NoS3 := false
Expand Down Expand Up @@ -1877,6 +1878,8 @@ func (v *VRGInstance) restorePVsAndPVCsFromS3(result *ctrl.Result) (int, error)
// Restore all PVs found in the s3 store. If any failure, the next profile will be retried
pvCount, err = v.restorePVsFromObjectStore(objectStore, s3ProfileName)
if err != nil {
v.log.Info(fmt.Sprintf("Warning: cannot restore PVs from s3 profile %s (%v)", s3ProfileName, err))

continue
}

Expand All @@ -1889,7 +1892,13 @@ func (v *VRGInstance) restorePVsAndPVCsFromS3(result *ctrl.Result) (int, error)
// Ignoring PVC restore errors helps with the upgrade from ODF-4.12.x to 4.13
pvcCount, err = v.restorePVCsFromObjectStore(objectStore, s3ProfileName)

if err != nil || pvCount != pvcCount {
if err != nil {
v.log.Info(fmt.Sprintf("Warning: cannot restore PVCs from s3 profile %s (%v)", s3ProfileName, err))

continue
}

if pvCount != pvcCount {
v.log.Info(fmt.Sprintf("Warning: Mismatch in PV/PVC count %d/%d (%v)",
pvCount, pvcCount, err))

Expand All @@ -1913,19 +1922,13 @@ func (v *VRGInstance) restorePVsAndPVCsFromS3(result *ctrl.Result) (int, error)
func (v *VRGInstance) restorePVsFromObjectStore(objectStore ObjectStorer, s3ProfileName string) (int, error) {
pvList, err := downloadPVs(objectStore, v.s3KeyPrefix())
if err != nil {
v.log.Error(err, fmt.Sprintf("error fetching PV cluster data from S3 profile %s", s3ProfileName))

return 0, err
}

v.log.Info(fmt.Sprintf("Found %d PVs in s3 store using profile %s", len(pvList), s3ProfileName))

if err = v.checkPVClusterData(pvList); err != nil {
errMsg := fmt.Sprintf("Error found in PV cluster data in S3 store %s", s3ProfileName)
v.log.Info(errMsg)
v.log.Error(err, fmt.Sprintf("Resolve PV conflict in the S3 store %s to deploy the application", s3ProfileName))

return 0, fmt.Errorf("%s: %w", errMsg, err)
return 0, err
}

return restoreClusterDataObjects(v, pvList, "PV", cleanupPVForRestore, v.validateExistingPV)
Expand All @@ -1934,8 +1937,6 @@ func (v *VRGInstance) restorePVsFromObjectStore(objectStore ObjectStorer, s3Prof
func (v *VRGInstance) restorePVCsFromObjectStore(objectStore ObjectStorer, s3ProfileName string) (int, error) {
pvcList, err := downloadPVCs(objectStore, v.s3KeyPrefix())
if err != nil {
v.log.Error(err, fmt.Sprintf("error fetching PVC cluster data from S3 profile %s", s3ProfileName))

return 0, err
}

Expand Down

0 comments on commit 2417800

Please sign in to comment.