【k8s错误解决系列】(202304)metadata.resourceVersion... must be specified for an update

报错信息

The xxxx is invalid: metadata.resourceVersion: Invalid value: 0x0: must be specified for an update

解决办法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

getObj, err := dr.Get(obj.GetName(), metav1.GetOptions{})
if errors.IsNotFound(err) {
// This doesnt ever happen even if it is already deleted or not found
log.Printf("%v not found", obj.GetName())
return nil, nil
}

if err != nil {
return nil, err
}

obj.SetResourceVersion(getObj.GetResourceVersion())

response, err := dr.Update(obj, metav1.UpdateOptions{})
if err != nil {
return nil, err
}

参考

https://github.com/argoproj/argo-cd/issues/3657


【k8s错误解决系列】(202304)metadata.resourceVersion... must be specified for an update
http://example.com/2023/04/24/k8s/【k8s错误解决系列】(202304)metadata.resourceVersion... must be specified for an update/
作者
ningan123
发布于
2023年4月24日
许可协议