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

🐛Bugfix: Director v2 called from GC errors because of wrong use of yarl library #3207

Merged

Conversation

mrnicegyu11
Copy link
Member

What do these changes do?

Fixes #3206

How to test

Check that the error and assoc. stack-trace mentioned in the issue #3206 is not happening anymore

Checklist

  • Unit tests for the changes exist

@codecov
Copy link

codecov bot commented Jul 20, 2022

Codecov Report

Merging #3207 (045001c) into master (f90a680) will increase coverage by 0.0%.
The diff coverage is 80.0%.

❗ Current head 045001c differs from pull request most recent head 16d5f22. Consider uploading reports for the commit 16d5f22 to get more accurate results

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #3207   +/-   ##
======================================
  Coverage    82.0%   82.0%           
======================================
  Files         740     740           
  Lines       31574   31578    +4     
  Branches     4082    4084    +2     
======================================
+ Hits        25897   25906    +9     
+ Misses       4845    4839    -6     
- Partials      832     833    +1     
Flag Coverage Δ
integrationtests 66.4% <20.0%> (+<0.1%) ⬆️
unittests 78.5% <80.0%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ice_webserver/director_v2_core_dynamic_services.py 65.7% <80.0%> (+3.2%) ⬆️
...rvice_datcore_adapter/utils/requests_decorators.py 68.4% <0.0%> (-10.6%) ⬇️
...mcore_service_webserver/garbage_collector_utils.py 82.0% <0.0%> (-2.6%) ⬇️
...c/simcore_service_catalog/core/background_tasks.py 66.3% <0.0%> (-1.1%) ⬇️
.../director/src/simcore_service_director/producer.py 61.6% <0.0%> (-0.3%) ⬇️
...ce_webserver/resource_manager/websocket_manager.py 94.8% <0.0%> (+1.2%) ⬆️
...imcore_service_webserver/garbage_collector_task.py 100.0% <0.0%> (+2.3%) ⬆️
...imcore_service_webserver/garbage_collector_core.py 68.6% <0.0%> (+2.4%) ⬆️
.../simcore_service_catalog/services/access_rights.py 81.2% <0.0%> (+2.5%) ⬆️
... and 1 more

@@ -38,12 +38,17 @@ async def get_dynamic_services(
params["project_id"] = project_id

settings: DirectorV2Settings = get_plugin_settings(app)
backend_url = (settings.base_url / "dynamic_services").update_query(**params)
if params != {}: # Update query doesnt work with no params to unwrap
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if params != {}: # Update query doesnt work with no params to unwrap
if not params: # Update query doesnt work with no params to unwrap

Copy link
Member

@pcrespov pcrespov Jul 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GitHK suggestion is good idea BUT the condition he wrote is reversed i.e. it should be

backend_url: URL = settings.base_url / "dynamic_services"
if params:
   backend_url = backend_url.update_query(**params)

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please addressed the below minor suggestions.

…core_dynamic_services.py

Co-authored-by: Andrei Neagu <5694077+GitHK@users.noreply.github.com>
@@ -38,12 +38,17 @@ async def get_dynamic_services(
params["project_id"] = project_id

settings: DirectorV2Settings = get_plugin_settings(app)
backend_url = (settings.base_url / "dynamic_services").update_query(**params)
if params: # Update query doesnt work with no params to unwrap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW i have been looking at the doc and this solution would also work (NOTE no **)

backend_url = (settings.base_url / "dynamic_services").update_query(params)

example

>>> from yarl import URL
>>> URL('http://example.com/path?a=b').update_query({'c': 'd'})
URL('http://example.com/path?a=b&c=d')
>>> URL('http://example.com/path?a=b').update_query({})
URL('http://example.com/path?a=b')
>>> URL('http://example.com/path?a=b').update_query(None)
URL('http://example.com/path?a=b')

@pcrespov pcrespov added the a:webserver issue related to the webserver service label Jul 20, 2022
@pcrespov pcrespov added this to the Meteora milestone Jul 20, 2022
@pcrespov pcrespov merged commit 984b762 into ITISFoundation:master Jul 20, 2022
@sonarcloud
Copy link

sonarcloud bot commented Jul 20, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:webserver issue related to the webserver service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Bug: garbage colletor doesnt work, throws constant errors
3 participants