-
Notifications
You must be signed in to change notification settings - Fork 2k
Error when trying to call patchNode #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
know issue #127 will arise for all patch calls use JSON PATCH, which will not throw any error: |
closing as duplicate. |
The
But there is no Ideas? |
Same problem here. I want to make this call with the api: kubectl taint nodes testKey=value:NoExecute is it possible? I got: Internal Server Error, Response Error: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"json: cannot unmarshal object into Go value of type jsonpatch.Patch","code":500} I got the solution to patch the Node with coreV1Api.patchNode The body need to be a JsonPatch Object. String jsonPatchString= {\"op\":\"add\",\"path\":\"/spec/taints\",\"value\":[{\"effect\":\"NoSchedule\",\"key\":\"testKey\",\"value\":\"testValue\"}]}"; As @kondapally1989 mention, you need to create the body like in the PatchExample and than you can use the coreV1Api.patchNode( .. ) to patch the Node public V1Node patchNode(String jsonPatchString, String nodeId) {
ArrayList<JsonObject> arr = new ArrayList<>();
arr.add(((JsonElement) deserialize(jsonPatchString, JsonElement.class)).getAsJsonObject());
V1Node nodeV1;
try {
nodeV1 = this.coreV1Api.patchNode(nodeName, arr, "false");
LOG.info("patchNode | patching node {} was successful",
nodeV1.getMetadata().getName());
} catch (ApiException e) {
throw new RuntimeException("Patching node fail", e);
}
return nodeV1;
} |
patchNode sample: add -v=8 for kubectl command to see how kubectl is hitting the server api with jsonPayloads |
Using version 1.0.0
When calling CoreV1Api patchNode method the call fails because the inner methods set the wrong content type, the content type should be : "application/merge-patch+json"
when setting it manually the call succeed
The text was updated successfully, but these errors were encountered: