Skip to content

Commit

Permalink
Merge branch 'main' into version-pipeline-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wonwuakpa-msft authored Nov 14, 2024
2 parents 14fa7c5 + a98ffc7 commit 972d2e6
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 199 deletions.
8 changes: 8 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
### Bug Fixes
1. Fixed an issue where AzCopy would not persist tokens when logging in via Device Code. ([#2361](https://github.com/Azure/azure-storage-azcopy/issues/2361))

## Version 10.27.1

### Bug Fixes
1. Reverted a change that resulted in breaking file service transfers and a larger memory footprint. ([#2858](https://github.com/Azure/azure-storage-azcopy/issues/2858)[#2855](https://github.com/Azure/azure-storage-azcopy/issues/2855))

### Dependency updates
1. github.com/golang-jwt/jwt/v4 v4.5.0 -> v4.5.1 ([#2861](https://github.com/Azure/azure-storage-azcopy/issues/2861))

## Version 10.27.0

### New Features
Expand Down
1 change: 1 addition & 0 deletions common/folderCreationTracker_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package common
type FolderCreationTracker interface {
CreateFolder(folder string, doCreation func() error) error
ShouldSetProperties(folder string, overwrite OverwriteOption, prompter Prompter) bool
StopTracking(folder string)
}

type Prompter interface {
Expand Down
54 changes: 0 additions & 54 deletions common/trieForDirPath.go

This file was deleted.

95 changes: 0 additions & 95 deletions common/trieForDirPath_test.go

This file was deleted.

70 changes: 47 additions & 23 deletions ste/folderCreationTracker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ste

import (
"fmt"
"net/url"
"strings"
"sync"
Expand All @@ -20,9 +21,10 @@ func NewFolderCreationTracker(fpo common.FolderPropertyOption, plan *JobPartPlan
case common.EFolderPropertiesOption.AllFolders(),
common.EFolderPropertiesOption.AllFoldersExceptRoot():
return &jpptFolderTracker{ // This prevents a dependency cycle. Reviewers: Are we OK with this? Can you think of a better way to do it?
plan: plan,
mu: &sync.Mutex{},
contents: common.NewTrie(),
plan: plan,
mu: &sync.Mutex{},
contents: make(map[string]uint32),
unregisteredButCreated: make(map[string]struct{}),
}
case common.EFolderPropertiesOption.NoFolders():
// can't use simpleFolderTracker here, because when no folders are processed,
Expand All @@ -46,10 +48,15 @@ func (f *nullFolderTracker) ShouldSetProperties(folder string, overwrite common.
panic("wrong type of folder tracker has been instantiated. This type does not do any tracking")
}

func (f *nullFolderTracker) StopTracking(folder string) {
// noop (because we don't track anything)
}

type jpptFolderTracker struct {
plan IJobPartPlanHeader
mu *sync.Mutex
contents *common.Trie
plan IJobPartPlanHeader
mu *sync.Mutex
contents map[string]uint32
unregisteredButCreated map[string]struct{}
}

func (f *jpptFolderTracker) RegisterPropertiesTransfer(folder string, transferIndex uint32) {
Expand All @@ -60,14 +67,13 @@ func (f *jpptFolderTracker) RegisterPropertiesTransfer(folder string, transferIn
return // Never persist to dev-null
}

fNode, _ := f.contents.InsertDirNode(folder)
fNode.TransferIndex = transferIndex
f.contents[folder] = transferIndex

// We created it before it was enumerated-- Let's register that now.
if fNode.UnregisteredButCreated {
if _, ok := f.unregisteredButCreated[folder]; ok {
f.plan.Transfer(transferIndex).SetTransferStatus(common.ETransferStatus.FolderCreated(), false)
fNode.UnregisteredButCreated = false

delete(f.unregisteredButCreated, folder)
}
}

Expand All @@ -79,15 +85,12 @@ func (f *jpptFolderTracker) CreateFolder(folder string, doCreation func() error)
return nil // Never persist to dev-null
}

// If the folder has already been created, then we don't need to create it again
fNode, addedToTrie := f.contents.InsertDirNode(folder)

if !addedToTrie && (f.plan.Transfer(fNode.TransferIndex).TransferStatus() == common.ETransferStatus.FolderCreated() ||
f.plan.Transfer(fNode.TransferIndex).TransferStatus() == common.ETransferStatus.Success()) {
if idx, ok := f.contents[folder]; ok &&
f.plan.Transfer(idx).TransferStatus() == (common.ETransferStatus.FolderCreated()) {
return nil
}

if fNode.UnregisteredButCreated {
if _, ok := f.unregisteredButCreated[folder]; ok {
return nil
}

Expand All @@ -96,14 +99,13 @@ func (f *jpptFolderTracker) CreateFolder(folder string, doCreation func() error)
return err
}

if !addedToTrie {
if idx, ok := f.contents[folder]; ok {
// overwrite it's transfer status
f.plan.Transfer(fNode.TransferIndex).SetTransferStatus(common.ETransferStatus.FolderCreated(), false)
f.plan.Transfer(idx).SetTransferStatus(common.ETransferStatus.FolderCreated(), false)
} else {
// A folder hasn't been hit in traversal yet.
// Recording it in memory is OK, because we *cannot* resume a job that hasn't finished traversal.
// We set the value to 0 as we just want to record it in memory
fNode.UnregisteredButCreated = true
f.unregisteredButCreated[folder] = struct{}{}
}

return nil
Expand All @@ -125,9 +127,8 @@ func (f *jpptFolderTracker) ShouldSetProperties(folder string, overwrite common.
defer f.mu.Unlock()

var created bool
if fNode, ok := f.contents.GetDirNode(folder); ok {
created = f.plan.Transfer(fNode.TransferIndex).TransferStatus() == common.ETransferStatus.FolderCreated() ||
f.plan.Transfer(fNode.TransferIndex).TransferStatus() == common.ETransferStatus.Success()
if idx, ok := f.contents[folder]; ok {
created = f.plan.Transfer(idx).TransferStatus() == common.ETransferStatus.FolderCreated()
} else {
// This should not happen, ever.
// Folder property jobs register with the tracker before they start getting processed.
Expand Down Expand Up @@ -157,3 +158,26 @@ func (f *jpptFolderTracker) ShouldSetProperties(folder string, overwrite common.
panic("unknown overwrite option")
}
}

func (f *jpptFolderTracker) StopTracking(folder string) {
f.mu.Lock()
defer f.mu.Unlock()

if folder == common.Dev_Null {
return // Not possible to track this
}

// no-op, because tracking is now handled by jppt, anyway.
if _, ok := f.contents[folder]; ok {
delete(f.contents, folder)
} else {
currentContents := ""

for k, v := range f.contents {
currentContents += fmt.Sprintf("K: %s V: %d\n", k, v)
}

// double should never be hit, but *just in case*.
panic(common.NewAzCopyLogSanitizer().SanitizeLogMessage("Folder " + folder + " shouldn't finish tracking until it's been recorded\nCurrent Contents:\n" + currentContents))
}
}
Loading

0 comments on commit 972d2e6

Please sign in to comment.