openshift version: 3.11
appeared since: 4.11.0
affected objects: any object that has an API version different than v1, imagestream (image.openshift.io/v1), route (route.openshift.io/v1), ...
It looks like the replace mechanism has changed and you now try to POST an object to catch the error 410 to detect if it already exists. I think the POST somehow sends the wrong API version, compared to what OCP is expecting.
code sample:
ImageStream imageStream = Serialization.unmarshal(objectAsJsonString, ImageStream.class);
client.imageStreams().inNamespace(namespace).createOrReplace(imageStream);
stacktrace:
2020-08-31 16:42:22,507 ERROR com.mycompany.ocpdeploy.Launcher deploy job failed
java.lang.RuntimeException: java.util.concurrent.ExecutionException: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://ocpdev.dev.biz.lodh.com:8443/apis/image.openshift.io/v1/namespaces/ocptest-kblg-kuk/imagestreams. Message: the API version in the data (image.openshift.io/v1) does not match the expected API version (v1). Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=the API version in the data (image.openshift.io/v1) does not match the expected API version (v1), metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).
at com.mycompany.ocpdeploy.deploy.OpenShiftManager.ocApply(OpenShiftManager.java:127)
at com.mycompany.ocpdeploy.deploy.K8sStep.lambda$deployApplicationContext$0(K8sStep.java:147)
at com.mycompany.ocpdeploy.deploy.helper.TaskHelper.withRetries(TaskHelper.java:38)
at com.mycompany.ocpdeploy.deploy.K8sStep.deployApplicationContext(K8sStep.java:143)
at com.mycompany.ocpdeploy.deploy.K8sStep.createAppResources(K8sStep.java:91)
at com.mycompany.ocpdeploy.deploy.K8sStep.execute(K8sStep.java:77)
at com.mycompany.ocpdeploy.deploy.DeployJob.deployBase(DeployJob.java:246)
at com.mycompany.ocpdeploy.deploy.SmbManager.deploy(SmbManager.java:56)
at com.mycompany.ocpdeploy.deploy.DeployJob.deploy(DeployJob.java:220)
at com.mycompany.ocpdeploy.deploy.DeployJob.deploy(DeployJob.java:125)
at com.mycompany.ocpdeploy.deploy.DeployJob.execute(DeployJob.java:86)
at com.mycompany.ocpdeploy.Launcher.main(Launcher.java:51)
Caused by: java.util.concurrent.ExecutionException: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://ocpdev.dev.biz.lodh.com:8443/apis/image.openshift.io/v1/namespaces/ocptest-kblg-kuk/imagestreams. Message: the API version in the data (image.openshift.io/v1) does not match the expected API version (v1). Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=the API version in the data (image.openshift.io/v1) does not match the expected API version (v1), metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).
at java.base/java.util.concurrent.FutureTask.report(Unknown Source)
at java.base/java.util.concurrent.FutureTask.get(Unknown Source)
at com.mycompany.ocpdeploy.deploy.OpenShiftManager.ocApply(OpenShiftManager.java:121)
... 11 common frames omitted
Caused by: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://ocpdev.dev.biz.lodh.com:8443/apis/image.openshift.io/v1/namespaces/ocptest-kblg-kuk/imagestreams. Message: the API version in the data (image.openshift.io/v1) does not match the expected API version (v1). Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=the API version in the data (image.openshift.io/v1) does not match the expected API version (v1), metadata=ListMeta(_continue=null, remainingItemCount=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.requestFailure(OperationSupport.java:589)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.assertResponseCode(OperationSupport.java:528)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:492)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleResponse(OperationSupport.java:451)
at io.fabric8.kubernetes.client.dsl.base.OperationSupport.handleCreate(OperationSupport.java:252)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.handleCreate(BaseOperation.java:867)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.create(BaseOperation.java:356)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.createOrReplace(BaseOperation.java:421)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.createOrReplace(BaseOperation.java:83)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.createOrReplace(BaseOperation.java:415)
at io.fabric8.kubernetes.client.dsl.base.BaseOperation.createOrReplace(BaseOperation.java:83)
at com.mycompany.ocpdeploy.deploy.OpenShiftManager.createOrReplace(OpenShiftManager.java:271)
at com.mycompany.ocpdeploy.deploy.OpenShiftManager.lambda$ocApply$1(OpenShiftManager.java:114)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
@rohanKanojia this is the problem that I thought would be corrected by #2453
oh, okay. I will try to reproduce this and provide a fix.
@rohanKanojia it works perfectly in 4.12.0 thanks a lot!
cool, Thanks! Apologies for inconvenience caused. In previous releases we released lots of breaking changes without notifying users about it. We're discussing this here: https://github.com/fabric8io/kubernetes-client/issues/2518 . Feel free to share your thoughts on it.