Java Kube client patch doesn't update configmap

319 views Asked by At

Using Java client - "io.kubernetes:client-java:11.0.0"

I am trying to use patch utils with JSON as

"{ "op": "replace", "path": "/data/stream.properties", "value": "abcd.topic[com.test.xyz.poc.basicauditbatch1]=avro_test1 " }";

CoreV1Api api = new CoreV1Api(client);
    V1ConfigMap configMap = PatchUtils.patch(V1ConfigMap.class, () -> api.patchNamespacedConfigMapCall(
        name,
        namespace,
        new V1Patch(jsonPatchStr),
        null,
        null,
        null,
        null,
        new ApiCallbackDebugger()), V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, client);
    System.out.println("patched configmap data "+ configMap.getData());
    return configMap;

API call to the server went without any exception, however configmap remains unaffected. I have tried add, remove and replace Json patch options but still no luck.

Any suggestions what could I am missing, also tried following patch formats but still response remains same.

public static final String PATCH_FORMAT_JSON_PATCH = "application/json-patch+json";
public static final String PATCH_FORMAT_JSON_MERGE_PATCH = "application/merge-patch+json";

Though one strange thing on callback added for debugging, I neither see success nor failure just calls to onUpload and onDownload progress.

public static class ApiCallbackDebugger implements ApiCallback {

    @Override
    public void onFailure(ApiException e, int statusCode, Map responseHeaders) {
      System.out.println("Call back Failure " );
      e.printStackTrace();
      LOGGER.error(
          "kube.call.failure status {} response {} headers {}",
          statusCode,
          e.getResponseBody(),
          responseHeaders,
          e);
    }

    @Override
    public void onSuccess(Object result, int statusCode, Map responseHeaders) {
      System.out.println("CALLBACK Successful - " + statusCode + " status "+statusCode + " responseHeader "+ responseHeaders);
      LOGGER.debug(
          "api.call.success statusCode {} response {} responseHeader {}",
          statusCode,
          result,
          responseHeaders);
    }

    @Override
    public void onUploadProgress(long bytesWritten, long contentLength, boolean done) {
      System.out.println("On Callback upload progress.");
    }

    @Override
    public void onDownloadProgress(long bytesRead, long contentLength, boolean done) {
      System.out.println("On Callback download progress.");
    }
  }

Any inputs / pointers appreciated.

0

There are 0 answers