当前位置:网站首页>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
}
边栏推荐
- Understand CRF
- Superficial understanding of conditional random fields
- [reading point paper] deeplobv3+ encoder decoder with Atlas separable revolution
- Basic exercises of test questions Fibonacci series
- Barrykay electronics rushes to the scientific innovation board: it is planned to raise 360million yuan. Mr. and Mrs. Wang Binhua are the major shareholders
- Linear, integer, nonlinear, dynamic programming
- Chapter7-11_ Deep Learning for Question Answering (2/2)
- [pytorch] kaggle large image dataset data analysis + visualization
- [open source] libinimini: a minimalist ini parsing library for single chip computers
- cmake_ example
猜你喜欢
Chapter7-11_ Deep Learning for Question Answering (2/2)
[reading paper] generate confrontation network Gan
ROS learning-8 pit for custom action programming
Paipai loan parent company Xinye quarterly report diagram: revenue of RMB 2.4 billion, net profit of RMB 530million, a year-on-year decrease of 10%
Sqlserver2008 denied select permission on object'***** '(database'*****', schema'dbo')
Hstack, vstack and dstack in numpy
Impossible d'afficher le contenu de la base de données après que l'idée a utilisé le pool de connexion c3p0 pour se connecter à la base de données SQL
C language conditional compilation routine
[learning notes] xr872 GUI littlevgl 8.0 migration (file system)
[pytorch]fixmatch code explanation - data loading
随机推荐
传感器:MQ-5燃气模块测量燃气值(底部附代码)
Deep learning the principle of armv8/armv9 cache
How to learn to understand Matplotlib instead of simple code reuse
Paper reading - group normalization
Solution of depth learning for 3D anisotropic images
[reading point paper] deeplobv3+ encoder decoder with Atlas separable revolution
Basic exercises of test questions letter graphics ※
Leetcode 93 recovery IP address
4.11 introduction to firmware image package
C language complex type description
0- blog notes guide directory (all)
Basic exercise of test questions decimal to hexadecimal
[work with notes] MFC solves the problem that pressing ESC and enter will automatically exit
cmake_ example
Chapter7-13_ Dialogue State Tracking (as Question Answering)
[work notes] xr872 codec driver migration and application program example (with chip debugging method)
Image table solid line and dashed line detection
Sensor: sht30 temperature and humidity sensor testing ambient temperature and humidity experiment (code attached at the bottom)
柏瑞凱電子沖刺科創板:擬募資3.6億 汪斌華夫婦為大股東
Cumulative tax law: calculate how much tax you have paid in a year