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

[Event Hubs] Port azure storage blob code into checkpointstore #9950

Merged
merged 36 commits into from
Mar 6, 2020

Conversation

YijunXieMS
Copy link
Contributor

@YijunXieMS YijunXieMS commented Feb 21, 2020

This PR is for issue #7808 - Remove checkpointstore's dependency on azure blob storage.
An example is the latest azure-storage-blob SDK v12.x supports storage service API 2019-02-02 and 2019-07-07. But Azure Stack's storage service API version is 2017-11-09. So lib azure-eventhub-checkpointstoreblob and azure-eventhub-checkpointblob-aio can't work on Azure Stack.

This PR is to port the latest storage blob SDK code to the two checkpointstore libs and make it to be compatible with storage 2017-11-09. And this doesn't introduce a break change to the user.

These changes are made:

  • Copy storage blob v12.2.1 from latest master to azure.eventhub.extensions.checkpointstoreblobaio._vendor and azure.eventhub.extensions.checkpointstoreblob._vendor
  • Removed dependency on azure-storage and added storage’s dependency (azure-core, msrest and cryptography) to checkpointstore’s setup.py
  • BlobCheckpointStore imports ContainerClient and BlobClient from vendored code instead of azure-storage-blob code.
  • BlobCheckpointStore converts param "api_version" to http header "x-ms-version"

An Azure Stack user will need to specify storage service api_version when creating an BlobCheckpointStore if the api_version isn't the latest version.

    checkpoint_store = BlobCheckpointStore.from_connection_string(
        STORAGE_CONNECTION_STR, 
        BLOB_CONTAINER_NAME,
        api_version="2017-11-09"
    )

@YijunXieMS
Copy link
Contributor Author

/azp run python - eventhubs - ci

@azure-pipelines
Copy link

Pull request contains merge conflicts.

@YijunXieMS
Copy link
Contributor Author

/azp run python - eventhubs - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -97,6 +97,20 @@ if __name__ == '__main__':
loop.run_until_complete(main())
```

#### Use `BlobCheckpointStore` with a different version of Azure Storage Service API
Some environments have different versions of Azure Storage Service API. For instance, some Azure Stack use 2017-11-09.
Copy link
Member

Choose a reason for hiding this comment

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

"some Azure Stack deployments"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we have other deployments that are not Azure Stack

Copy link
Member

Choose a reason for hiding this comment

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

In that case I would change it to "For instance, Azure Stack may use...."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed

if headers:
headers["x-ms-version"] = api_version
else:
kwargs["headers"] = {"x-ms-version": api_version}
Copy link
Member

Choose a reason for hiding this comment

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

You could simplify:

headers = kwargs.get("headers") or {}
headers["x-ms-version"] = api_version

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to this

loop = asyncio.get_event_loop()
checkpoint_store = BlobCheckpointStore.from_connection_string(
STORAGE_CONNECTION_STR,
container_name=BLOB_CONTAINER_NAME,
Copy link
Member

Choose a reason for hiding this comment

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

API version sample doesn't use API version :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -2,6 +2,9 @@

## 1.0.1 (Unreleased)

**New features**
- Param `api_version` of `BlobPartitionManager` now supports older versions of Azure Storage Serice API.
Copy link
Member

Choose a reason for hiding this comment

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

Typo: "Service"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. good catch

annatisch
annatisch previously approved these changes Mar 5, 2020
@YijunXieMS
Copy link
Contributor Author

/azp run python - eventhubs - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@YijunXieMS YijunXieMS merged commit 4c50b69 into Azure:master Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants