blob: 5aac30a146d26e4c069646fdac61980e8c0e705c [file] [log] [blame]
Matthias Andreas Benkard832a54e2019-01-29 09:27:38 +01001/*
2Copyright 2016 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package etcd3
18
19import (
20 "k8s.io/apimachinery/pkg/api/errors"
21
22 etcdrpc "github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
23)
24
25func interpretWatchError(err error) error {
26 switch {
27 case err == etcdrpc.ErrCompacted:
28 return errors.NewResourceExpired("The resourceVersion for the provided watch is too old.")
29 }
30 return err
31}
32
33func interpretListError(err error, paging bool) error {
34 switch {
35 case err == etcdrpc.ErrCompacted:
36 if paging {
37 return errors.NewResourceExpired("The provided from parameter is too old to display a consistent list result. You must start a new list without the from.")
38 }
39 return errors.NewResourceExpired("The resourceVersion for the provided list is too old.")
40 }
41 return err
42}