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

Commit e3e3197

Browse files
prydieowainlewis
authored andcommitted
Fix repeated execution of restore operations (#215)
1 parent f9ccd3b commit e3e3197

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

pkg/controllers/cluster/cluster_control.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ func (csu *clusterUpdater) UpdateClusterLabels(cluster *v1alpha1.Cluster, lbls l
7272
key := fmt.Sprintf("%s/%s", cluster.GetNamespace(), cluster.GetName())
7373
glog.V(4).Infof("Conflict updating Cluster labels. Getting updated Cluster %s from cache...", key)
7474

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

pkg/controllers/restore/agent_controller.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,20 @@ func NewAgentController(
137137
cache.ResourceEventHandlerFuncs{
138138
UpdateFunc: func(oldObj, newObj interface{}) {
139139
new := newObj.(*v1alpha1.Restore)
140-
_, cond := restoreutil.GetRestoreCondition(&new.Status, v1alpha1.RestoreScheduled)
140+
141+
_, cond := restoreutil.GetRestoreCondition(&new.Status, v1alpha1.RestoreComplete)
142+
if cond != nil && cond.Status == corev1.ConditionTrue {
143+
glog.V(2).Infof("Restore %q is Complete, skipping.", kubeutil.NamespaceAndName(new))
144+
return
145+
}
146+
147+
_, cond = restoreutil.GetRestoreCondition(&new.Status, v1alpha1.RestoreRunning)
148+
if cond != nil && cond.Status == corev1.ConditionTrue {
149+
glog.V(2).Infof("Restore %q is Running, skipping.", kubeutil.NamespaceAndName(new))
150+
return
151+
}
152+
153+
_, cond = restoreutil.GetRestoreCondition(&new.Status, v1alpha1.RestoreScheduled)
141154
if cond != nil && cond.Status == corev1.ConditionTrue && new.Spec.ScheduledMember == c.podName {
142155
key, err := cache.MetaNamespaceKeyFunc(new)
143156
if err != nil {
@@ -147,8 +160,8 @@ func NewAgentController(
147160
c.queue.Add(key)
148161
return
149162
}
150-
glog.V(4).Infof("Restore %q is not Scheduled on this agent")
151163

164+
glog.V(4).Infof("Restore %q is not Scheduled on this agent")
152165
},
153166
},
154167
)

0 commit comments

Comments
 (0)