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

WP-1275: call park api #309

Merged
merged 37 commits into from
Apr 2, 2024
Merged

WP-1275: call park api #309

merged 37 commits into from
Apr 2, 2024

Conversation

ja0x
Copy link
Contributor

@ja0x ja0x commented Mar 18, 2024

Depends-On: wazo-platform/wazo-bus#102
Depends-On: wazo-platform/wazo-asterisk-config#58
Depends-On: wazo-platform/wazo-auth-keys#77
Depends-On: wazo-platform/wazo-calld-client#57

Provides an API to park a call

  • GET /parking_lots/$parking-id Retrieve parking realtime information
  • PUT /calls/$call-id/park Park the call into parking
  • PUT /users/me/calls/$call-id/park Park the user's recipient call

To test

  1. mount unto stack
  2. reload calld
  3. User A calls User B
  4. Using API, get User's A call-id: e.g: GET /calls
  5. Using API, park the call: PUT /calls//park
  6. To retrieve the call, dial park slot (extension) or wait for timeout

Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/3d9b2b6d488a444593b8462a6f65782b

✔️ tox-linters SUCCESS in 6m 48s
✔️ wazo-tox-py39 SUCCESS in 7m 10s
✔️ debian-packaging-bullseye SUCCESS in 4m 50s
calld-tox-integration FAILURE in 38m 48s

@ja0x
Copy link
Contributor Author

ja0x commented Mar 19, 2024

Tests failed because it didnt use wazo-test-helpers updated image that supports parking mocks. wazo-test-helpers will need to be merged first

@fblackburn1 fblackburn1 changed the title WP-1193: call park api WP-1275: call park api Mar 19, 2024
Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/8ca211dc39054475b79435299f03f4b9

✔️ tox-linters SUCCESS in 6m 59s
✔️ wazo-tox-py39 SUCCESS in 7m 20s
✔️ debian-packaging-bullseye SUCCESS in 4m 55s
calld-tox-integration FAILURE in 37m 55s

Copy link
Member

@fblackburn1 fblackburn1 left a comment

Choose a reason for hiding this comment

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

✔️ If we start to use typing, then mypy should be adding in linters

✔️ edit: We must listen on parking_lot_edited instead of parking_lot_updated
✔️ edit2: changelog is missing for the new parked options for calls

wazo_calld/plugins/parking_lots/api.yml Outdated Show resolved Hide resolved
wazo_calld/plugins/parking_lots/api.yml Outdated Show resolved Hide resolved
wazo_calld/plugins/parking_lots/http.py Show resolved Hide resolved
wazo_calld/plugins/parking_lots/http.py Show resolved Hide resolved
wazo_calld/plugins/parking_lots/schemas.py Outdated Show resolved Hide resolved
Copy link
Member

@fblackburn1 fblackburn1 left a comment

Choose a reason for hiding this comment

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

The endpoint to unpark a call is missing: need to be discussed
edit: after discussion, no use case for now

Comment on lines +104 to +107
# If call is already parked, preserve callback
park_payload['TimeoutChannel'] = parked_call.parker_dial_string
Copy link
Member

@fblackburn1 fblackburn1 Mar 20, 2024

Choose a reason for hiding this comment

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

If call is already parked, should we just thrown an exception?
(I didn't test) Swapping feature seems a dedicate endpoint to me, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is more related to reparking a call since it wont leave the parking. We could throw an exception to prevent a call from being reparked, but reparking allows to update timeout for instance. A call can also be reparked in the same space

wazo_calld/plugins/parking_lots/services.py Outdated Show resolved Hide resolved
wazo_calld/plugins/parking_lots/services.py Outdated Show resolved Hide resolved
wazo_calld/plugins/parking_lots/services.py Outdated Show resolved Hide resolved
wazo_calld/plugins/parking_lots/services.py Outdated Show resolved Hide resolved
Copy link
Member

@fblackburn1 fblackburn1 left a comment

Choose a reason for hiding this comment

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

✔️ When testing on my wazo, I get a OverflowError

2024-03-20 17:56:07,067 [2263762] (ERROR) (wazo_calld): Exception on /1.0/parking_lots/2 [GET]
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/python3/dist-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/xivo/rest_api_helpers.py", line 41, in wrapper
    return func(*args, **kwargs)
  File "/usr/src/wazo/wazo-calld/wazo_calld/http.py", line 20, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/xivo/mallow_helpers.py", line 30, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/xivo/auth_verifier.py", line 225, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/xivo/auth_verifier.py", line 190, in wrapper
    return func(*args, **kwargs)
  File "/usr/src/wazo/wazo-calld/wazo_calld/plugins/parking_lots/http.py", line 32, in get
    return ParkingLotSchema(context={'calls': calls}).dump(parking_lot), 200
  File "/usr/lib/python3/dist-packages/marshmallow/schema.py", line 559, in dump
    result = self._serialize(processed_obj, many=many)
  File "/usr/lib/python3/dist-packages/marshmallow/schema.py", line 523, in _serialize
    value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute)
  File "/usr/lib/python3/dist-packages/marshmallow/fields.py", line 330, in serialize
    return self._serialize(value, attr, obj, **kwargs)
  File "/usr/lib/python3/dist-packages/marshmallow/fields.py", line 718, in _serialize
    return [self.inner._serialize(each, attr, obj, **kwargs) for each in value]
  File "/usr/lib/python3/dist-packages/marshmallow/fields.py", line 718, in <listcomp>
    return [self.inner._serialize(each, attr, obj, **kwargs) for each in value]
  File "/usr/lib/python3/dist-packages/marshmallow/fields.py", line 585, in _serialize
    return schema.dump(nested_obj, many=many)
  File "/usr/lib/python3/dist-packages/marshmallow/schema.py", line 559, in dump
    result = self._serialize(processed_obj, many=many)
  File "/usr/lib/python3/dist-packages/marshmallow/schema.py", line 523, in _serialize
    value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute)
  File "/usr/lib/python3/dist-packages/marshmallow/fields.py", line 330, in serialize
    return self._serialize(value, attr, obj, **kwargs)
  File "/usr/lib/python3/dist-packages/marshmallow/fields.py", line 1757, in _serialize
    return method(obj)
  File "/usr/src/wazo/wazo-calld/wazo_calld/plugins/parking_lots/schemas.py", line 68, in compute_timeout
    timeout_at = now + timedelta(seconds=int(parked_call.parking_timeout))
OverflowError: Python int too large to convert to C int

@ja0x ja0x force-pushed the WP-1193-call-park-api branch from 80d682c to 4d49bc6 Compare March 21, 2024 02:49
Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/98d940c6844c4033b4c5de2733eb63b2

✔️ tox-linters SUCCESS in 7m 21s
wazo-tox-py39 FAILURE in 7m 12s
✔️ debian-packaging-bullseye SUCCESS in 4m 37s
calld-tox-integration FAILURE in 37m 32s

@sboily
Copy link
Contributor

sboily commented Mar 21, 2024

Please don't use collocutor, it doesn't make any sense here.

Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/b285ac6e88cf42ea9f6ff4788edc290e

✔️ tox-linters SUCCESS in 7m 19s
wazo-tox-py39 FAILURE in 7m 07s
✔️ debian-packaging-bullseye SUCCESS in 4m 49s
calld-tox-integration FAILURE in 37m 52s

Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/5a8f5c84da614016b0b30661e4da4a24

tox-linters FAILURE in 7m 15s
✔️ wazo-tox-py39 SUCCESS in 7m 07s
✔️ debian-packaging-bullseye SUCCESS in 4m 46s
calld-tox-integration FAILURE in 37m 05s

Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/5871941d404d40b9aa724feabbc18d15

✔️ tox-linters SUCCESS in 7m 22s
✔️ wazo-tox-py39 SUCCESS in 7m 11s
✔️ debian-packaging-bullseye SUCCESS in 4m 49s
calld-tox-integration FAILURE in 36m 30s

@ja0x ja0x force-pushed the WP-1193-call-park-api branch from bda7c1e to 1b0596b Compare March 22, 2024 19:27
Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/b98cb1c8dbc84dc889de0136426d8e0f

✔️ tox-linters SUCCESS in 7m 02s
✔️ wazo-tox-py39 SUCCESS in 6m 54s
✔️ debian-packaging-bullseye SUCCESS in 4m 48s
calld-tox-integration FAILURE in 37m 51s

Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/f8c1dc75a05f4a79a0d2d50e195e207a

✔️ tox-linters SUCCESS in 4m 48s
✔️ wazo-tox-py39 SUCCESS in 4m 37s
✔️ debian-packaging-bullseye SUCCESS in 3m 22s
calld-tox-integration FAILURE in 37m 16s

@ja0x ja0x force-pushed the WP-1193-call-park-api branch from efb42b0 to d68d203 Compare March 25, 2024 13:55
Copy link
Contributor

Build succeeded.
https://zuul.wazo.community/zuul/t/local/buildset/287754de6e1c45bbac2343bc446c7fd1

✔️ tox-linters SUCCESS in 4m 45s
✔️ wazo-tox-py39 SUCCESS in 4m 46s
✔️ debian-packaging-bullseye SUCCESS in 3m 34s
✔️ calld-tox-integration SUCCESS in 36m 50s

@ja0x ja0x added the mergeit label Mar 27, 2024
CHANGELOG.md Outdated Show resolved Hide resolved
integration_tests/suite/test_parkings.py Show resolved Hide resolved
integration_tests/suite/test_parkings.py Outdated Show resolved Hide resolved
integration_tests/suite/test_parkings.py Outdated Show resolved Hide resolved
wazo_calld/plugins/parking_lots/http.py Outdated Show resolved Hide resolved
ja0x and others added 12 commits April 2, 2024 08:21
* Changed the version
* Changed the user call parking route
* Added attribute to calls object
why: avoid specific ACL and be consistent with others API
* when setting a timeout of 0, internally, asterisk will use a value of 2^64
(max int).  Calculating a timestamp of now + this max value will overflow and
return an error.  We now detect this and return a null timeout_at value when
timeout is disabled
* microseconds were removed, making the check inaccurate
* mitigates a possible issue if there's system slowness
* change /parking_lots/$id -> /parkinglots/$id
  For symmetry with confd route

* remove collocutor from user's route
  /users/me/calls/$callid/collocutor/park -> /users/me/calls/$callid/park
- test_reparking_call_updates_timeout: fix false negative where only
  first event was pickup

- test_503_when_is_full: check bridge to be full before trying to
  park
Copy link
Contributor

Build succeeded.
https://zuul.wazo.community/zuul/t/local/buildset/f0b00875804b472f819bd51602eefed1

✔️ tox-linters SUCCESS in 4m 49s
✔️ wazo-tox-py39 SUCCESS in 4m 50s
✔️ debian-packaging-bullseye SUCCESS in 2m 10s
✔️ calld-tox-integration SUCCESS in 36m 24s

@ja0x ja0x force-pushed the WP-1193-call-park-api branch from eec19db to 4ae7e13 Compare April 2, 2024 12:23
@ja0x ja0x requested a review from pc-m April 2, 2024 12:24
Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/864a004e1c874d59b9218212a094b03a

✔️ tox-linters SUCCESS in 4m 43s
✔️ wazo-tox-py39 SUCCESS in 4m 26s
✔️ debian-packaging-bullseye SUCCESS in 2m 03s
calld-tox-integration FAILURE in 36m 36s

@ja0x
Copy link
Contributor Author

ja0x commented Apr 2, 2024

recheck

Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/1cfdc7d4b74b4f6dbcbac3fead504e3c

✔️ tox-linters SUCCESS in 7m 07s
✔️ wazo-tox-py39 SUCCESS in 6m 25s
✔️ debian-packaging-bullseye SUCCESS in 2m 23s
calld-tox-integration FAILURE in 36m 41s

Copy link
Contributor

Build failed.
https://zuul.wazo.community/zuul/t/local/buildset/083cd16586104307ba7c9e501a487950

tox-linters FAILURE in 7m 03s
✔️ wazo-tox-py39 SUCCESS in 6m 44s
✔️ debian-packaging-bullseye SUCCESS in 2m 05s
✔️ calld-tox-integration SUCCESS in 36m 04s

- Fix an issue w/ calls without tenant_uuid or user_uuid
- Up default parking timeout to 45 to prevent channels from timing out
  before all channels are parked with a slow asterisk
@ja0x ja0x force-pushed the WP-1193-call-park-api branch from a7ed31a to b8f2346 Compare April 2, 2024 15:46
Copy link

sonarqubecloud bot commented Apr 2, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

Build succeeded.
https://zuul.wazo.community/zuul/t/local/buildset/4a3e53507dae429e99e1ab166f909529

✔️ tox-linters SUCCESS in 4m 51s
✔️ wazo-tox-py39 SUCCESS in 4m 37s
✔️ debian-packaging-bullseye SUCCESS in 2m 06s
✔️ calld-tox-integration SUCCESS in 36m 12s

@ja0x ja0x dismissed fblackburn1’s stale review April 2, 2024 17:42

Has been modified to take care of

@ja0x ja0x added mergeit and removed mergeit labels Apr 2, 2024
Copy link
Contributor

Build succeeded (gate pipeline).
https://zuul.wazo.community/zuul/t/local/buildset/18e8fe8dd360498f9c3a11ac580387bb

✔️ tox-linters SUCCESS in 4m 48s
✔️ wazo-tox-py39 SUCCESS in 4m 33s
✔️ debian-packaging-bullseye SUCCESS in 2m 12s
✔️ calld-tox-integration SUCCESS in 37m 23s

@wazo-community-zuul wazo-community-zuul bot merged commit 3d31969 into master Apr 2, 2024
3 checks passed
@wazo-community-zuul wazo-community-zuul bot deleted the WP-1193-call-park-api branch April 2, 2024 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants