• k8s-merge-robot's avatar
    Merge pull request #25369 from liggitt/cached-watch · aa8fddb7
    k8s-merge-robot authored
    Automatic merge from submit-queue
    
    Return 'too old' errors from watch cache via watch stream
    
    Fixes #25151
    
    This PR updates the API server to produce the same results when a watch is attempted with a resourceVersion that is too old, regardless of whether the etcd watch cache is enabled. The expected result is a `200` http status, with a single watch event of type `ERROR`. Previously, the watch cache would deliver a `410` http response.
    
    This is the uncached watch impl:
    ```
    // Implements storage.Interface.
    func (h *etcdHelper) WatchList(ctx context.Context, key string, resourceVersion string, filter storage.FilterFunc) (watch.Interface, error) {
    	if ctx == nil {
    		glog.Errorf("Context is nil")
    	}
    	watchRV, err := storage.ParseWatchResourceVersion(resourceVersion)
    	if err != nil {
    		return nil, err
    	}
    	key = h.prefixEtcdKey(key)
    	w := newEtcdWatcher(true, h.quorum, exceptKey(key), filter, h.codec, h.versioner, nil, h)
    	go w.etcdWatch(ctx, h.etcdKeysAPI, key, watchRV)
    	return w, nil
    }
    ```
    
    once the resourceVersion parses, there is no path that returns a direct error, so all errors would have to be returned as an `ERROR` event via the ResultChan().
    aa8fddb7
Name
Last commit
Last update
..
etcd Loading commit data...
etcd3 Loading commit data...
storagebackend Loading commit data...
testing Loading commit data...
cacher.go Loading commit data...
cacher_test.go Loading commit data...
doc.go Loading commit data...
errors.go Loading commit data...
interfaces.go Loading commit data...
util.go Loading commit data...
util_test.go Loading commit data...
watch_cache.go Loading commit data...
watch_cache_test.go Loading commit data...