the object has been modified; please apply your changes to the latest version and try again

调用k8s的api进行修改主机操作报这个错误:

Operation cannot be fulfilled on nodes "node--mjsbyov0-15": the object has been modified; please apply your changes to the latest version and try again

经过一番折腾,终于发现是传入的值有问题,metadata中应该去掉"resourceVersion": "17087854",这个字段

正确的request body如下:

{
    "metadata": {
        "name": "node--mjsbyov0-15",
        "selfLink": "/api/v1/nodes/node--mjsbyov0-15",
        "uid": "26c067c5-9f00-11e9-9498-fa163e383d43",
        "labels": {
            "beta.kubernetes.io/arch": "amd64",
            "beta.kubernetes.io/os": "linux",
            "kubernetes.io/hostname": "node--mjsbyov0-15",
            "node-role.kubernetes.io/worker": "true"
        },
        "annotations": {
            "field.cattle.io/creatorId": "",
            "node.alpha.kubernetes.io/ttl": "0",
            "projectcalico.org/IPv4Address": "192.168.103.188/24",
            "rke.cattle.io/external-ip": "192.168.103.188",
            "rke.cattle.io/internal-ip": "192.168.103.188",
            "volumes.kubernetes.io/controller-managed-attach-detach": "true"
        }
    },
    "spec": {
        "podCIDR": "10.42.2.0/24",
        "taints": [
            {
                "key": "abc",
                "effect": "NoSchedule",
                "value": "vvv",
                "timeAdded": null
            }
        ]
    }
}

 

你可能感兴趣的:(the object has been modified; please apply your changes to the latest version and try again)