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

Fix repeated execution of restore operations #215

Merged
merged 1 commit into from
Aug 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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