当前位置:网站首页>too old resource version,Code:410
too old resource version,Code:410
2022-06-13 02:23:00 【Matthew__M】
object="&Status{ListMeta:ListMeta{SelfLink:,
ResourceVersion:,Continue:,RemainingItemCount:nil,},
Status:Failure,Message:too old resource version: 81
006768 (81242378),Reason:Expired,Details:nil,Code:410,}"今天写代码遇到了too old resourceversion 这个问题,
•原因排查
未指定 ResourceVersion,默认空字符串。kube-apiserver 收到一个此类型的读请求后,它会向 etcd 发出共识读 / 线性读请求获取 etcd 集群最新的数据。
ResourceVersion="0",赋值字符串 0。kube-apiserver 收到此类请求时,它可能会返回任意资源版本号的数据,但是优先返回较新版本。一般情况下它直接从 kube-apiserver 缓存中获取数据返回给 client,有可能读到过期的数据,适用于对数据一致性要求不高的场景。
ResourceVersion 为一个非 0 的字符串。kube-apiserver 收到此类请求时,它会保证 Cache 中的最新 ResourceVersion 大于等于你传入的 ResourceVersion,然后从 Cache 中查找你请求的资源对象 key,返回数据给 client。基本原理是 kube-apiserver 为各个核心资源(如 Pod)维护了一个 Cache,通过 etcd 的 Watch 机制来实时更新 Cache。当你的 Get 请求中携带了非 0 的 ResourceVersion,它会等待缓存中最新 ResourceVersion 大于等于你 Get 请求中的 ResoureVersion,若满足条件则从 Cache 中查询数据,返回给 client。若不满足条件,它最多等待 3 秒,若超过 3 秒,Cache 中的最新 ResourceVersion 还小于 Get 请求中的 ResourceVersion,就会返回 ResourceVersionTooLarge 错误给 client。
etcd默认保留5分钟以内的变更记录,每个资源发生变更都会更新一个更大的资源版本ResourceVersion,ResourceVersion是一个所有资源类型共享的全局变量。
对于watch请求来说,你可以指定一个resourceVersion=0来获取5分钟以内的任意变更记录及其之后,这种表现很奇怪,所以不建议指定0。可以指定一个resourceVersion来获取这个资源版本之后的变更记录,但这个资源版本早于5分钟以内保留的最小版本,则会回复一个410状态码,如果大于最大版本,则可能会一直等下去,直到超时。\
•触发条件
服务创建超过etcd 集群默认保存cache时间之后,如果服务传进来的resourceversion 的版本早于etcd 默认保存时间以内保留的最小版本,就会触发410(status code),引发too old resource version.
•解决方法
在收到410 statuscode 时候,进行错误处理,重新rewatch 一遍、直接上代码:
retry := 0
reWatch:
ch, err := kubeclient.KubeClient.AppsV1().StatefulSets(sts.ObjectMeta.Namespace).Watch(context.TODO(),
metav1.SingleObject(metav1.ObjectMeta{Name: sts.ObjectMeta.Name, ResourceVersion: resourceVersion}))
if err != nil {
if apierrors.IsGone(err) {
tlog.Error(err, "watch resource is gone", "err is:", sts.Name)
resourceVersion = ""
retry++
if retry < 3 {
goto reWatch
}
}
tlog.Error(err, "cannot watch resource:%v", "err is:", sts.Name)
return
}边栏推荐
- Basic exercises of test questions letter graphics ※
- STM32 external interrupt Usage Summary
- [learning notes] xr872 audio driver framework analysis
- redis
- Understand HMM
- Application and examples of C language structure
- Paper reading - beat tracking by dynamic programming
- Queuing theory, game theory, analytic hierarchy process
- Installing Oracle with docker for Mac
- Basic exercises of test questions Fibonacci series
猜你喜欢

Review the history of various versions of ITIL, and find the key points for the development of enterprise operation and maintenance

Armv8-m learning notes - getting started

0- blog notes guide directory (all)

在IDEA使用C3P0連接池連接SQL數據庫後卻不能顯示數據庫內容

Understand HMM

Build MySQL environment under mac

Fast Color Segementation

Configuring virtual private network FRR for Huawei equipment

【Unity】打包WebGL項目遇到的問題及解决記錄

Mbedtls migration experience
随机推荐
【Unity】打包WebGL項目遇到的問題及解决記錄
C language conditional compilation routine
Understand HMM
Application and examples of C language structure
[keras learning]fit_ Generator analysis and complete examples
哈夫曼树及其应用
Jump model between mirrors
Laravel 权限导出
1000粉丝啦~
Automatic differential reference
C # illustrated tutorial (Fourth Edition) chapter7-7.2 accessing inherited members
Looking at Qianxin's "wild prospect" of network security from the 2021 annual performance report
Number of special palindromes in basic exercise of test questions
柏瑞凯电子冲刺科创板:拟募资3.6亿 汪斌华夫妇为大股东
How to learn to understand Matplotlib instead of simple code reuse
Gadgets: color based video and image cutting
Basic exercise of test questions Yanghui triangle (two-dimensional array and shallow copy)
Introduction to easydl object detection port
[reading paper] generate confrontation network Gan
Understand speech denoising