0

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.

tarunkumar
  • 861
  • 2
  • 15
  • 30
  • The config changes will be persisted only if there is a change. Are you submitting different ConfigMap on every run or same ConfigMap – Nataraj Medayhal Jul 14 '22 at 09:34
  • My submitted configuration is different than the existing created configmap under same namespace based on selected json patch operation but still this doesn't change state of configmap deployment in fact as response as deployed configmap without any change. – tarunkumar Jul 14 '22 at 15:24

0 Answers0