question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

kubernetes.client.exceptions.ApiException: (422)

See original GitHub issue

Tried this demo on a plain k8s 1.16 cluster on GKE.

Freshly installed illuminatio today, so I presume it’s version 1.4.0 (BTW can I query the version via CLI?).

Did a illuminatio clean run which resulted in the following error.

Starting cleaning resources with policies ['on-request', 'always']
Finished cleanUp
Starting test generation and run.
Generated 48 cases in 1.8740 seconds

FROM                                                                                                                 TO                                                      PORT      
default:*                                                                                                            *:*                                                     *         
kube-system:*                                                                                                        *:*                                                     *         
monitoring:*                                                                                                         *:*                                                     *         
production:*                                                                                                         *:*                                                     *         
default:*                                                                                                            default:*                                               -*        
*:*                                                                                                                  kube-system:k8s-app=kube-dns                            -16609    
*:*                                                                                                                  kube-system:*                                           -11776    
*:*                                                                                                                  kube-system:app=traefik                                 -40465    
*:*                                                                                                                  monitoring:*                                            -2791     
*:*                                                                                                                  monitoring:app=prometheus,component=server              -56189    
illuminatio-inverted-namespace=monitoring:illuminatio-inverted-app=prometheus,illuminatio-inverted-component=server  monitoring:app.kubernetes.io/name=kube-state-metrics    -8080     
illuminatio-inverted-namespace=monitoring:app=prometheus,component=server                                            monitoring:app.kubernetes.io/name=kube-state-metrics    -8080     
namespace=monitoring:illuminatio-inverted-app=prometheus,illuminatio-inverted-component=server                       monitoring:app.kubernetes.io/name=kube-state-metrics    -8080     
*:*                                                                                                                  monitoring:app=prometheus,component=node-exporter       -36725    
*:*                                                                                                                  monitoring:app=prometheus,component=alertmanager        -53931    
*:*                                                                                                                  monitoring:app=prometheus,component=kube-state-metrics  -27247    
namespace=kube-system:illuminatio-inverted-app=traefik                                                               production:*                                            -3000     
production:illuminatio-inverted-run=nosqlclient                                                                      production:*                                            -mongodb  
illuminatio-inverted-production:run=nosqlclient                                                                      production:*                                            -mongodb  
illuminatio-inverted-namespace=monitoring:app=prometheus,component=server                                            production:*                                            -metrics  
illuminatio-inverted-production:illuminatio-inverted-run=nosqlclient                                                 production:*                                            -mongodb  
illuminatio-inverted-namespace=kube-system:app=traefik                                                               production:*                                            -3000     
namespace=monitoring:illuminatio-inverted-app=prometheus,illuminatio-inverted-component=server                       production:*                                            -metrics  
illuminatio-inverted-namespace=monitoring:illuminatio-inverted-app=prometheus,illuminatio-inverted-component=server  production:*                                            -metrics  
illuminatio-inverted-namespace=kube-system:illuminatio-inverted-app=traefik                                          production:*                                            -3000     
production:illuminatio-inverted-run=nosqlclient                                                                      production:app.kubernetes.io/name=mongodb               -mongodb  
illuminatio-inverted-production:run=nosqlclient                                                                      production:app.kubernetes.io/name=mongodb               -mongodb  
illuminatio-inverted-namespace=monitoring:app=prometheus,component=server                                            production:app.kubernetes.io/name=mongodb               -metrics  
illuminatio-inverted-production:illuminatio-inverted-run=nosqlclient                                                 production:app.kubernetes.io/name=mongodb               -mongodb  
namespace=monitoring:illuminatio-inverted-app=prometheus,illuminatio-inverted-component=server                       production:app.kubernetes.io/name=mongodb               -metrics  
illuminatio-inverted-namespace=monitoring:illuminatio-inverted-app=prometheus,illuminatio-inverted-component=server  production:app.kubernetes.io/name=mongodb               -metrics  
namespace=kube-system:illuminatio-inverted-app=traefik                                                               production:run=nosqlclient                              -3000     
illuminatio-inverted-namespace=kube-system:app=traefik                                                               production:run=nosqlclient                              -3000     
illuminatio-inverted-namespace=kube-system:illuminatio-inverted-app=traefik                                          production:run=nosqlclient                              -3000     
*:*                                                                                                                  kube-system:k8s-app=kube-dns                            53        
namespace=monitoring:app=prometheus,component=server                                                                 kube-system:app=traefik                                 8080      
*:*                                                                                                                  kube-system:app=traefik                                 80        
*:*                                                                                                                  kube-system:app=traefik                                 443       
namespace=monitoring:app=prometheus,component=server                                                                 monitoring:app.kubernetes.io/name=kube-state-metrics    8080      
namespace=monitoring:app=prometheus,component=server                                                                 monitoring:app=prometheus,component=node-exporter       metrics   
namespace=kube-system:app=traefik                                                                                    monitoring:app=prometheus,component=server              9090      
*:*                                                                                                                  monitoring:app=prometheus,component=alertmanager        9093      
monitoring:app=prometheus,component=server                                                                           monitoring:app=prometheus,component=alertmanager        *         
*:*                                                                                                                  monitoring:app=prometheus,component=kube-state-metrics  8080      
monitoring:app=prometheus,component=server                                                                           monitoring:app=prometheus,component=kube-state-metrics  *         
production:run=nosqlclient                                                                                           production:app.kubernetes.io/name=mongodb               mongodb   
namespace=monitoring:app=prometheus,component=server                                                                 production:app.kubernetes.io/name=mongodb               metrics   
namespace=kube-system:app=traefik                                                                                    production:run=nosqlclient                              3000      

