🏃‍♂ Improve log message clarity (#3047)

Signed-off-by: Ashish Amarnath <ashisham@vmware.com>
This commit is contained in:
Ashish Amarnath
2020-11-02 13:39:32 -08:00
committed by GitHub
parent e9a19581bf
commit 1be97a2b04
2 changed files with 10 additions and 10 deletions

View File

@@ -519,7 +519,7 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
// Assuming we successfully uploaded the log file, this will have already been closed below. It is safe to call
// close multiple times. If we get an error closing this, there's not really anything we can do about it.
defer gzippedLogFile.Close()
defer closeAndRemoveFile(logFile, c.logger)
defer closeAndRemoveFile(logFile, c.logger.WithField(Backup, kubeutil.NamespaceAndName(backup)))
// Log the backup to both a backup log file and to stdout. This will help see what happened if the upload of the
// backup log failed for whatever reason.
@@ -608,7 +608,7 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
recordBackupMetrics(backupLog, backup.Backup, backupFile, c.metrics)
if err := gzippedLogFile.Close(); err != nil {
c.logger.WithError(err).Error("error closing gzippedLogFile")
c.logger.WithField(Backup, kubeutil.NamespaceAndName(backup)).WithError(err).Error("error closing gzippedLogFile")
}
backup.Status.Warnings = logCounter.GetCount(logrus.WarnLevel)
@@ -635,11 +635,11 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
return err
}
if errs := persistBackup(backup, backupFile, logFile, backupStore, c.logger, volumeSnapshots, volumeSnapshotContents); len(errs) > 0 {
if errs := persistBackup(backup, backupFile, logFile, backupStore, c.logger.WithField(Backup, kubeutil.NamespaceAndName(backup)), volumeSnapshots, volumeSnapshotContents); len(errs) > 0 {
fatalErrs = append(fatalErrs, errs...)
}
c.logger.Info("Backup completed")
c.logger.WithField(Backup, kubeutil.NamespaceAndName(backup)).Info("Backup completed")
// if we return a non-nil error, the calling function will update
// the backup's phase to Failed.

View File

@@ -55,7 +55,7 @@ type BackupStorageLocationReconciler struct {
func (r *BackupStorageLocationReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithField("controller", BackupStorageLocation)
log.Info("Checking for existing backup locations ready to be verified; there needs to be at least 1 backup location available")
log.Debug("Validating availablity of backup storage locations.")
locationList, err := storage.ListBackupStorageLocations(r.Ctx, r.Client, req.Namespace)
if err != nil {
@@ -78,7 +78,7 @@ func (r *BackupStorageLocationReconciler) Reconcile(req ctrl.Request) (ctrl.Resu
}
if !storage.IsReadyToValidate(location.Spec.ValidationFrequency, location.Status.LastValidationTime, r.DefaultBackupLocationInfo, log) {
log.Debug("Backup location not ready to be validated")
log.Info("Validation not required, skipping...")
continue
}
@@ -95,10 +95,10 @@ func (r *BackupStorageLocationReconciler) Reconcile(req ctrl.Request) (ctrl.Resu
continue
}
log.Debug("Verifying backup storage location")
log.Info("Validating backup storage location")
anyVerified = true
if err := backupStore.IsValid(); err != nil {
log.Debug("Backup location verified, not valid")
log.Info("Backup location is invalid, marking as unavailable")
unavailableErrors = append(unavailableErrors, errors.Wrapf(err, "Backup location %q is unavailable", location.Name).Error())
if location.Name == r.DefaultBackupLocationInfo.StorageLocation {
@@ -107,7 +107,7 @@ func (r *BackupStorageLocationReconciler) Reconcile(req ctrl.Request) (ctrl.Resu
location.Status.Phase = velerov1api.BackupStorageLocationPhaseUnavailable
} else {
log.Debug("Backup location verified and it is valid")
log.Info("Backup location valid, marking as available")
location.Status.Phase = velerov1api.BackupStorageLocationPhaseAvailable
}
location.Status.LastValidationTime = &metav1.Time{Time: time.Now().UTC()}
@@ -117,7 +117,7 @@ func (r *BackupStorageLocationReconciler) Reconcile(req ctrl.Request) (ctrl.Resu
}
if !anyVerified {
log.Info("No backup locations were ready to be verified")
log.Info("No backup locations needed to be validated")
}
r.logReconciledPhase(defaultFound, locationList, unavailableErrors)