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

Pulling from dev to set-props #1821

Merged
merged 2 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions cmd/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ type rawBenchmarkCmdArgs struct {
numOfFolders uint

// options from flags
blockSizeMB float64
putMd5 bool
checkLength bool
blobType string
output string
logVerbosity string
mode string
blockSizeMB float64
putMd5 bool
checkLength bool
blobType string
output string
mode string
}

const (
Expand Down Expand Up @@ -153,7 +152,6 @@ func (raw rawBenchmarkCmdArgs) cook() (CookedCopyCmdArgs, error) {
c.CheckLength = raw.checkLength
c.blobType = raw.blobType
c.output = raw.output
c.logVerbosity = raw.logVerbosity

cooked, err := c.cook()
if err != nil {
Expand All @@ -168,7 +166,7 @@ func (raw rawBenchmarkCmdArgs) cook() (CookedCopyCmdArgs, error) {

if !downloadMode && raw.deleteTestData {
// set up automatic cleanup
cooked.followupJobArgs, err = raw.createCleanupJobArgs(cooked.Destination, raw.logVerbosity)
cooked.followupJobArgs, err = raw.createCleanupJobArgs(cooked.Destination, logVerbosityRaw)
if err != nil {
return dummyCooked, err
}
Expand Down Expand Up @@ -225,7 +223,6 @@ func (raw rawBenchmarkCmdArgs) createCleanupJobArgs(benchmarkDest common.Resourc
u, _ := benchmarkDest.FullURL() // don't check error, because it was parsed already in main job
rc.src = u.String() // the SOURCE for the deletion is the the dest from the benchmark
rc.recursive = true
rc.logVerbosity = logVerbosity

switch InferArgumentLocation(rc.src) {
case common.ELocation.Blob():
Expand Down Expand Up @@ -345,8 +342,4 @@ func init() {
benchCmd.PersistentFlags().BoolVar(&raw.putMd5, "put-md5", false, "create an MD5 hash of each file, and save the hash as the Content-MD5 property of the destination blob/file. (By default the hash is NOT created.) Identical to the same-named parameter in the copy command")
benchCmd.PersistentFlags().BoolVar(&raw.checkLength, "check-length", true, "Check the length of a file on the destination after the transfer. If there is a mismatch between source and destination, the transfer is marked as failed.")
benchCmd.PersistentFlags().StringVar(&raw.mode, "mode", "upload", "Defines if Azcopy should test uploads or downloads from this target. Valid values are 'upload' and 'download'. Defaulted option is 'upload'.")

// TODO use constant for default value or, better, move loglevel param to root cmd?
benchCmd.PersistentFlags().StringVar(&raw.logVerbosity, "log-level", "INFO", "define the log verbosity for the log file, available levels: INFO(all requests/responses), WARNING(slow responses), ERROR(only failed requests), and NONE(no output logs).")

}
12 changes: 2 additions & 10 deletions cmd/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ type rawCopyCmdArgs struct {
blockBlobTier string
pageBlobTier string
output string // TODO: Is this unused now? replaced with param at root level?
logVerbosity string
// list of blobTypes to exclude while enumerating the transfer
excludeBlobType string
// Opt-in flag to persist SMB ACLs to Azure Files.
Expand Down Expand Up @@ -257,13 +256,8 @@ func (raw rawCopyCmdArgs) cook() (CookedCopyCmdArgs, error) {
jobID: azcopyCurrentJobID,
}

err := cooked.LogVerbosity.Parse(raw.logVerbosity)
if err != nil {
return cooked, err
}

// set up the front end scanning logger
azcopyScanningLogger = common.NewJobLogger(azcopyCurrentJobID, cooked.LogVerbosity, azcopyLogPathFolder, "-scanning")
azcopyScanningLogger = common.NewJobLogger(azcopyCurrentJobID, azcopyLogVerbosity, azcopyLogPathFolder, "-scanning")
azcopyScanningLogger.OpenLog()
glcm.RegisterCloseFunc(func() {
azcopyScanningLogger.CloseLog()
Expand Down Expand Up @@ -1102,7 +1096,6 @@ type CookedCopyCmdArgs struct {
putMd5 bool
md5ValidationOption common.HashValidationOption
CheckLength bool
LogVerbosity common.LogLevel
// commandString hold the user given command which is logged to the Job log file
commandString string

Expand Down Expand Up @@ -1384,7 +1377,7 @@ func (cca *CookedCopyCmdArgs) processCopyJobPartOrders() (err error) {
ForceIfReadOnly: cca.ForceIfReadOnly,
AutoDecompress: cca.autoDecompress,
Priority: common.EJobPriority.Normal(),
LogLevel: cca.LogVerbosity,
LogLevel: azcopyLogVerbosity,
ExcludeBlobType: cca.excludeBlobType,
BlobAttributes: common.BlobTransferAttributes{
BlobType: cca.blobType,
Expand Down Expand Up @@ -1880,7 +1873,6 @@ func init() {
"or the account. Use of this flag is not applicable for copying data from non azure-service to service. More than one blob should be separated by ';'. ")
// options change how the transfers are performed
cpCmd.PersistentFlags().Float64Var(&raw.blockSizeMB, "block-size-mb", 0, "Use this block size (specified in MiB) when uploading to Azure Storage, and downloading from Azure Storage. The default value is automatically calculated based on file size. Decimal fractions are allowed (For example: 0.25).")
cpCmd.PersistentFlags().StringVar(&raw.logVerbosity, "log-level", "INFO", "Define the log verbosity for the log file, available levels: INFO(all requests/responses), WARNING(slow responses), ERROR(only failed requests), and NONE(no output logs). (default 'INFO').")
cpCmd.PersistentFlags().StringVar(&raw.blobType, "blob-type", "Detect", "Defines the type of blob at the destination. This is used for uploading blobs and when copying between accounts (default 'Detect'). Valid values include 'Detect', 'BlockBlob', 'PageBlob', and 'AppendBlob'. "+
"When copying between accounts, a value of 'Detect' causes AzCopy to use the type of source blob to determine the type of the destination blob. When uploading a file, 'Detect' determines if the file is a VHD or a VHDX file based on the file extension. If the file is either a VHD or VHDX file, AzCopy treats the file as a page blob.")
cpCmd.PersistentFlags().StringVar(&raw.blockBlobTier, "block-blob-tier", "None", "upload block blob to Azure Storage using this blob tier.")
Expand Down
11 changes: 7 additions & 4 deletions cmd/copyEnumeratorInit.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ func (cca *CookedCopyCmdArgs) initEnumerator(jobPartOrder common.CopyJobPartOrde
jobPartOrder.S2SInvalidMetadataHandleOption = cca.s2sInvalidMetadataHandleOption
jobPartOrder.S2SPreserveBlobTags = cca.S2sPreserveBlobTags

traverser, err = InitResourceTraverser(cca.Source, cca.FromTo.From(), &ctx, &srcCredInfo, &cca.FollowSymlinks, cca.ListOfFilesChannel, cca.Recursive, getRemoteProperties, cca.IncludeDirectoryStubs, cca.permanentDeleteOption, func(common.EntityType) {}, cca.ListOfVersionIDs, cca.S2sPreserveBlobTags, cca.LogVerbosity.ToPipelineLogLevel(), cca.CpkOptions)
traverser, err = InitResourceTraverser(cca.Source, cca.FromTo.From(), &ctx, &srcCredInfo,
&cca.FollowSymlinks, cca.ListOfFilesChannel, cca.Recursive, getRemoteProperties,
cca.IncludeDirectoryStubs, cca.permanentDeleteOption, func(common.EntityType) {}, cca.ListOfVersionIDs,
cca.S2sPreserveBlobTags, azcopyLogVerbosity.ToPipelineLogLevel(), cca.CpkOptions)

if err != nil {
return nil, err
Expand Down Expand Up @@ -159,7 +162,7 @@ func (cca *CookedCopyCmdArgs) initEnumerator(jobPartOrder common.CopyJobPartOrde
// only create the destination container in S2S scenarios
if cca.FromTo.From().IsRemote() && dstContainerName != "" { // if the destination has a explicit container name
// Attempt to create the container. If we fail, fail silently.
err = cca.createDstContainer(dstContainerName, cca.Destination, ctx, existingContainers, cca.LogVerbosity)
err = cca.createDstContainer(dstContainerName, cca.Destination, ctx, existingContainers, azcopyLogVerbosity)

// check against seenFailedContainers so we don't spam the job log with initialization failed errors
if _, ok := seenFailedContainers[dstContainerName]; err != nil && jobsAdmin.JobsAdmin != nil && !ok {
Expand Down Expand Up @@ -193,7 +196,7 @@ func (cca *CookedCopyCmdArgs) initEnumerator(jobPartOrder common.CopyJobPartOrde
continue
}

err = cca.createDstContainer(bucketName, cca.Destination, ctx, existingContainers, cca.LogVerbosity)
err = cca.createDstContainer(bucketName, cca.Destination, ctx, existingContainers, azcopyLogVerbosity)

// if JobsAdmin is nil, we're probably in testing mode.
// As a result, container creation failures are expected as we don't give the SAS tokens adequate permissions.
Expand All @@ -216,7 +219,7 @@ func (cca *CookedCopyCmdArgs) initEnumerator(jobPartOrder common.CopyJobPartOrde
resName, err := containerResolver.ResolveName(cName)

if err == nil {
err = cca.createDstContainer(resName, cca.Destination, ctx, existingContainers, cca.LogVerbosity)
err = cca.createDstContainer(resName, cca.Destination, ctx, existingContainers, azcopyLogVerbosity)

if _, ok := seenFailedContainers[dstContainerName]; err != nil && jobsAdmin.JobsAdmin != nil && !ok {
logDstContainerCreateFailureOnce.Do(func() {
Expand Down
6 changes: 3 additions & 3 deletions cmd/credentialUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ const oauthLoginSessionCacheAccountName = "AzCopyOAuthTokenCache"
// Note: Currently, only support to have TokenManager for one user mapping to one tenantID.
func GetUserOAuthTokenManagerInstance() *common.UserOAuthTokenManager {
once.Do(func() {
if AzcopyAppPathFolder == "" {
panic("invalid state, azcopyAppPathFolder should be initialized by root")
if common.AzcopyJobPlanFolder == "" {
panic("invalid state, AzcopyJobPlanFolder should not be an empty string")
}
currentUserOAuthTokenManager = common.NewUserOAuthTokenManagerInstance(common.CredCacheOptions{
DPAPIFilePath: AzcopyAppPathFolder,
DPAPIFilePath: common.AzcopyJobPlanFolder,
KeyName: oauthLoginSessionCacheKeyName,
ServiceName: oauthLoginSessionCacheServiceName,
AccountName: oauthLoginSessionCacheAccountName,
Expand Down
1 change: 0 additions & 1 deletion cmd/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func init() {
rootCmd.AddCommand(deleteCmd)

deleteCmd.PersistentFlags().BoolVar(&raw.recursive, "recursive", false, "Look into sub-directories recursively when syncing between directories.")
deleteCmd.PersistentFlags().StringVar(&raw.logVerbosity, "log-level", "INFO", "Define the log verbosity for the log file. Available levels include: INFO(all requests/responses), WARNING(slow responses), ERROR(only failed requests), and NONE(no output logs). (default 'INFO')")
deleteCmd.PersistentFlags().StringVar(&raw.include, "include-pattern", "", "Include only files where the name matches the pattern list. For example: *.jpg;*.pdf;exactName")
deleteCmd.PersistentFlags().StringVar(&raw.includePath, "include-path", "", "Include only these paths when removing. "+
"This option does not support wildcard characters (*). Checks relative path prefix. For example: myFolder;myFolder/subDirName/file.pdf")
Expand Down
7 changes: 5 additions & 2 deletions cmd/removeEnumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ func newRemoveEnumerator(cca *CookedCopyCmdArgs) (enumerator *CopyEnumerator, er
ctx := context.WithValue(context.TODO(), ste.ServiceAPIVersionOverride, ste.DefaultServiceApiVersion)

// Include-path is handled by ListOfFilesChannel.
sourceTraverser, err = InitResourceTraverser(cca.Source, cca.FromTo.From(), &ctx, &cca.credentialInfo, nil, cca.ListOfFilesChannel, cca.Recursive, false, cca.IncludeDirectoryStubs, cca.permanentDeleteOption, func(common.EntityType) {}, cca.ListOfVersionIDs, false, cca.LogVerbosity.ToPipelineLogLevel(), cca.CpkOptions)
sourceTraverser, err = InitResourceTraverser(cca.Source, cca.FromTo.From(), &ctx, &cca.credentialInfo,
nil, cca.ListOfFilesChannel, cca.Recursive, false, cca.IncludeDirectoryStubs,
cca.permanentDeleteOption, func(common.EntityType) {}, cca.ListOfVersionIDs, false,
azcopyLogVerbosity.ToPipelineLogLevel(), cca.CpkOptions)

// report failure to create traverser
if err != nil {
Expand Down Expand Up @@ -132,7 +135,7 @@ func removeBfsResources(cca *CookedCopyCmdArgs) (err error) {
}

// create bfs pipeline
p, err := createBlobFSPipeline(ctx, cca.credentialInfo, cca.LogVerbosity.ToPipelineLogLevel())
p, err := createBlobFSPipeline(ctx, cca.credentialInfo, azcopyLogVerbosity.ToPipelineLogLevel())
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/removeProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newRemoveTransferProcessor(cca *CookedCopyCmdArgs, numOfTransfersPerPart in
ForceIfReadOnly: cca.ForceIfReadOnly,

// flags
LogLevel: cca.LogVerbosity,
LogLevel: azcopyLogVerbosity,
BlobAttributes: common.BlobTransferAttributes{DeleteSnapshotsOption: cca.deleteSnapshotsOption, PermanentDeleteOption: cca.permanentDeleteOption},
}

Expand Down
23 changes: 19 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,23 @@ var azcopyLogPathFolder string
var azcopyMaxFileAndSocketHandles int
var outputFormatRaw string
var outputVerbosityRaw string
var logVerbosityRaw string
var cancelFromStdin bool
var azcopyOutputFormat common.OutputFormat
var azcopyOutputVerbosity common.OutputVerbosity
var azcopyLogVerbosity common.LogLevel
var loggerInfo jobLoggerInfo
var cmdLineCapMegaBitsPerSecond float64
var azcopyAwaitContinue bool
var azcopyAwaitAllowOpenFiles bool
var azcopyScanningLogger common.ILoggerResetable
var azcopyCurrentJobID common.JobID

type jobLoggerInfo struct {
jobID common.JobID
logFileFolder string
}

// It's not pretty that this one is read directly by credential util.
// But doing otherwise required us passing it around in many places, even though really
// it can be thought of as an "ambient" property. That's the (weak?) justification for implementing
Expand Down Expand Up @@ -95,6 +103,13 @@ var rootCmd = &cobra.Command{
return err
}

err = azcopyLogVerbosity.Parse(logVerbosityRaw)
if err != nil {
return err
}
common.AzcopyCurrentJobLogger = common.NewJobLogger(loggerInfo.jobID, azcopyLogVerbosity, loggerInfo.logFileFolder, "")
common.AzcopyCurrentJobLogger.OpenLog()

glcm.SetForceLogging()

// warn Windows users re quoting (since our docs all use single quotes, but CMD needs double)
Expand Down Expand Up @@ -163,14 +178,13 @@ var glcmSwapOnce = &sync.Once{}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute(azsAppPathFolder, logPathFolder string, jobPlanFolder string, maxFileAndSocketHandles int, jobID common.JobID) {
AzcopyAppPathFolder = azsAppPathFolder

func Execute(logPathFolder, jobPlanFolder string, maxFileAndSocketHandles int, jobID common.JobID) {
azcopyLogPathFolder = logPathFolder
common.AzcopyJobPlanFolder = jobPlanFolder
azcopyMaxFileAndSocketHandles = maxFileAndSocketHandles
azcopyCurrentJobID = jobID
common.AzcopyCurrentJobLogger = common.NewJobLogger(jobID, common.ELogLevel.Debug(), logPathFolder, "")
common.AzcopyCurrentJobLogger.OpenLog()
loggerInfo = jobLoggerInfo{jobID, logPathFolder}

if err := rootCmd.Execute(); err != nil {
glcm.Error(err.Error())
Expand All @@ -194,6 +208,7 @@ func init() {
rootCmd.PersistentFlags().Float64Var(&cmdLineCapMegaBitsPerSecond, "cap-mbps", 0, "Caps the transfer rate, in megabits per second. Moment-by-moment throughput might vary slightly from the cap. If this option is set to zero, or it is omitted, the throughput isn't capped.")
rootCmd.PersistentFlags().StringVar(&outputFormatRaw, "output-type", "text", "Format of the command's output. The choices include: text, json. The default value is 'text'.")
rootCmd.PersistentFlags().StringVar(&outputVerbosityRaw, "output-level", "default", "Define the output verbosity. Available levels: essential, quiet.")
rootCmd.PersistentFlags().StringVar(&logVerbosityRaw, "log-level", "INFO", "Define the log verbosity for the log file, available levels: INFO(all requests/responses), WARNING(slow responses), ERROR(only failed requests), and NONE(no output logs). (default 'INFO').")

rootCmd.PersistentFlags().StringVar(&cmdLineExtraSuffixesAAD, trustedSuffixesNameAAD, "", "Specifies additional domain suffixes where Azure Active Directory login tokens may be sent. The default is '"+
trustedSuffixesAAD+"'. Any listed here are added to the default. For security, you should only put Microsoft Azure domains here. Separate multiple entries with semi-colons.")
Expand Down
11 changes: 2 additions & 9 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type rawSyncCmdArgs struct {

// options from flags
blockSizeMB float64
logVerbosity string
include string
exclude string
excludePath string
Expand Down Expand Up @@ -123,13 +122,8 @@ func (raw *rawSyncCmdArgs) validateURLIsNotServiceLevel(url string, location com
func (raw *rawSyncCmdArgs) cook() (cookedSyncCmdArgs, error) {
cooked := cookedSyncCmdArgs{}

err := cooked.logVerbosity.Parse(raw.logVerbosity)
if err != nil {
return cooked, err
}

// set up the front end scanning logger
azcopyScanningLogger = common.NewJobLogger(azcopyCurrentJobID, cooked.logVerbosity, azcopyLogPathFolder, "-scanning")
azcopyScanningLogger = common.NewJobLogger(azcopyCurrentJobID, azcopyLogVerbosity, azcopyLogPathFolder, "-scanning")
azcopyScanningLogger.OpenLog()
glcm.RegisterCloseFunc(func() {
azcopyScanningLogger.CloseLog()
Expand All @@ -155,6 +149,7 @@ func (raw *rawSyncCmdArgs) cook() (cookedSyncCmdArgs, error) {

cooked.isHNSToHNS = srcHNS && dstHNS

var err error
cooked.fromTo, err = ValidateFromTo(raw.src, raw.dst, raw.fromTo)
if err != nil {
return cooked, err
Expand Down Expand Up @@ -392,7 +387,6 @@ type cookedSyncCmdArgs struct {
putMd5 bool
md5ValidationOption common.HashValidationOption
blockSize int64
logVerbosity common.LogLevel
forceIfReadOnly bool
backupMode bool

Expand Down Expand Up @@ -774,7 +768,6 @@ func init() {
syncCmd.PersistentFlags().StringVar(&raw.excludeFileAttributes, "exclude-attributes", "", "(Windows only) Exclude files whose attributes match the attribute list. For example: A;S;R")
syncCmd.PersistentFlags().StringVar(&raw.includeRegex, "include-regex", "", "Include the relative path of the files that match with the regular expressions. Separate regular expressions with ';'.")
syncCmd.PersistentFlags().StringVar(&raw.excludeRegex, "exclude-regex", "", "Exclude the relative path of the files that match with the regular expressions. Separate regular expressions with ';'.")
syncCmd.PersistentFlags().StringVar(&raw.logVerbosity, "log-level", "INFO", "Define the log verbosity for the log file, available levels: INFO(all requests and responses), WARNING(slow responses), ERROR(only failed requests), and NONE(no output logs). (default INFO).")
syncCmd.PersistentFlags().StringVar(&raw.deleteDestination, "delete-destination", "false", "Defines whether to delete extra files from the destination that are not present at the source. Could be set to true, false, or prompt. "+
"If set to prompt, the user will be asked a question before scheduling files and blobs for deletion. (default 'false').")
syncCmd.PersistentFlags().BoolVar(&raw.putMd5, "put-md5", false, "Create an MD5 hash of each file, and save the hash as the Content-MD5 property of the destination blob or file. (By default the hash is NOT created.) Only available when uploading.")
Expand Down
Loading