use field selector on name when watching download requests (#2065)

Signed-off-by: Steve Kriss <krisss@vmware.com>
This commit is contained in:
Steve Kriss
2019-11-14 16:50:24 -08:00
committed by Adnan Abdulhussein
parent cd045be028
commit e5a85f140a
@@ -60,9 +60,7 @@ func Stream(client velerov1client.DownloadRequestsGetter, namespace, name string
defer client.DownloadRequests(namespace).Delete(req.Name, nil)
listOptions := metav1.ListOptions{
// TODO: once the minimum supported Kubernetes version is v1.9.0, uncomment the following line.
// See http://issue.k8s.io/51046 for details.
//FieldSelector: "metadata.name=" + req.Name
FieldSelector: "metadata.name=" + req.Name,
ResourceVersion: req.ResourceVersion,
}
watcher, err := client.DownloadRequests(namespace).Watch(listOptions)
@@ -85,12 +83,6 @@ Loop:
return errors.Errorf("unexpected type %T", e.Object)
}
// TODO: once the minimum supported Kubernetes version is v1.9.0, remove the following check.
// See http://issue.k8s.io/51046 for details.
if updated.Name != req.Name {
continue
}
switch e.Type {
case watch.Deleted:
errors.New("download request was unexpectedly deleted")