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

LeaseIDMissing error even though LeaseID is present #230

Closed
eccles opened this issue Nov 19, 2020 · 5 comments
Closed

LeaseIDMissing error even though LeaseID is present #230

eccles opened this issue Nov 19, 2020 · 5 comments

Comments

@eccles
Copy link

eccles commented Nov 19, 2020

Which version of the SDK was used?

0.10.0 and 0.11.0

Which platform are you using? (ex: Windows, Linux, Debian)

Linux

What problem was encountered?

LeaseIDMissing error even though LeaseID is present. Code worked previously on 0.8.0

How can we reproduce the problem in the simplest way?

Example code that is failing:

// WriteWithLease writes to blob with lease - pass empty lease for no lease
func (azp *Storer) WriteWithLease(
    ctx context.Context,
    objectname string,
    reader io.Reader,
    leaseID string,
) error {
    logger.Sugar.Debugf("WriteWithLease: %s %s", objectname, leaseID)
    
    objectURL, err := url.Parse(fmt.Sprintf(
        "%s/%s",
        azp.containerURL,
        objectname,
    )) 
    if err != nil {
        logger.Sugar.Infof("WriteWithLease URL parse error: %v", err)
        return err
   }

   blockBlobURL := azStorageBlob.NewBlockBlobURL(
       *objectURL,
        azStorageBlob.NewPipeline(
            azp.Credential,
            azStorageBlob.PipelineOptions{
                Retry: azStorageBlob.RetryOptions{
                    TryTimeout: tryTimeoutSecs * time.Second,
                },
           },
       ),
    )

    blobAccessConditions := azStorageBlob.BlobAccessConditions{
        LeaseAccessConditions: azStorageBlob.LeaseAccessConditions{
           LeaseID: leaseID,
        },
   }

    logger.Sugar.Debugf("WriteWithLease: accessConditions %v", blobAccessConditions)
    _, err = azStorageBlob.UploadStreamToBlockBlob(
        ctx,
        reader,
        blockBlobURL,
        azStorageBlob.UploadStreamToBlockBlobOptions{
            BufferSize:       chunkSize,
            MaxBuffers:       3,
            AccessConditions: blobAccessConditions,
        },
    )
    if err != nil {
        logger.Sugar.Infof("WriteWithLease cannot upload blobs: %v", err)
        return ErrorFromError(err)

    }
    return nil
}

Have you found a mitigation/solution?

No

Other Info (Log output):
DEBUG   azblob/storer.go:348    WriteWithLease: accessConditions {{0001-01-01 00:00:00 +0000 UTC 0001-01-01 00:00:00 +0000 UTC  } {4a66fbe7-053a-4c66-ba12-81ac039347a8}}
INFO    azblob/storer.go:360    WriteWithLease cannot upload blobs: write error: -> github.com/Azure/azure-storage-blob-go/azblob.newStorageError, /opt/go/pkg/mod/github.com/!azure/azure-storage-blob-go@v0.11.0/azblob/zc_storage_error.go:42
===== RESPONSE ERROR (ServiceCode=LeaseIdMissing) =====
Description=There is currently a lease on the blob and no lease ID was specified in the request.
RequestId:5a264520-d01e-0018-6774-beb83f000000
Time:2020-11-19T13:01:47.8449028Z, Details:
  Code: LeaseIdMissing
  PUT https://xxxxxxxxxxxxxxxxxxxxxx.blob.core.windows.net/dlt/yyyyy?blockid=g1zcpLIGR2GdQ0gAXkScDgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%3D%3D&comp=block&timeout=31
  Authorization: REDACTED
  Content-Length: [73]
  User-Agent: [Azure-Storage/0.11 (go1.14.8; linux)]
  X-Ms-Client-Request-Id: [1a06b262-8072-4545-631c-addda4e9290c]
  X-Ms-Date: [Thu, 19 Nov 2020 13:01:47 GMT]
  X-Ms-Version: [2019-12-12]
  --------------------------------------------------------------------------------
  RESPONSE Status: 412 There is currently a lease on the blob and no lease ID was specified in the request.
  Content-Length: [267]
  Content-Type: [application/xml]
  Date: [Thu, 19 Nov 2020 13:01:47 GMT]
  Server: [Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0]
  X-Ms-Client-Request-Id: [1a06b262-8072-4545-631c-addda4e9290c]
  X-Ms-Error-Code: [LeaseIdMissing]
  X-Ms-Request-Id: [5a264520-d01e-0018-6774-beb83f000000]
  X-Ms-Version: [2019-12-12]

