mirror of
https://github.com/niusmallnan/steve.git
synced 2025-06-25 06:01:35 +00:00
Ensure we send an error when the resource version is too old.
This commit is contained in:
parent
4e31a4b24b
commit
a8ce2f5ec8
@ -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) {
|
func (s *Store) listAndWatch(apiOp *types.APIRequest, k8sClient dynamic.ResourceInterface, schema *types.APISchema, w types.WatchRequest, result chan types.APIEvent) {
|
||||||
rev := w.Revision
|
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{
|
list, err := k8sClient.List(apiOp.Context(), metav1.ListOptions{
|
||||||
Limit: 1,
|
Limit: 1,
|
||||||
|
ResourceVersion: rev,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
returnErr(errors.Wrapf(err, "failed to list %s", schema.ID), result)
|
returnErr(errors.Wrapf(err, "failed to list %s", schema.ID), result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rev = list.GetResourceVersion()
|
if rev == "" {
|
||||||
} else if rev == "-1" {
|
rev = list.GetResourceVersion()
|
||||||
rev = ""
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
timeout := int64(60 * 30)
|
timeout := int64(60 * 30)
|
||||||
|
Loading…
Reference in New Issue
Block a user