Skip to content

Commit

Permalink
Revert "[EventHub] Raise error when primary key is rotated" (Azure#37622
Browse files Browse the repository at this point in the history
)

* Revert "[EventHub] Raise error when primary key is rotated (Azure#36245)"

This reverts commit 3b2dfa4.

* skip windows tests
  • Loading branch information
swathipil authored Sep 30, 2024
1 parent ae22841 commit e7724da
Show file tree
Hide file tree
Showing 11 changed files with 6 additions and 26 deletions.
2 changes: 0 additions & 2 deletions sdk/eventhub/azure-eventhub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

### Bugs Fixed

- Fixed a bug where the consumer waited indefinitely when the primary key was rotated while receiving, rather than raising an authentication error. ([#33926](https://github.com/Azure/azure-sdk-for-python/issues/33926))

### Other Changes

## 5.12.1 (2024-06-11)
Expand Down
5 changes: 0 additions & 5 deletions sdk/eventhub/azure-eventhub/azure/eventhub/_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,6 @@ def receive(self, batch=False, max_batch_size=300, max_wait_time=None):
# If optional dependency is not installed, do not retry.
if isinstance(exception, ImportError):
raise exception

# If authentication exception, do not retry.
if isinstance(exception, self._amqp_transport.AUTHENTICATION_EXCEPTION):
raise self._handle_exception(exception, is_consumer=True)

self._amqp_transport.check_link_stolen(self, exception)
# TODO: below block hangs when retry_total > 0
# need to remove/refactor, issue #27137
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
ReceiveClient as uamqp_ReceiveClient,
)
from uamqp.authentication import JWTTokenAuth as uamqp_JWTTokenAuth
from uamqp.errors import AuthenticationException as uamqp_AuthenticationException

except ImportError:
pass
Expand All @@ -49,7 +48,6 @@
from .._pyamqp.constants import (
ConnectionState as pyamqp_ConnectionState
)
from .._pyamqp.error import AuthenticationException as pyamqp_AuthenticationException

class AmqpTransport(ABC): # pylint: disable=too-many-public-methods
"""
Expand Down Expand Up @@ -78,9 +76,6 @@ class AmqpTransport(ABC): # pylint: disable=too-many-public-methods
USER_AGENT_SYMBOL: Union[uamqp_Types_AMQPSymbol, str, bytes]
PROP_PARTITION_KEY_AMQP_SYMBOL: Union[uamqp_Types_AMQPSymbol, str, bytes]

# exceptions
AUTHENTICATION_EXCEPTION: Union["uamqp_AuthenticationException", "pyamqp_AuthenticationException"]

@staticmethod
@abstractmethod
def build_message(**kwargs: Any) -> Union["uamqp_Message", "pyamqp_Message"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ class PyamqpTransport(AmqpTransport): # pylint: disable=too-many-public-method

ERROR_CONDITIONS = [condition.value for condition in errors.ErrorCondition]

# define exceptions
AUTHENTICATION_EXCEPTION = errors.AuthenticationException

@staticmethod
def build_message(**kwargs):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ class UamqpTransport(AmqpTransport): # pylint: disable=too-many-public-method
USER_AGENT_SYMBOL = types.AMQPSymbol("user-agent")
PROP_PARTITION_KEY_AMQP_SYMBOL = types.AMQPSymbol(PROP_PARTITION_KEY)

# define exceptions
AUTHENTICATION_EXCEPTION = errors.AuthenticationException

@staticmethod
def build_message(**kwargs):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
**kwargs: Any
) -> None:
self._loop = kwargs.get("loop")
self._lock = Lock(loop=self._loop) # pylint: disable=unexpected-keyword-arg
self._lock = Lock(loop=self._loop)
self._conn: Optional[Union[uamqp_ConnectionAsync, ConnectionAsync]] = None

self._container_id = container_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class AmqpTransportAsync(ABC): # pylint: disable=too-many-public-methods
USER_AGENT_SYMBOL: Union[uamqp_Types_AMQPSymbol, Literal["user-agent"]]
PROP_PARTITION_KEY_AMQP_SYMBOL: Union[uamqp_Types_AMQPSymbol, Literal[b'x-opt-partition-key']]


@staticmethod
@abstractmethod
def build_message(**kwargs: Any) -> Union["uamqp_Message", "pyamqp_Message"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,6 @@ async def _receive_task(consumer, max_batch_size):
# If optional dependency is not installed, do not retry.
if isinstance(exception, ImportError):
raise exception
# If authentication exception, do not retry.
if isinstance(exception, errors.AuthenticationException):
raise await consumer._handle_exception(exception)
if (
isinstance(exception, errors.AMQPLinkError)
and exception.condition == errors.ErrorCondition.LinkStolen # pylint: disable=no-member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ async def receive_messages_async(
except asyncio.CancelledError: # pylint: disable=try-except-raise
raise
except Exception as exception: # pylint: disable=broad-except
# If authentication exception, do not retry.
if isinstance(exception, errors.AuthenticationException):
raise await consumer._handle_exception(exception)
if (
isinstance(exception, errors.LinkDetach)
and exception.condition == constants.ErrorCodes.LinkStolen # pylint: disable=no-member
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# license information.
# --------------------------------------------------------------------------

import sys
import pytest

from azure.eventhub.aio import (
Expand Down Expand Up @@ -101,6 +102,7 @@ async def test_get_partition_ids(auth_credentials_async, uamqp_transport):
assert partition_ids == ["0", "1"]


@pytest.mark.skipif(sys.platform.startswith("win"), reason="Large negative timestamp to datetime conversion fails on Windows with: https://bugs.python.org/issue36439")
@pytest.mark.liveTest
@pytest.mark.asyncio
async def test_get_partition_properties(auth_credentials_async, uamqp_transport):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# license information.
# --------------------------------------------------------------------------

import sys
import pytest

from azure.eventhub import EventHubSharedKeyCredential
Expand Down Expand Up @@ -97,7 +98,7 @@ def test_get_partition_ids(auth_credentials, uamqp_transport):
partition_ids = client.get_partition_ids()
assert partition_ids == ["0", "1"]


@pytest.mark.skipif(sys.platform.startswith("win"), reason="Large negative timestamp to datetime conversion fails on Windows with: https://bugs.python.org/issue36439")
@pytest.mark.liveTest
def test_get_partition_properties(auth_credentials, uamqp_transport):
fully_qualified_namespace, eventhub_name, credential = auth_credentials
Expand Down

0 comments on commit e7724da

Please sign in to comment.