Help: Node patching not working
I am trying to patch custom node condition types, my below code is not working or patching although error is nil, also I have tested by running curl against the api and it's working fine.
Example1:
payloadT := []byte(`[{"op": "replace", "path": "/status/conditions/0","value": { "type": "QuayStatez", "status": "True"}}]`)
node2, err := clientset.CoreV1().Nodes().Patch(context.TODO(), "<Node-Name>", types.JSONPatchType, payloadT, metav1.PatchOptions{})
Example2:
type Value struct {
Type string `json:"type"`
Status string `json:"status"`
}
type Cond struct {
Op string `json:"op"`
Path string `json:"path"`
Value Value `json:"value"`
}
payloadz := []Cond{{
Op: "add",
Path: "/status/conditions/6",
Value: Value{
Type: "SMelikTest",
Status: "True",
},
}}
bytesPayloadTT, _ := json.Marshal(payloadz)
node2, err := clientset.CoreV1().Nodes().Patch(context.TODO(), "<Node-Name>", types.JSONPatchType, bytesPayloadTT, metav1.PatchOptions{})
Curl command which is working fine:
curl -k -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json-patch+json" -X PATCH https://<APISERVER>:6443/api/v1/nodes/<Node-Name>/status --data '[{ "op": "replace", "path": "/status/conditions/0","value": { "type": "Test123", "status": "False" }}]'
Any ideas would be much appreciated.
@Shikaz try this, it works for me
node2, err := clientset.CoreV1().Nodes().Patch(context.TODO(), "<Node-Name>", types.JSONPatchType, bytesPayloadTT, metav1.PatchOptions{}, "status")
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle stale - Mark this issue or PR as rotten with
/lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Mark this issue or PR as fresh with
/remove-lifecycle rotten - Close this issue or PR with
/close - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied - After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied - After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closed
You can:
- Reopen this issue with
/reopen - Mark this issue as fresh with
/remove-lifecycle rotten - Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
In response to this:
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
- After 90d of inactivity,
lifecycle/staleis applied- After 30d of inactivity since
lifecycle/stalewas applied,lifecycle/rottenis applied- After 30d of inactivity since
lifecycle/rottenwas applied, the issue is closedYou can:
- Reopen this issue with
/reopen- Mark this issue as fresh with
/remove-lifecycle rotten- Offer to help out with Issue Triage
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.