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

Enable legacy checkpoint reading in WebJobs #17392

Merged

Conversation

pakrym
Copy link
Contributor

@pakrym pakrym commented Dec 7, 2020

Fixes: #17034

Also include name casing in tests.

@@ -344,7 +344,8 @@ await foreach (BlobItem blob in ContainerClient.GetBlobsAsync(traits: BlobTraits

async Task<List<EventProcessorCheckpoint>> listLegacyCheckpointsAsync(List<EventProcessorCheckpoint> existingCheckpoints, CancellationToken listCheckpointsToken)
{
var legacyPrefix = string.Format(CultureInfo.InvariantCulture, LegacyCheckpointPrefix, fullyQualifiedNamespace.ToLowerInvariant(), eventHubName.ToLowerInvariant(), consumerGroup.ToLowerInvariant());
// Legacy checkpoints are not normalized to lowercase
var legacyPrefix = string.Format(CultureInfo.InvariantCulture, LegacyCheckpointPrefix, fullyQualifiedNamespace, eventHubName, consumerGroup);
Copy link
Member

Choose a reason for hiding this comment

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

Without this change, are the legacy checkpoints skipped? Do we have a test for this?

Copy link
Member

Choose a reason for hiding this comment

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

That's an interesting question... I think that Storage is case-sensitive for naming, but I'm not 100% sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I changed the existing tests to use the expected casing both to T1 and T2 checkpoints. Storage is case-sensitive.

@@ -60,7 +60,7 @@ public async Task ListCheckpointsAsync_LogsOnInvalidCheckpoints()
{
Page<BlobItem>.FromValues(new[]
{
BlobsModelFactory.BlobItem("testnamespace/testeventhubname/testconsumergroup/checkpoint/0", false, BlobsModelFactory.BlobItemProperties(false), metadata: new Dictionary<string, string>())
BlobsModelFactory.BlobItem("testnamespace/testeventhubname/testconsumergroup/checkpoint/0", false, BlobsModelFactory.BlobItemProperties(false, contentLength: 0), metadata: new Dictionary<string, string>())
Copy link
Member

@JoshLove-msft JoshLove-msft Dec 8, 2020

Choose a reason for hiding this comment

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

Why do we pass contentLength of 0?

Copy link
Member

@jsquire jsquire Dec 8, 2020

Choose a reason for hiding this comment

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

There is no content for a checkpoint blob; its a zero-byte file. The data exists entirely in the metadata. I'm not sure why the text is explicitly setting this, as no logic relies on it, but it does mirror what is expected for the actual service return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

ah, fair enough. I was thinking in terms of the T2 checkpoints. Makes sense in the legacy context.

@@ -31,7 +31,7 @@ protected BlobsCheckpointStore()
public BlobsCheckpointStore(BlobContainerClient blobContainerClient,
EventHubsRetryPolicy retryPolicy,
string functionId,
ILogger logger): this(blobContainerClient, retryPolicy)
ILogger logger): this(blobContainerClient, retryPolicy, readLegacyCheckpoints: true)
Copy link
Member

Choose a reason for hiding this comment

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

Should we consider renaming to something like initializeWithLegacyCheckpoints to reflect that the intent is to read them once and then replace them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, will do.

@ghost
Copy link

ghost commented Dec 8, 2020

Hello @pakrym!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit b179f15 into Azure:master Dec 8, 2020
annelo-msft pushed a commit to annelo-msft/azure-sdk-for-net that referenced this pull request Feb 17, 2021
This pull request was closed.
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.

[WebJobs/EventHubs] Add checkpoint migration support
3 participants