Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
Fix repeated execution of restore operations (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
prydie authored and owainlewis committed Aug 31, 2018
1 parent f9ccd3b commit e3e3197
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/controllers/cluster/cluster_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ func (csu *clusterUpdater) UpdateClusterLabels(cluster *v1alpha1.Cluster, lbls l
key := fmt.Sprintf("%s/%s", cluster.GetNamespace(), cluster.GetName())
glog.V(4).Infof("Conflict updating Cluster labels. Getting updated Cluster %s from cache...", key)

updated, err := csu.lister.Clusters(cluster.GetNamespace()).Get(cluster.GetName())
updated, err := csu.lister.Clusters(cluster.Namespace).Get(cluster.Name)
if err != nil {
glog.Errorf("Error getting updated Cluster %s: %v", key, err)
glog.Errorf("Error getting updated Cluster %q: %v", key, err)
return err
}

Expand Down
17 changes: 15 additions & 2 deletions pkg/controllers/restore/agent_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,20 @@ func NewAgentController(
cache.ResourceEventHandlerFuncs{
UpdateFunc: func(oldObj, newObj interface{}) {
new := newObj.(*v1alpha1.Restore)
_, cond := restoreutil.GetRestoreCondition(&new.Status, v1alpha1.RestoreScheduled)

_, cond := restoreutil.GetRestoreCondition(&new.Status, v1alpha1.RestoreComplete)
if cond != nil && cond.Status == corev1.ConditionTrue {
glog.V(2).Infof("Restore %q is Complete, skipping.", kubeutil.NamespaceAndName(new))
return
}

_, cond = restoreutil.GetRestoreCondition(&new.Status, v1alpha1.RestoreRunning)
if cond != nil && cond.Status == corev1.ConditionTrue {
glog.V(2).Infof("Restore %q is Running, skipping.", kubeutil.NamespaceAndName(new))
return
}

_, cond = restoreutil.GetRestoreCondition(&new.Status, v1alpha1.RestoreScheduled)
if cond != nil && cond.Status == corev1.ConditionTrue && new.Spec.ScheduledMember == c.podName {
key, err := cache.MetaNamespaceKeyFunc(new)
if err != nil {
Expand All @@ -147,8 +160,8 @@ func NewAgentController(
c.queue.Add(key)
return
}
glog.V(4).Infof("Restore %q is not Scheduled on this agent")

glog.V(4).Infof("Restore %q is not Scheduled on this agent")
},
},
)
Expand Down

0 comments on commit e3e3197

Please sign in to comment.