-
Notifications
You must be signed in to change notification settings - Fork 250
Migrated resume code #3289
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
base: main
Are you sure you want to change the base?
Migrated resume code #3289
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the jobs resume functionality in AzCopy to support library usage, moving resume-related code from the CLI layer into the azcopy package. The refactoring enables programmatic job resumption while maintaining CLI compatibility.
Key Changes
- Migrated resume job logic from
cmd/jobsResume.gotoazcopy/jobsResume.go, exposingResumeJob()as a public API - Introduced
JobLifecycleManagerto handle job lifecycle events with adaptive progress reporting - Moved credential utility functions to
azcopy/credentialUtil.gofor shared use between CLI and library modes
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| ste/mgr-JobPartMgr.go | Removed obsolete include/exclude transfer list check |
| ste/mgr-JobMgr.go | Removed include/exclude transfer methods and fields from job manager |
| jobsAdmin/init.go | Simplified ResumeJobOrder by removing SAS stripping and include/exclude logic |
| common/rpc-models.go | Removed obsolete SourceSAS, DestinationSAS, IncludeTransfer, and ExcludeTransfer fields from ResumeJobRequest |
| cmd/sync.go | Updated constant reference from base10Mega to azcopy.Base10Mega |
| cmd/root.go | Refactored Initialize function to handle library mode vs CLI mode initialization |
| cmd/jobsShow.go | Updated API calls to pass JobID as first parameter instead of in options |
| cmd/jobsResume.go | Completely refactored to use new azcopy.ResumeJob API with handler pattern |
| cmd/jobsRemove.go | Updated API call signature to pass JobID as first parameter |
| cmd/credentialUtil.go | Delegated credential logic to azcopy package functions |
| cmd/copyEnumeratorInit.go | Fixed trailing whitespace and variable reference |
| cmd/copy.go | Updated constant reference from base10Mega to azcopy.Base10Mega |
| cmd/constants.go | Removed constants migrated to azcopy package |
| cmd/cancel.go | Updated API call signature for GetJobSummary |
| azcopy/zt_credentialUtil_test.go | Moved and updated credential tests to azcopy package |
| azcopy/jobsShow.go | Updated API to take JobID as first parameter with cleaner option structs |
| azcopy/jobsResume.go | New file implementing ResumeJob API with handler pattern for progress tracking |
| azcopy/jobsRemove.go | Updated API signature to take JobID as first parameter |
| azcopy/jobLifecycleManager.go | New file implementing job lifecycle management with adaptive progress reporting |
| azcopy/credentialUtil.go | New file consolidating credential utility functions for library usage |
| azcopy/client.go | Added LogLevel support and moved constants from cmd package |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // TODO : rename interface method to OnError to match other method naming conventions | ||
| func (j *JobLifecycleManager) Error(err string) { |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The TODO comment on line 105 mentions renaming the interface method to OnError to match naming conventions, but this hasn't been addressed. This should either be implemented or the TODO should be tracked elsewhere to ensure consistency across the API.
| // TODO : rename interface method to OnError to match other method naming conventions | |
| func (j *JobLifecycleManager) Error(err string) { | |
| // Renamed to OnError to match other method naming conventions | |
| func (j *JobLifecycleManager) OnError(err string) { |
| } | ||
| return false, nil | ||
| } | ||
|
|
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation for the exported function GetCredentialTypeForLocation. Public API functions should have doc comments explaining their parameters, return values, and behavior.
| // GetCredentialTypeForLocation determines the appropriate credential type to use for a given storage location and resource. | |
| // | |
| // Parameters: | |
| // - ctx: The context for cancellation and deadlines. | |
| // - location: The storage location (e.g., Azure, local, etc.). | |
| // - resource: The resource string representing the target or source. | |
| // - isSource: True if the resource is a source; false if it is a destination. | |
| // - cpkOptions: Options for customer-provided keys. | |
| // - uotm: User OAuth token manager for managing OAuth tokens. | |
| // | |
| // Returns: | |
| // - credType: The determined credential type for accessing the resource. | |
| // - isPublic: True if the resource is publicly accessible; false otherwise. | |
| // - err: Any error encountered during determination. |
| type ResumeJobHandler interface { | ||
| OnStart(ctx JobContext) | ||
| OnTransferProgress(progress ResumeJobProgress) | ||
| } |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation for the exported ResumeJobHandler interface. Public API interfaces should have doc comments describing their contract and when they will be called.
| type JobProgressTracker interface { | ||
| // Start - calls OnStart | ||
| Start() | ||
| // CheckProgress checks the progress of the job and returns the number of transfers completed so far and whether the job is done | ||
| CheckProgress() (uint32, bool) | ||
| // CompletedEnumeration checks whether the enumeration is complete | ||
| CompletedEnumeration() bool // Whether we should prompt before cancelling | ||
| // GetJobID returns the JobID of the job being tracked | ||
| GetJobID() common.JobID | ||
| // GetElapsedTime returns the elapsed time since the job started | ||
| GetElapsedTime() time.Duration | ||
| } |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation for the exported JobProgressTracker interface. Public API interfaces should have doc comments explaining the contract and typical usage patterns.
|
|
||
| func warnIfSharedKeyAuthForDatalake() { | ||
| sharedKeyDeprecation.Do(func() { | ||
| common.GetLifecycleMgr().Warn(sharedKeyDeprecationMessage) |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reference to common.GetLifecycleMgr() may return nil in library mode, but the code immediately calls .Warn() on line 52. While there's a nil check in the function body at line 128, the warnIfSharedKeyAuthForDatalake function doesn't guard against this nil case and could panic.
| common.GetLifecycleMgr().Warn(sharedKeyDeprecationMessage) | |
| lcm := common.GetLifecycleMgr() | |
| if lcm != nil { | |
| lcm.Warn(sharedKeyDeprecationMessage) | |
| } |
| common.GetLifecycleMgr().Info(message) | ||
| } |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to common.GetLifecycleMgr().Info(message) on line 220 may panic if GetLifecycleMgr() returns nil, which can happen in library mode. A nil check is needed before calling the method.
| common.GetLifecycleMgr().Info(message) | |
| } | |
| if mgr := common.GetLifecycleMgr(); mgr != nil { | |
| mgr.Info(message) | |
| } |
| return | ||
| } | ||
|
|
||
| if err = checkAuthSafeForTarget(credType, resource.Value, TrustedSuffixes, location); err != nil { |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the check for TrustedSuffixes on line 330, the code references a global variable TrustedSuffixes that may not be set in the azcopy package context. The checkAuthSafeForTarget function receives extraSuffixesAAD as a parameter but on line 330 it references the global TrustedSuffixes variable. This should use a local reference or be passed as a parameter to ensure it has the correct value.
| if err = checkAuthSafeForTarget(credType, resource.Value, TrustedSuffixes, location); err != nil { | |
| if err = checkAuthSafeForTarget(credType, resource.Value, TrustedSuffixesAAD, location); err != nil { |
| type ResumeJobProgress struct { | ||
| common.ListJobSummaryResponse | ||
| Throughput float64 | ||
| ElapsedTime time.Duration | ||
| } |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation for the exported ResumeJobProgress struct. Public API types should have doc comments explaining their purpose, especially since this is part of the library API migration.
| type ResumeJobResult struct { | ||
| common.ListJobSummaryResponse | ||
| ElapsedTime time.Duration | ||
| } |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing documentation for the exported ResumeJobResult struct. Public API types should have doc comments explaining what they represent.
Description
Refactor of jobs resume code for AzCopy as a library.
Feature / Bug Fix: (Brief description of the feature or issue being addressed)
Related Links:
Issues
Team thread
Documents
[Email Subject]
Type of Change
How Has This Been Tested?
Existing integration tests as this is a refactor.
Thank you for your contribution to AzCopy!