Traceback (most recent call last):
  File "/home/myuser/.local/bin/illuminatio", line 8, in <module>
    sys.exit(cli())
  File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1163, in invoke
    rv.append(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/myuser/.local/lib/python3.8/site-packages/illuminatio/illuminatio.py", line 164, in run
    ) = execute_tests(cases, orch, cri_socket)
  File "/home/myuser/.local/lib/python3.8/site-packages/illuminatio/illuminatio.py", line 212, in execute_tests
    ) = orch.ensure_cases_are_generated(core_api)
  File "/home/myuser/.local/lib/python3.8/site-packages/illuminatio/test_orchestrator.py", line 422, in ensure_cases_are_generated
    ) = self._find_or_create_cluster_resources_for_cases(cases_dict, core_api)
  File "/home/myuser/.local/lib/python3.8/site-packages/illuminatio/test_orchestrator.py", line 358, in _find_or_create_cluster_resources_for_cases
    ) = self._get_target_names_creating_them_if_missing(target_dict, api)
  File "/home/myuser/.local/lib/python3.8/site-packages/illuminatio/test_orchestrator.py", line 282, in _get_target_names_creating_them_if_missing
    resp = api.create_namespaced_service(namespace=host.namespace, body=svc)
  File "/home/myuser/.local/lib/python3.8/site-packages/kubernetes/client/api/core_v1_api.py", line 8304, in create_namespaced_service
    return self.create_namespaced_service_with_http_info(namespace, body, **kwargs)  # noqa: E501
  File "/home/myuser/.local/lib/python3.8/site-packages/kubernetes/client/api/core_v1_api.py", line 8399, in create_namespaced_service_with_http_info
    return self.api_client.call_api(
  File "/home/myuser/.local/lib/python3.8/site-packages/kubernetes/client/api_client.py", line 348, in call_api
    return self.__call_api(resource_path, method,
  File "/home/myuser/.local/lib/python3.8/site-packages/kubernetes/client/api_client.py", line 180, in __call_api
    response_data = self.request(
  File "/home/myuser/.local/lib/python3.8/site-packages/kubernetes/client/api_client.py", line 391, in request
    return self.rest_client.POST(url,
  File "/home/myuser/.local/lib/python3.8/site-packages/kubernetes/client/rest.py", line 274, in POST
    return self.request("POST", url,
  File "/home/myuser/.local/lib/python3.8/site-packages/kubernetes/client/rest.py", line 233, in request
    raise ApiException(http_resp=r)
kubernetes.client.exceptions.ApiException: (422)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Phil1602commented, Jan 29, 2021

Hi @schnatterer, thanks for reporting this issue.

The attached log seems to be result of antoher issue (most likely old runners/results were present).

However the API exception could be related to the issue I discovered during #134. There was/is a problem that the name metadata for a port of a k8s service object is not mandatory for a single port, but is mandatory for multiple ports. So if a “dummy” pod + service containing multiple ports is created by illuminatio, this could lead to an API exception.

I will try to verify my assumption later. If my assumption is correct, this issue will be fixed by #134 as well.

0reactions
maxbischoffcommented, Sep 1, 2022

Hi @aasyria, I am currently not actively working on this project anymore, but if you want to submit a PR I’ll happily review it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting Status code 422 when creating Kubernetes Job using ...
Status code 422 Unprocessable Entity means that server understand the content type, and the syntax of the request is correct, ...
Read more >
Getting error while starting a jupyterlab instance using k8s
ApiException : (422) hub Reason: Unprocessable Entity hub HTTP response headers: ... 'application/json', 'X-Kubernetes-Pf-Flowschema-Uid': ...
Read more >
Python Examples of kubernetes.client.rest.ApiException
This page shows Python examples of kubernetes.client.rest.ApiException.
Read more >
kubernetes.client.exceptions.ApiException Example
Learn how to use python api kubernetes.client.exceptions. ... ApiException as e: if e.status in [409, 422]: # the Stowaway service already exist #...
Read more >
One can set a non-working flow run name through Prefect ...
It looks like this is a kubernetes error, rather than one coming from ... raise ApiException(http_resp=r) kubernetes.client.exceptions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found