@eccles
Copy link
Author

eccles commented Nov 20, 2020

anyone monitoring this repo?

@eccles
Copy link
Author

eccles commented Nov 20, 2020

I have fixed it - heres the diff:
diff --git a/src/microsoft/azblob/chunkwriting.go b/src/microsoft/azblob/chunkwriting.go
index f44727eb..47aa9ff4 100644
--- a/src/microsoft/azblob/chunkwriting.go
+++ b/src/microsoft/azblob/chunkwriting.go
@@ -184,7 +184,7 @@ func (c *copier) write(chunk copierChunk) error {
return err
}

-       _, err := c.to.StageBlock(c.ctx, chunk.id, bytes.NewReader(chunk.buffer), LeaseAccessConditions{}, nil)
+       _, err := c.to.StageBlock(c.ctx, chunk.id, bytes.NewReader(chunk.buffer), c.o.AccessConditions.LeaseAccessConditions, nil)
         if err != nil {
                return fmt.Errorf("write error: %w", err)
         }

@eccles
Copy link
Author

eccles commented Nov 20, 2020

The lease access conditions in the copier struct are not propagated to the StageBlock call. I made this change and now the LeaseId error no longer occurs and all is good.

I would really appreciate if a release 0.11.1 could be made ASAP with this fix

@mohsha-msft
Copy link
Contributor

Hey @eccles ,

I appreciate your contribution. We'll try to include it in the next release.

mohsha-msft added a commit that referenced this issue Nov 20, 2020
@eccles
Copy link
Author

eccles commented Dec 14, 2020

Thanks for the release - however the tagging has gone awry - I change my go.mod file to:

github.com/Azure/azure-storage-blob-go v0.12.0

and inspection of my go cache:

vi /opt/go/pkg/mod/github.com/!azure/azure-storage-blob-go@v0.12.0/azblob/chunkwriting.go

shows the change has not been applied.

187 _, err := c.to.StageBlock(c.ctx, chunk.id, bytes.NewReader(chunk.buffer), LeaseAccessConditions{}, nil, c.o.ClientProvidedKeyOptions)

If I pull repo directly using git clone and inspect that all looks good:

paul@paul-Precision-7530:~/git/azure-storage-blob-go$ git log
commit 6df5d9a (HEAD -> master, tag: v0.12.0, origin/master, origin/HEAD)
Merge: 456ab47 559b75b
Author: Mohit Sharma 65536214+mohsha-msft@users.noreply.github.com
Date: Wed Dec 9 17:40:48 2020 +0530

Merge pull request #235 from Azure/dev

Release v0.12.0

commit 559b75b (origin/dev)
Author: Mohit Sharma 65536214+mohsha-msft@users.noreply.github.com
Date: Wed Dec 9 12:49:08 2020 +0530

v0.12.0 Release change logs (#231)

* v0.12.0 Release ChangeLogs & BreakingChanges

* Updated changelogs

* Added mmf changes in ChangeLog.md

commit 0c35e97
Author: Mohit Sharma 65536214+mohsha-msft@users.noreply.github.com
Date: Fri Nov 20 23:41:19 2020 +0530

Fixed #230 (#232)

and the fix is in:

186 _, err := c.to.StageBlock(c.ctx, chunk.id, bytes.NewReader(chunk.buffer), c.o.AccessConditions.LeaseAccessConditions, nil, c.o.ClientProvidedKeyOptions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants