Merge pull request #1167 from skriss/logging-and-misc-cleanup
Logging and misc cleanuppull/1196/head
commit
52ecc45ec8
|
@ -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 {
|
||||
|
@ -396,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)
|
||||
}
|
||||
|
@ -412,17 +409,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
|
||||
|
@ -447,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")
|
||||
|
@ -458,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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue