Skip to content

Commit 507aba1

Browse files
committed
- based url/endpoint suffix is exposed as an option.
- download transfer improvements - doc and help update - fix error message when account or key env variables are missing
1 parent 3270568 commit 507aba1

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

args.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ type arguments struct {
6161
storageAccountKey string
6262
storageClientHTTPTimeout int
6363
baseBlobURL string
64-
targetBaseBlobURL string
6564
sourceParameters map[string]string
6665
sourceAuthorization string
6766
quietMode bool
@@ -206,11 +205,13 @@ func (p *paramParserValidator) getTargetRules() ([]parseAndValidationRule, error
206205
p.pvKeepDirStructueIsFalseWarning}, nil
207206
case transfer.PageBlob:
208207
return []parseAndValidationRule{
208+
p.pvTargetBaseURL,
209209
p.pvTargetContainerIsReq,
210210
p.pvBlockSizeCheckForPageBlobs,
211211
p.pvTargetBlobAuthInfoIsReq}, nil
212212
case transfer.BlockBlob:
213213
return []parseAndValidationRule{
214+
p.pvTargetBaseURL,
214215
p.pvTargetContainerIsReq,
215216
p.pvBlockSizeCheckForBlockBlobs,
216217
p.pvTargetBlobAuthInfoIsReq}, nil
@@ -239,6 +240,7 @@ func (p *paramParserValidator) getSourceRules() ([]parseAndValidationRule, error
239240
p.pvSourceInfoForS3IsReq}, nil
240241
case transfer.Blob:
241242
return []parseAndValidationRule{
243+
p.pvSourceBaseURL,
242244
p.pvSourceInfoForBlobIsReq,
243245
p.pvSetEmptyPrefixIfNone}, nil
244246
case transfer.Perf:
@@ -266,7 +268,7 @@ func (p *paramParserValidator) pvgUseExactMatch() error {
266268
func (p *paramParserValidator) pvgTransferStatusPathIsPresent() error {
267269

268270
if p.args.transferStatusPath != "" {
269-
if !p.args.quietMode{
271+
if !p.args.quietMode {
270272
fmt.Printf("Transfer is resumable. Transfer status file:%v \n", p.args.transferStatusPath)
271273
}
272274
tracker, err := internal.NewTransferTracker(p.args.transferStatusPath)
@@ -345,6 +347,16 @@ func (p *paramParserValidator) pvgTransferType() error {
345347
}
346348

347349
//Transfer segment specific rules...
350+
func (p *paramParserValidator) pvSourceBaseURL() error {
351+
p.params.blobSource.baseBlobURL = p.args.baseBlobURL
352+
353+
return nil
354+
}
355+
func (p *paramParserValidator) pvTargetBaseURL() error {
356+
p.params.blobTarget.baseBlobURL = p.args.baseBlobURL
357+
358+
return nil
359+
}
348360
func (p *paramParserValidator) pvSetTargetAliases() error {
349361
p.params.targetAliases = p.args.blobNames
350362

@@ -447,7 +459,7 @@ func (p *paramParserValidator) pvSetEmptyPrefixIfNone() error {
447459
// storage account that is the target in all other cases. And the second with the URI provided, as when blob to blob transfers occur.
448460
func (p *paramParserValidator) pvSourceInfoForBlobIsReq() error {
449461

450-
//if the scenarios is download then check if download is via short-mode
462+
//if the scenario is download check for short-mode download
451463
if p.params.transferType == transfer.BlobToFile {
452464
p.params.blobSource.accountName = p.args.storageAccountName
453465
if p.params.blobSource.accountName == "" {
@@ -477,7 +489,7 @@ func (p *paramParserValidator) pvSourceInfoForBlobIsReq() error {
477489
err := p.pvSourceURIISReq()
478490

479491
if err != nil {
480-
return err
492+
return fmt.Errorf("%s \n Or the account name or key were not set", err)
481493
}
482494

483495
var burl *url.URL
@@ -492,7 +504,7 @@ func (p *paramParserValidator) pvSourceInfoForBlobIsReq() error {
492504
p.params.blobSource.accountName = host[0]
493505

494506
if p.params.blobSource.accountName == "" {
495-
return fmt.Errorf("Invalid source Azure Blob URL. Account name could be parsed from the domain")
507+
return fmt.Errorf("Invalid source Azure Blob URL. Account name could not be parsed from the domain")
496508
}
497509

498510
segments := strings.Split(burl.Path, "/")
@@ -540,7 +552,7 @@ func (p *paramParserValidator) pvSourceInfoForS3IsReq() error {
540552
segments := strings.Split(burl.Path, "/")
541553

542554
if len(segments) < 2 {
543-
return fmt.Errorf("Invalid S3 endpoint URL. Bucket not specified. The format is s3://[END_POINT]/[BUCKET]/[PREFIX]")
555+
return fmt.Errorf("Invalid S3 endpoint URL. Bucket not specified. The format is s3://[END_POINT]/[BUCKET]/[PREFIX]")
544556
}
545557

546558
p.params.s3Source.bucket = segments[1]

blobporter.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ func init() {
4545
numberOfHandlersPerFileMsg = "Number of open handles for concurrent reads and writes per file."
4646
numberOfFilesInBatchMsg = "Maximum number of files in a transfer.\n\tIf the number is exceeded new transfers are created"
4747
readTokenExpMsg = "Expiration in minutes of the read-only access token that will be generated to read from S3 or Azure Blob sources."
48-
transferStatusFileMsg = "Transfer status file location. If set, blobporter will use this file to track the status of the transfer.\n\tIn case of failure and if the option is set the same status file, source files that were transferred will be skipped.\n\tIf the transfer is successful a summary will be appended."
48+
transferStatusFileMsg = "Transfer status file location. If set, blobporter will use this file to track the status of the transfer.\n\tIn case of failure the transfer will skip files already transferred.\n\tIf the transfer is successful a summary will be appended."
49+
baseURLMsg = "Endpoint suffix to be used for blob sources or targets. Default is blob.core.windows.net"
4950
)
5051

5152
flag.Usage = func() {
@@ -69,6 +70,7 @@ func init() {
6970
util.PrintUsageDefaults("x", "files_per_transfer", strconv.Itoa(argsUtil.args.numberOfFilesInBatch), numberOfFilesInBatchMsg)
7071
util.PrintUsageDefaults("o", "read_token_exp", strconv.Itoa(defaultReadTokenExp), readTokenExpMsg)
7172
util.PrintUsageDefaults("l", "transfer_status", "", transferStatusFileMsg)
73+
util.PrintUsageDefaults("u", "endpoint_suffix", "", baseURLMsg) //when empty the azutil will use the default base url, hence not setting it here.
7274
}
7375

7476
util.StringListVarAlias(&argsUtil.args.sourceURIs, "f", "source_file", "", fileMsg)
@@ -91,6 +93,7 @@ func init() {
9193
util.IntVarAlias(&argsUtil.args.numberOfFilesInBatch, "x", "files_per_transfer", defaultNumberOfFilesInBatch, numberOfFilesInBatchMsg)
9294
util.IntVarAlias(&argsUtil.args.readTokenExp, "o", "read_token_exp", defaultReadTokenExp, readTokenExpMsg)
9395
util.StringVarAlias(&argsUtil.args.transferStatusPath, "l", "transfer_status", "", transferStatusFileMsg)
96+
util.StringVarAlias(&argsUtil.args.baseBlobURL, "u", "endpoint_suffix", "", baseURLMsg)
9497
}
9598

9699
var dataTransferred uint64

docs/gettingstarted.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ Command Options
8989
-l, --transfer_status (string) Transfer status file location.
9090
If set, blobporter will use this file to track the status of the transfer.
9191

92-
In case of failure and the same file is referrenced, the source files that were transferred will be skipped.
92+
By referencing the same status file after a failure, the transfer will skip files already transferred.
9393

9494
If the transfer is successful a summary will be appended.
95+
96+
-u, --endpoint_suffix Endpoint suffix to be used for blob sources or targets.
97+
98+
Default is blob.core.windows.net

internal/const.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
)
77

88
//ProgramVersion blobporter version
9-
const ProgramVersion = "0.6.14"
9+
const ProgramVersion = "0.6.15"
1010

1111
//HTTPClientTimeout HTTP client timeout when reading from HTTP sources and try timeout for blob storage operations.
1212
var HTTPClientTimeout = 90

sources/http.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ func (f *HTTPSource) ExecuteReader(partitionsQ chan pipeline.PartsPartition, par
170170
req.Header.Set("Range", header)
171171
req.Header.Set("User-Agent", internal.UserAgentStr)
172172

173-
//set the close header only when the block is larger than the blob
174-
//to minimize the number of open when transferring small files.
175-
if p.BytesToRead < p.BlockSize {
176-
req.Close = true
177-
}
178-
179173
if res, err = f.HTTPClient.Do(req); err != nil || res.StatusCode != 206 {
180174
var status int
181175
if res != nil {

0 commit comments

Comments
 (0)