Skip to content
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

OpenShiftClient cannot replace existing resource with API version =! v1 #2467

Closed
matthyx opened this issue Sep 7, 2020 · 4 comments · Fixed by #2475
Closed

OpenShiftClient cannot replace existing resource with API version =! v1 #2467

matthyx opened this issue Sep 7, 2020 · 4 comments · Fixed by #2475
Assignees
Labels

Comments

@matthyx
Copy link
Contributor

matthyx commented Sep 7, 2020

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)
@matthyx
Copy link
Contributor Author

matthyx commented Sep 9, 2020

@rohanKanojia this is the problem that I thought would be corrected by #2453

@rohanKanojia
Copy link
Member

oh, okay. I will try to reproduce this and provide a fix.

@rohanKanojia rohanKanojia self-assigned this Sep 10, 2020
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Sep 10, 2020
…with API version =! v1

BackwardCompatibilityInterceptor should only convert openshift4 to openshift3 requests
on receiving 404
rohanKanojia added a commit to rohanKanojia/kubernetes-client that referenced this issue Sep 10, 2020
…with API version =! v1

BackwardCompatibilityInterceptor should only convert openshift4 to openshift3 requests
on receiving 404
@manusa manusa added the bug label Sep 11, 2020
@matthyx
Copy link
Contributor Author

matthyx commented Oct 5, 2020

@rohanKanojia it works perfectly in 4.12.0 thanks a lot!

@rohanKanojia
Copy link
Member

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: #2518 . Feel free to share your thoughts on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants