From c0a55e136b035c505f15d0c9de103dd71823de5b Mon Sep 17 00:00:00 2001 From: Steve Kriss Date: Thu, 24 Jan 2019 09:55:08 -0700 Subject: [PATCH 1/2] logging tweaks for clarity Signed-off-by: Steve Kriss --- pkg/backup/item_backupper.go | 11 +++++------ pkg/controller/backup_sync_controller.go | 9 +++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/backup/item_backupper.go b/pkg/backup/item_backupper.go index 42d808afd..2d0363452 100644 --- a/pkg/backup/item_backupper.go +++ b/pkg/backup/item_backupper.go @@ -387,6 +387,8 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log return errors.WithStack(err) } + log = log.WithField("persistentVolume", pv.Name) + // If this PV is claimed, see if we've already taken a (restic) snapshot of the contents // of this PV. If so, don't take a snapshot. if pv.Spec.ClaimRef != nil { @@ -412,17 +414,14 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log ) for _, snapshotLocation := range ib.backupRequest.SnapshotLocations { + log := log.WithField("volumeSnapshotLocation", snapshotLocation.Name) + bs, err := ib.blockStore(snapshotLocation) if err != nil { - log.WithError(err).WithField("volumeSnapshotLocation", snapshotLocation).Error("Error getting block store for volume snapshot location") + log.WithError(err).Error("Error getting block store for volume snapshot location") continue } - log := log.WithFields(map[string]interface{}{ - "volumeSnapshotLocation": snapshotLocation.Name, - "persistentVolume": metadata.GetName(), - }) - if volumeID, err = bs.GetVolumeID(obj); err != nil { log.WithError(err).Errorf("Error attempting to get volume ID for persistent volume") continue diff --git a/pkg/controller/backup_sync_controller.go b/pkg/controller/backup_sync_controller.go index 6769fec12..6ebbb0e99 100644 --- a/pkg/controller/backup_sync_controller.go +++ b/pkg/controller/backup_sync_controller.go @@ -103,22 +103,22 @@ func shouldSync(location *velerov1api.BackupStorageLocation, now time.Time, back revision, err := backupStore.GetRevision() if err != nil { - log.WithError(err).Info("Error getting backup store's revision, syncing") + log.WithError(err).Debugf("Unable to get backup store's revision file, syncing (this is not an error if a v0.10+ backup has not yet been taken into this location)") return true, "" } log = log.WithField("revision", revision) if location.Status.LastSyncedTime.Add(time.Hour).Before(now) { - log.Infof("Backup location hasn't been synced in more than %s, syncing", time.Hour) + log.Debugf("Backup location hasn't been synced in more than %s, syncing", time.Hour) return true, revision } if string(location.Status.LastSyncedRevision) != revision { - log.Info("Backup location hasn't been synced since its last modification, syncing") + log.Debugf("Backup location hasn't been synced since its last modification, syncing") return true, revision } - log.Debug("Backup location's contents haven't changed since last sync, not syncing") + log.Debugf("Backup location's contents haven't changed since last sync, not syncing") return false, "" } @@ -170,6 +170,7 @@ func (c *backupSyncController) run() { if !ok { continue } + log.Infof("Syncing contents of backup store into cluster") res, err := backupStore.ListBackups() if err != nil { From 7913ae1867337e0160ccbcefa34a48ba5a779d5b Mon Sep 17 00:00:00 2001 From: Steve Kriss Date: Thu, 24 Jan 2019 09:55:55 -0700 Subject: [PATCH 2/2] remove extraneous use of meta.Accessor Signed-off-by: Steve Kriss --- pkg/backup/item_backupper.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pkg/backup/item_backupper.go b/pkg/backup/item_backupper.go index 2d0363452..328e9df89 100644 --- a/pkg/backup/item_backupper.go +++ b/pkg/backup/item_backupper.go @@ -398,12 +398,7 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log } } - metadata, err := meta.Accessor(obj) - if err != nil { - return errors.WithStack(err) - } - - pvFailureDomainZone := metadata.GetLabels()[zoneLabel] + pvFailureDomainZone := pv.Labels[zoneLabel] if pvFailureDomainZone == "" { log.Infof("label %q is not present on PersistentVolume", zoneLabel) } @@ -446,7 +441,7 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log tags := map[string]string{ "velero.io/backup": ib.backupRequest.Name, - "velero.io/pv": metadata.GetName(), + "velero.io/pv": pv.Name, } log.Info("Getting volume information") @@ -457,7 +452,7 @@ func (ib *defaultItemBackupper) takePVSnapshot(obj runtime.Unstructured, log log } log.Info("Snapshotting PersistentVolume") - snapshot := volumeSnapshot(ib.backupRequest.Backup, metadata.GetName(), volumeID, volumeType, pvFailureDomainZone, location, iops) + snapshot := volumeSnapshot(ib.backupRequest.Backup, pv.Name, volumeID, volumeType, pvFailureDomainZone, location, iops) var errs []error snapshotID, err := blockStore.CreateSnapshot(snapshot.Spec.ProviderVolumeID, snapshot.Spec.VolumeAZ, tags)