Skip to content

Commit

Permalink
chore: remove double error logging in vgmanager_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobmoellerdev committed Aug 25, 2023
1 parent cf48cb2 commit 3361576
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 146 deletions.
27 changes: 14 additions & 13 deletions pkg/vgmanager/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,18 @@ func (r *VGReconciler) setVolumeGroupReadyStatus(ctx context.Context, vgName str
return r.setVolumeGroupStatus(ctx, status)
}

func (r *VGReconciler) setVolumeGroupFailedStatus(ctx context.Context, vgName string, reason string) error {
func (r *VGReconciler) setVolumeGroupFailedStatus(ctx context.Context, vgName string, err error) error {
status := &lvmv1alpha1.VGStatus{
Name: vgName,
Status: lvmv1alpha1.VGStatusFailed,
Reason: reason,
Reason: err.Error(),
}

// Set devices for the VGStatus.
// If there is backing volume group, then set as degraded
devicesExist, err := r.setDevices(status)
if err != nil {
return err
}
if devicesExist {
if devicesExist, err := r.setDevices(status); err != nil {
return fmt.Errorf("could not set devices in VGStatus: %w", err)
} else if devicesExist {
status.Status = lvmv1alpha1.VGStatusDegraded
}

Expand Down Expand Up @@ -98,10 +96,12 @@ func (r *VGReconciler) setVolumeGroupStatus(ctx context.Context, status *lvmv1al

return nil
})

if err != nil {
r.Log.Error(err, "failed to create or update LVMVolumeGroupNodeStatus", "name", nodeStatus.Name)
return err
} else if result != controllerutil.OperationResultNone {
return fmt.Errorf("LVMVolumeGroupNodeStatus could not be updated: %w", err)
}

if result != controllerutil.OperationResultNone {
r.Log.Info("LVMVolumeGroupNodeStatus modified", "operation", result, "name", nodeStatus.Name)
} else {
r.Log.Info("LVMVolumeGroupNodeStatus unchanged")
Expand Down Expand Up @@ -136,9 +136,10 @@ func (r *VGReconciler) removeVolumeGroupStatus(ctx context.Context, vgName strin
return nil
})
if err != nil {
r.Log.Error(err, "failed to create or update LVMVolumeGroupNodeStatus", "name", nodeStatus.Name)
return err
} else if result != controllerutil.OperationResultNone {
return fmt.Errorf("failed to create or update LVMVolumeGroupNodeStatus %s", nodeStatus.GetName())
}

if result != controllerutil.OperationResultNone {
r.Log.Info("LVMVolumeGroupNodeStatus modified", "operation", result, "name", nodeStatus.Name)
} else {
r.Log.Info("LVMVolumeGroupNodeStatus unchanged")
Expand Down
Loading

0 comments on commit 3361576

Please sign in to comment.