Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielZhangQD committed Dec 30, 2019
1 parent 27f2038 commit fed53d0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 3 additions & 6 deletions pkg/backup/backup/backup_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
batchlisters "k8s.io/client-go/listers/batch/v1"
corelisters "k8s.io/client-go/listers/core/v1"
glog "k8s.io/klog"
)

type backupManager struct {
Expand Down Expand Up @@ -83,16 +82,14 @@ func (bm *backupManager) syncBackupJob(backup *v1alpha1.Backup) error {

err := backuputil.ValidateBackup(backup)
if err != nil {
uErr := bm.statusUpdater.Update(backup, &v1alpha1.BackupCondition{
bm.statusUpdater.Update(backup, &v1alpha1.BackupCondition{
Type: v1alpha1.BackupInvalid,
Status: corev1.ConditionTrue,
Reason: "InvalidSpec",
Message: err.Error(),
})
if uErr != nil {
glog.Warningf("Update condition %s failed for backup %s/%s", v1alpha1.BackupInvalid, ns, name)
}
return nil

return controller.IgnoreErrorf("invalid backup spec %s/%s", ns, name)
}

_, err = bm.jobLister.Jobs(ns).Get(backupJobName)
Expand Down
5 changes: 4 additions & 1 deletion pkg/controller/backup/backup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ func (bkc *Controller) processNextWorkItem() bool {
if err := bkc.sync(key.(string)); err != nil {
if perrors.Find(err, controller.IsRequeueError) != nil {
glog.Infof("Backup: %v, still need sync: %v, requeuing", key.(string), err)
bkc.queue.AddRateLimited(key)
} else if perrors.Find(err, controller.IsIgnoreError) != nil {
glog.V(4).Infof("Backup: %v, ignore err: %v", key.(string), err)
} else {
utilruntime.HandleError(fmt.Errorf("Backup: %v, sync failed, err: %v, requeuing", key.(string), err))
bkc.queue.AddRateLimited(key)
}
bkc.queue.AddRateLimited(key)
} else {
bkc.queue.Forget(key)
}
Expand Down

0 comments on commit fed53d0

Please sign in to comment.