kubernetes-client / python

Official Python client library for kubernetes
http://kubernetes.io/
Apache License 2.0
6.8k stars 3.27k forks source link

unable to rollback #1256

Closed wzg0120 closed 3 years ago

wzg0120 commented 4 years ago

What happened (please include outputs or screenshots):

def rollback(self,namespace,name,version): try: rollbackto=client.AppsV1beta1RollbackConfig(revision=version) body=client.ExtensionsV1beta1DeploymentRollback(api_version="extensions/v1beta1",name=name,kind="DeploymentRollback",rollback_to=rollbackto) res=self.extensions_v1beta1.create_namespaced_deployment_rollback(namespace=namespace,name=name,body=body) return True,res.status except: return False,traceback.format_exc()

The result of the operation is: Connected to pydev debugger (build 192.6262.63) False:Traceback (most recent call last): File "D:/WORK/CI/branches/CI/Ci/base/k8scommon/k8s_api.py", line 51, in rollback res=self.extensions_v1beta1.create_namespaced_deployment_rollback(namespace=namespace,name=name,body=body) File "D:\vitural\lib\site-packages\kubernetes\client\api\extensions_v1beta1_api.py", line 291, in create_namespaced_deployment_rollback (data) = self.create_namespaced_deployment_rollback_with_http_info(name, namespace, body, kwargs) # noqa: E501 File "D:\vitural\CiWeb\lib\site-packages\kubernetes\client\api\extensions_v1beta1_api.py", line 389, in create_namespaced_deployment_rollback_with_http_info collection_formats=collection_formats) File "D:\vitural\CiWeb\lib\site-packages\kubernetes\client\api_client.py", line 345, in call_api _preload_content, _request_timeout) File "D:\vitural\CiWeb\lib\site-packages\kubernetes\client\api_client.py", line 176, in __call_api _request_timeout=_request_timeout) File "D:\vitural\CiWeb\lib\site-packages\kubernetes\client\api_client.py", line 388, in request body=body) File "D:\vitural\CiWeb\lib\site-packages\kubernetes\client\rest.py", line 278, in POST body=body) File "D:\vitural\CiWeb\lib\site-packages\kubernetes\client\rest.py", line 231, in request raise ApiException(http_resp=r) kubernetes.client.rest.ApiException: (404) Reason: Not Found HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Date': 'Mon, 14 Sep 2020 06:24:52 GMT', 'Content-Length': '174'}) HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"the server could not find the requested resource","reason":"NotFound","details":{},"code":404}**

What you expected to happen: there have versions1 、2 ,i want rollback to version 1 How to reproduce it (as minimally and precisely as possible):

Anything else we need to know?:

Environment:

roycaihw commented 4 years ago

the server could not find the requested resource

It looks like the server doesn't host the API, which is weird because IIRC the rollback API gets dropped in 1.18, and should be still available in 1.17. Does kubectl rollout work?

roycaihw commented 4 years ago

The apps/v1beta1 and extensions/v1beta1 API groups are not served by default since 1.16. Have you enabled them in the apiserver? Could you run kubectl api-versions to double check?

wzg0120 commented 4 years ago

The apps/v1beta1 and extensions/v1beta1 API groups are not served by default since 1.16. Have you enabled them in the apiserver? Could you run kubectl api-versions to double check? @roycaihw kubectl rollout is ok.

[root@k8smaster02 ~]# kubectl api-versions admissionregistration.k8s.io/v1 admissionregistration.k8s.io/v1beta1 apiextensions.k8s.io/v1 apiextensions.k8s.io/v1beta1 apiregistration.k8s.io/v1 apiregistration.k8s.io/v1beta1 apps/v1 authentication.k8s.io/v1 authentication.k8s.io/v1beta1 authorization.k8s.io/v1 authorization.k8s.io/v1beta1 autoscaling/v1 autoscaling/v2beta1 autoscaling/v2beta2 batch/v1 batch/v1beta1 certificates.k8s.io/v1beta1 coordination.k8s.io/v1 coordination.k8s.io/v1beta1 discovery.k8s.io/v1beta1 events.k8s.io/v1beta1 extensions/v1beta1 kuboard.cn/v1 metrics.k8s.io/v1beta1 networking.k8s.io/v1 networking.k8s.io/v1beta1 node.k8s.io/v1beta1 policy/v1beta1 rbac.authorization.k8s.io/v1 rbac.authorization.k8s.io/v1beta1 scheduling.k8s.io/v1 scheduling.k8s.io/v1beta1 storage.k8s.io/v1 storage.k8s.io/v1beta1 v1

tarun-wadhwa-mmt commented 4 years ago

Verified that extensions/v1beta1 is enabled. kubectl version is 1.16.8

Still getting 404 for rollback request. Tested with kubernetes-client 12.0.0b1 as well..

\n(404)\nReason: Not Found\nHTTP response headers: HTTPHeaderDict({'Date': 'Fri, 25 Sep 2020 08:32:26 GMT', 'Content-Length': '174', 'Content-Type': 'application/json', 'Cache-Control': 'no-cache, private'})\nHTTP response body: {\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"the server could not find the requested resource\",\"reason\":\"NotFound\",\"details\":{},\"code\":404}\n\n"

tarun-wadhwa-mmt commented 4 years ago

Found another issue which raises same problem. kubernetes 12 should use apps/v1 for rollback since apps/v1beta1 and extensions/v1beta1 seems deprecated

fejta-bot commented 3 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot commented 3 years ago

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot commented 3 years ago

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-contributor-experience at kubernetes/community. /close

k8s-ci-robot commented 3 years ago

@fejta-bot: Closing this issue.

In response to [this](https://github.com/kubernetes-client/python/issues/1256#issuecomment-783274594): >Rotten issues close after 30d of inactivity. >Reopen the issue with `/reopen`. >Mark the issue as fresh with `/remove-lifecycle rotten`. > >Send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). >/close Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.