jesper-raemaekers / python-polarion

A Python package to access the Polarion WSDL API.
MIT License
57 stars 35 forks source link

Transport Cookies not passed -> Could not assign Workitem #61

Closed schallinterferenz closed 2 years ago

schallinterferenz commented 2 years ago

Hello,

We have a 2 server setup for Polarion in AWS, and the 2 servers run behind a load balancer. The problem we encounter is that it happes often that we authenticate on one of the servers, and the next request goes to the other server and we get the following error:

Tag not found in polarion: Cannot find workitem <workitem_id> in project <project>
[2022-04-05 09:39:32,016] ERROR in app: Exception on /post [POST]
Traceback (most recent call last):
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/eduard/.local/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/eduard/.local/lib/python3.9/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/eduard/Repos/efg_devops_git-polarion-bridge/./github_polarion_bridge.py", line 433, in hook_github
add_polarion_table_entry(polarion_client, work_item, commit,
UnboundLocalError: local variable 'work_item' referenced before assignment
127.0.0.1 - - [05/Apr/2022 09:39:32] "POST /post HTTP/1.1" 500 -

My question now is, how I can pass the transport cookiejar, as well as the session id, via the library, so that our load balacer knows where to route the request?

jesper-raemaekers commented 2 years ago

Hello,

I don't believe there is any way I can reproduce this, so i made a best guess. I found where the cookies should be stored once you login and copied it to all services used. From testing i can see that i found something cookie related, but it seems empty: image I'm unfamiliar with how that load balancer works (does it add a cookie?) so it is hard to say if this works. But please let me know. The sessions id was already shared and should be correct for all outgoing calls.

schallinterferenz commented 2 years ago

Hello jesper,

Thank you for the quick response. Do I have to specify, define or pass the cookies somewhere, after you updated the lib?

jesper-raemaekers commented 2 years ago

Hi,

I expected the cookies to be assigned to the first call (logging in) and took them from there. (see https://github.com/jesper-raemaekers/python-polarion/commit/dffa8ad126a4e3054b6694aff68007b1326cb98b#diff-9e4a1f402680e813c78e2a66d9b8b7ff039fa510dac419d880a8968327ce3ab8R92 ) But it seems i might misunderstand, you want to specify a cookie? How do you create this?

schallinterferenz commented 2 years ago

I have to excuse for the confusion. You have understood my issue right!

It works like a charm :) Tested it five time. No errors at all. It finds the project instantly and our load balancer gets the right cookies.

Thanks a lot!

schallinterferenz commented 2 years ago

When do you think you will release a update?

jesper-raemaekers commented 2 years ago

It was released today with version 0.4.0

schallinterferenz commented 2 years ago

Thanks a lot!