Skip to content

Commit

Permalink
[AzDatalake] Lease Clients Implementation (#21297)
Browse files Browse the repository at this point in the history
* Enable gocritic during linting (#20715)

Enabled gocritic's evalOrder to catch dependencies on undefined behavior
on return statements.
Updated to latest version of golangci-lint.
Fixed issue in azblob flagged by latest linter.

* Cosmos DB: Enable merge support (#20716)

* Adding header and value

* Wiring and tests

* format

* Fixing value

* change log

* [azservicebus, azeventhubs] Stress test and logging improvement (#20710)

Logging improvements:

* Updating the logging to print more tracing information (per-link) in prep for the bigger release coming up.
* Trimming out some of the verbose logging, seeing if I can get it a bit more reasonable.

Stress tests:

* Add a timestamp to the log name we generate and also default to append, not overwrite.
* Use 0.5 cores, 0.5GB as our baseline. Some pods use more and I'll tune them more later.

* update proxy version (#20712)

Co-authored-by: Scott Beddall <[email protected]>

* Return an error when you try to send a message that's too large. (#20721)

This now works just like the message batch - you'll get an ErrMessageTooLarge
if you attempt to send a message that's too large for the link's configured
size.

NOTE: there's a patch to `internal/go-amqp/Sender.go` to match what's in go-amqp's
main so it returns a programmatically useful error when the message is too large.

Fixes #20647

* Changes in test that is failing in pipeline (#20693)

* [azservicebus, azeventhubs] Treat 'entity full' as a fatal error (#20722)

When the remote entity is full we get a resource-limit-exceeded condition. This isn't something we should keep retrying on and it's best to just abort and let the user know immediately, rather than hoping it might eventually clear out.

This affected both Event Hubs and Service Bus.

Fixes #20647

* [azservicebus/azeventhubs] Redirect stderr and stdout to tee (#20726)

* Update changelog with latest features (#20730)

* Update changelog with latest features

Prepare for upcoming release.

* bump minor version

* pass along the artifact name so we can override it later (#20732)

Co-authored-by: scbedd <[email protected]>

* [azeventhubs] Fixing checkpoint store race condition (#20727)

The checkpoint store wasn't guarding against multiple owners claiming for the first time - fixing this by using IfNoneMatch

Fixes #20717

* Fix azidentity troubleshooting guide link (#20736)

* [Release] sdk/resourcemanager/paloaltonetworksngfw/armpanngfw/0.1.0 (#20437)

* [Release] sdk/resourcemanager/paloaltonetworksngfw/armpanngfw/0.1.0 generation from spec commit: 85fb4ac6f8bfefd179e6c2632976a154b5c9ff04

* client factory

* fix

* fix

* update

* add sdk/resourcemanager/postgresql/armpostgresql live test (#20685)

* add sdk/resourcemanager/postgresql/armpostgresql live test

* update assets.json

* set subscriptionId default value

* format

* add sdk/resourcemanager/eventhub/armeventhub live test (#20686)

* add sdk/resourcemanager/eventhub/armeventhub live test

* update assets

* add sdk/resourcemanager/compute/armcompute live test (#20048)

* add sdk/resourcemanager/compute/armcompute live test

* skus filter

* fix subscriptionId default value

* fix

* gofmt

* update recording

* sdk/resourcemanager/network/armnetwork live test (#20331)

* sdk/resourcemanager/network/armnetwork live test

* update subscriptionId default value

* update recording

* add sdk/resourcemanager/cosmos/armcosmos live test (#20705)

* add sdk/resourcemanager/cosmos/armcosmos live test

* update assets.json

* update assets.json

* update assets.json

* update assets.json

* Increment package version after release of azcore (#20740)

* [azeventhubs] Improperly resetting etag in the checkpoint store (#20737)

We shouldn't be resetting the etag to nil - it's what we use to enforce a "single winner" when doing ownership claims.

The bug here was two-fold: I had bad logic in my previous claim ownership, which I fixed in a previous PR, but we need to reflect that same constraint properly in our in-memory checkpoint store for these tests.

* Eng workflows sync and branch cleanup additions (#20743)

Co-authored-by: James Suplizio <[email protected]>

* [azeventhubs] Latest start position can also be inclusive (ie, get the latest message) (#20744)

* Update GitHubEventProcessor version and remove pull_request_review procesing (#20751)

Co-authored-by: James Suplizio <[email protected]>

* Rename DisableAuthorityValidationAndInstanceDiscovery (#20746)

* fix (#20707)

* AzFile (#20739)

* azfile: Fixing connection string parsing logic (#20798)

* Fixing connection string parse logic

* Update README

* [azadmin] fix flaky test (#20758)

* fix flaky test

* charles suggestion

* Prepare azidentity v1.3.0 for release (#20756)

* Fix broken podman link (#20801)

Co-authored-by: Wes Haggard <[email protected]>

* [azquery] update doc comments (#20755)

* update doc comments

* update statistics and visualization generation

* prep-for-release

* Fixed contribution section (#20752)

Co-authored-by: Bob Tabor <[email protected]>

* [azeventhubs,azservicebus] Some API cleanup, renames (#20754)

* Adding options to UpdateCheckpoint(), just for future potential expansion
* Make Offset an int64, not a *int64 (it's not optional, it'll always come back with ReceivedEvents)
* Adding more logging into the checkpoint store.
* Point all imports at the production go-amqp

* Add supporting features to enable distributed tracing (#20301) (#20708)

* Add supporting features to enable distributed tracing

This includes new internal pipeline policies and other supporting types.
See the changelog for a full description.
Added some missing doc comments.

* fix linter issue

* add net.peer.name trace attribute

sequence custom HTTP header policy before logging policy.
sequence logging policy after HTTP trace policy.
keep body download policy at the end.

* add span for iterating over pages

* Restore ARM CAE support for azcore beta (#20657)

This reverts commit 9020972.

* Upgrade to stable azcore (#20808)

* Increment package version after release of data/azcosmos (#20807)

* Updating changelog (#20810)

* Add fake package to azcore (#20711)

* Add fake package to azcore

This is the supporting infrastructure for the generated SDK fakes.

* fix doc comment

* Updating CHANGELOG.md (#20809)

* changelog (#20811)

* Increment package version after release of storage/azfile (#20813)

* Update changelog (azblob) (#20815)

* Updating CHANGELOG.md

* Update the changelog with correct version

* [azquery] migration guide (#20742)

* migration guide

* Charles feedback

* Richard feedback

---------

Co-authored-by: Charles Lowell <[email protected]>

* Increment package version after release of monitor/azquery (#20820)

* [keyvault] prep for release (#20819)

* prep for release

* perf tests

* update date

* lease implementation and tests

* tests

* handled errors

* nit

---------

Co-authored-by: Joel Hendrix <[email protected]>
Co-authored-by: Matias Quaranta <[email protected]>
Co-authored-by: Richard Park <[email protected]>
Co-authored-by: Azure SDK Bot <[email protected]>
Co-authored-by: Scott Beddall <[email protected]>
Co-authored-by: siminsavani-msft <[email protected]>
Co-authored-by: scbedd <[email protected]>
Co-authored-by: Charles Lowell <[email protected]>
Co-authored-by: Peng Jiahui <[email protected]>
Co-authored-by: James Suplizio <[email protected]>
Co-authored-by: Sourav Gupta <[email protected]>
Co-authored-by: gracewilcox <[email protected]>
Co-authored-by: Wes Haggard <[email protected]>
Co-authored-by: Bob Tabor <[email protected]>
Co-authored-by: Bob Tabor <[email protected]>
  • Loading branch information
16 people authored Aug 1, 2023
1 parent 757507a commit 58726b9
Show file tree
Hide file tree
Showing 10 changed files with 689 additions and 32 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/azdatalake/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "go",
"TagPrefix": "go/storage/azdatalake",
"Tag": "go/storage/azdatalake_9dd1cc3e0e"
"Tag": "go/storage/azdatalake_78f150eb1d"
}
4 changes: 2 additions & 2 deletions sdk/storage/azdatalake/directory/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ func (d *Client) renamePathInURL(newName string) (string, string, string) {
lastIndex := strings.LastIndex(endpoint, separator)
// Split the string based on the last occurrence of the separator
firstPart := endpoint[:lastIndex] // From the beginning of the string to the last occurrence of the separator
newPathURL, newBlobURL := shared.GetURLs(runtime.JoinPaths(firstPart, newName))
newBlobURL, newPathURL := shared.GetURLs(runtime.JoinPaths(firstPart, newName))
parsedNewURL, _ := url.Parse(d.DFSURL())
return parsedNewURL.Path, newPathURL, newBlobURL
}

// Rename renames a directory (dfs1)
func (d *Client) Rename(ctx context.Context, newName string, options *RenameOptions) (RenameResponse, error) {
newPathWithoutURL, newBlobURL, newPathURL := d.renamePathInURL(newName)
newPathWithoutURL, newPathURL, newBlobURL := d.renamePathInURL(newName)
lac, mac, smac, createOpts := path.FormatRenameOptions(options, newPathWithoutURL)
var newBlobClient *blockblob.Client
var err error
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/azdatalake/file/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ func (f *Client) renamePathInURL(newName string) (string, string, string) {
lastIndex := strings.LastIndex(endpoint, separator)
// Split the string based on the last occurrence of the separator
firstPart := endpoint[:lastIndex] // From the beginning of the string to the last occurrence of the separator
newPathURL, newBlobURL := shared.GetURLs(runtime.JoinPaths(firstPart, newName))
newBlobURL, newPathURL := shared.GetURLs(runtime.JoinPaths(firstPart, newName))
parsedNewURL, _ := url.Parse(f.DFSURL())
return parsedNewURL.Path, newPathURL, newBlobURL
}

// Rename renames a file (dfs1)
func (f *Client) Rename(ctx context.Context, newName string, options *RenameOptions) (RenameResponse, error) {
newPathWithoutURL, newBlobURL, newPathURL := f.renamePathInURL(newName)
newPathWithoutURL, newPathURL, newBlobURL := f.renamePathInURL(newName)
lac, mac, smac, createOpts := path.FormatRenameOptions(options, newPathWithoutURL)
var newBlobClient *blockblob.Client
var err error
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/azdatalake/filesystem/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ func (fs *Client) BlobURL() string {
// The new directory.Client uses the same request policy pipeline as the Client.
func (fs *Client) NewDirectoryClient(directoryPath string) *directory.Client {
dirURL := runtime.JoinPaths(fs.generatedFSClientWithDFS().Endpoint(), directoryPath)
dirURL, blobURL := shared.GetURLs(dirURL)
blobURL, dirURL := shared.GetURLs(dirURL)
return (*directory.Client)(base.NewPathClient(dirURL, blobURL, fs.containerClient().NewBlockBlobClient(directoryPath), fs.generatedFSClientWithDFS().InternalClient().WithClientName(shared.DirectoryClient), fs.sharedKey(), fs.identityCredential(), fs.getClientOptions()))
}

// NewFileClient creates a new file.Client object by concatenating file path to the end of this Client's URL.
// The new file.Client uses the same request policy pipeline as the Client.
func (fs *Client) NewFileClient(filePath string) *file.Client {
fileURL := runtime.JoinPaths(fs.generatedFSClientWithDFS().Endpoint(), filePath)
fileURL, blobURL := shared.GetURLs(filePath)
blobURL, fileURL := shared.GetURLs(fileURL)
return (*file.Client)(base.NewPathClient(fileURL, blobURL, fs.containerClient().NewBlockBlobClient(filePath), fs.generatedFSClientWithDFS().InternalClient().WithClientName(shared.FileClient), fs.sharedKey(), fs.identityCredential(), fs.getClientOptions()))
}

Expand Down
14 changes: 14 additions & 0 deletions sdk/storage/azdatalake/internal/testcommon/clients_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,20 @@ func GetFileClient(fsName, fName string, t *testing.T, accountType TestAccountTy
return fileClient, err
}

func CreateNewFile(ctx context.Context, _require *require.Assertions, fileName string, filesystemClient *filesystem.Client) *file.Client {
fileClient := filesystemClient.NewFileClient(fileName)
_, err := fileClient.Create(ctx, nil)
_require.Nil(err)
return fileClient
}

func CreateNewDir(ctx context.Context, _require *require.Assertions, dirName string, filesystemClient *filesystem.Client) *directory.Client {
dirClient := filesystemClient.NewDirectoryClient(dirName)
_, err := dirClient.Create(ctx, nil)
_require.Nil(err)
return dirClient
}

func GetDirClient(fsName, dirName string, t *testing.T, accountType TestAccountType, options *directory.ClientOptions) (*directory.Client, error) {
if options == nil {
options = &directory.ClientOptions{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,36 @@ package lease

import (
"context"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/container"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/lease"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/filesystem"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/base"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/exported"
"github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake/internal/generated"
)

// FilesystemClient provides lease functionality for the underlying filesystem client.
type FilesystemClient struct {
leaseID *string
containerClient *lease.ContainerClient
leaseID *string
}

// FilesystemClientOptions contains the optional values when creating a FilesystemClient.
type FilesystemClientOptions struct {
// LeaseID contains a caller-provided lease ID.
LeaseID *string
}
type FilesystemClientOptions = lease.ContainerClientOptions

// NewFilesystemClient creates a filesystem lease client for the provided filesystem client.
// - client - an instance of a filesystem client
// - options - client options; pass nil to accept the default values
func NewFilesystemClient(client *filesystem.Client, options *FilesystemClientOptions) (*FilesystemClient, error) {
// TODO: set up container lease client
return nil, nil
_, _, containerClient := base.InnerClients((*base.CompositeClient[generated.FileSystemClient, generated.FileSystemClient, container.Client])(client))
containerLeaseClient, err := lease.NewContainerClient(containerClient, options)
if err != nil {
return nil, exported.ConvertToDFSError(err)
}
return &FilesystemClient{
containerClient: containerLeaseClient,
leaseID: containerLeaseClient.LeaseID(),
}, nil
}

// LeaseID returns leaseID of the client.
Expand All @@ -42,33 +50,42 @@ func (c *FilesystemClient) LeaseID() *string {
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
func (c *FilesystemClient) AcquireLease(ctx context.Context, duration int32, o *FilesystemAcquireOptions) (FilesystemAcquireResponse, error) {
opts := o.format()
return c.containerClient.AcquireLease(ctx, duration, opts)
resp, err := c.containerClient.AcquireLease(ctx, duration, opts)
return resp, exported.ConvertToDFSError(err)
}

// BreakLease breaks the filesystem's previously-acquired lease (if it exists). Pass the LeaseBreakDefault (-1)
// constant to break a fixed-Duration lease when it expires or an infinite lease immediately.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
func (c *FilesystemClient) BreakLease(ctx context.Context, o *FilesystemBreakOptions) (FilesystemBreakResponse, error) {
opts := o.format()
return c.containerClient.BreakLease(ctx, opts)
resp, err := c.containerClient.BreakLease(ctx, opts)
return resp, exported.ConvertToDFSError(err)
}

// ChangeLease changes the filesystem's lease ID.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
func (c *FilesystemClient) ChangeLease(ctx context.Context, proposedLeaseID string, o *FilesystemChangeOptions) (FilesystemChangeResponse, error) {
opts := o.format()
return c.containerClient.ChangeLease(ctx, proposedLeaseID, opts)
resp, err := c.containerClient.ChangeLease(ctx, proposedLeaseID, opts)
if err != nil {
return resp, exported.ConvertToDFSError(err)
}
c.leaseID = &proposedLeaseID
return resp, nil
}

// RenewLease renews the filesystem's previously-acquired lease.
// For more information, see https://docs.microsoft.com/rest/api/storageservices/lease-blob.
func (c *FilesystemClient) RenewLease(ctx context.Context, o *FilesystemRenewOptions) (FilesystemRenewResponse, error) {
opts := o.format()
return c.containerClient.RenewLease(ctx, opts)
resp, err := c.containerClient.RenewLease(ctx, opts)
return resp, exported.ConvertToDFSError(err)
}

// ReleaseLease releases the filesystem's previously-acquired lease.
func (c *FilesystemClient) ReleaseLease(ctx context.Context, o *FilesystemReleaseOptions) (FilesystemReleaseResponse, error) {
opts := o.format()
return c.containerClient.ReleaseLease(ctx, opts)
resp, err := c.containerClient.ReleaseLease(ctx, opts)
return resp, exported.ConvertToDFSError(err)
}
Loading

0 comments on commit 58726b9

Please sign in to comment.