-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
PubSub Client: list_subscriptions returns all subscriptions, not just for that topic #4426
Comments
+1 |
So this is an issue, but not really as reported. The problem is that In [1]: import google.auth
In [2]: from google.cloud import pubsub_v1
In [3]: _, project = google.auth.default()
In [4]: publisher = pubsub_v1.PublisherClient()
E1215 14:50:02.433979430 11896 ev_epollex_linux.cc:1482] Skipping epollex becuase GRPC_LINUX_EPOLL is not defined.
E1215 14:50:02.434013514 11896 ev_epoll1_linux.cc:1261] Skipping epoll1 becuase GRPC_LINUX_EPOLL is not defined.
E1215 14:50:02.434020956 11896 ev_epollsig_linux.cc:1761] Skipping epollsig becuase GRPC_LINUX_EPOLL is not defined.
In [5]: subscriber = pubsub_v1.SubscriberClient()
In [6]: subscriber.list_subscriptions?
Signature: subscriber.list_subscriptions(project, ...)
Docstring:
Lists matching subscriptions.
...
Args:
project (str): The name of the cloud project that subscriptions belong to.
Format is ``projects/{project}``.
...
In [7]: project_path = subscriber.project_path(project)
In [8]: LS = list(subscriber.list_subscriptions(project_path))
In [9]: len(LS)
Out[9]: 6 The method you want is In [10]: topic_path = publisher.topic_path(project, 'abcdef2')
In [11]: LTS = list(publisher.list_topic_subscriptions(topic_path))
In [12]: len(LTS)
Out[12]: 3
In [13]: publisher.list_topic_subscriptions?
Signature: publisher.list_topic_subscriptions(topic, ...)
Docstring:
Lists the name of the subscriptions for this topic.
...
Args:
topic (str): The name of the topic that subscriptions are attached to.
Format is ``projects/{project}/topics/{topic}``. The actual issue is that In [14]: topic_path.startswith(project_path)
Out[14]: True
In [15]: LS_ALSO = list(subscriber.list_subscriptions(topic_path))
In [16]: LS_ALSO == LS
Out[16]: True I think an issue could be filed with the backend to reject those requests with the /cc @kir-titievsky |
I filed https://issuetracker.google.com/issues/70727179 with the backend team. |
@dhermes If this is indeed the issue, then this needs to be updated: https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/pubsub/cloud-client/subscriber.py#L30 The docs state that my method was the way to retrieve by topic. |
Thanks for finding that @anorth2 (I'm only loosely aware of what's in |
…)](GoogleCloudPlatform/python-docs-samples#4426) This PR contains the following updates: | Package | Update | Change | |---|---|---| | [google-cloud-translate](https://github.com/googleapis/python-translate) | patch | `==2.0.1` -> `==2.0.2` | --- <details> <summary>googleapis/python-translate</summary> [Compare Source](https://github.com/googleapis/python-translate/compare/v2.0.1...v2.0.2) </details> --- :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Never, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#GoogleCloudPlatform/python-docs-samples).
OS type and version
Any and all
Python version and virtual environment information
python --version
Python 3.6.3
google-cloud-python version
pip show google-cloud
,pip show google-<service>
orpip freeze
google==1.9.3
google-api-core==0.1.1
google-auth==1.2.1
google-cloud-core==0.28.0
google-cloud-pubsub==0.29.0
google-gax==0.15.16
googleapis-common-protos==1.5.3
grpc-google-iam-v1==0.11.4
Stacktrace if available
Steps to reproduce
Run example code for listing subscriptions for a topic from here:
https://cloud.google.com/pubsub/docs/admin
Code example
topic path being used as shown by
topic_path = subscriber.topic_path(project, topic_name)
:projects/my-team-dev/topics/testing-topic
Using GitHub flavored markdown can help make your request clearer.
See: https://guides.github.com/features/mastering-markdown/
The text was updated successfully, but these errors were encountered: