From a8ce2f5ec86ce6c158f95704be57f6b9025cb5ac Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Sun, 27 Sep 2020 17:51:52 -0700 Subject: [PATCH] Ensure we send an error when the resource version is too old. --- pkg/stores/proxy/proxy_store.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkg/stores/proxy/proxy_store.go b/pkg/stores/proxy/proxy_store.go index 31a2888..92c4c40 100644 --- a/pkg/stores/proxy/proxy_store.go +++ b/pkg/stores/proxy/proxy_store.go @@ -275,17 +275,21 @@ func returnErr(err error, c chan types.APIEvent) { func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.ResourceInterface, schema *types.APISchema, w types.WatchRequest, result chan types.APIEvent) { rev := w.Revision - if rev == "" { + if rev == "-1" { + rev = "" + } else { + // ensure the revision is valid or get the latest one list, err := k8sClient.List(apiOp.Context(), metav1.ListOptions{ - Limit: 1, + Limit: 1, + ResourceVersion: rev, }) if err != nil { returnErr(errors.Wrapf(err, "failed to list %s", schema.ID), result) return } - rev = list.GetResourceVersion() - } else if rev == "-1" { - rev = "" + if rev == "" { + rev = list.GetResourceVersion() + } } timeout := int64(60 * 30)