client-go icon indicating copy to clipboard operation
client-go copied to clipboard

Help: Node patching not working

Open Shikaz opened this issue 3 years ago • 2 comments

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 avatar May 20 '22 07:05 Shikaz

@Shikaz try this, it works for me

node2, err := clientset.CoreV1().Nodes().Patch(context.TODO(), "<Node-Name>", types.JSONPatchType, bytesPayloadTT, metav1.PatchOptions{}, "status")

mirocody avatar Aug 15 '22 06:08 mirocody

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Nov 13 '22 07:11 k8s-triage-robot

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

k8s-triage-robot avatar Dec 13 '22 07:12 k8s-triage-robot

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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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 avatar Jan 12 '23 08:01 k8s-triage-robot

@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/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was 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

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.

k8s-ci-robot avatar Jan 12 '23 08:01 k8s-ci-robot