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

Transfer - Additional logs #974

Merged
merged 3 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func handleDelayedArtifactsFiles(filesToConsume []string, base phaseBase, delayU
}

func consumeDelayedArtifactsFiles(pcWrapper *producerConsumerWrapper, filesToConsume []string, uploadChunkChan chan UploadedChunk, base phaseBase, delayHelper delayUploadHelper, errorsChannelMng *ErrorsChannelMng) error {
log.Debug(fmt.Sprintf("Starting to handle delayed artifacts files. Found %d files.", len(filesToConsume)))
for _, filePath := range filesToConsume {
log.Debug("Handling delayed artifacts file: '" + filePath + "'")
delayedArtifactsFile, err := readDelayFile(filePath)
Expand Down
13 changes: 11 additions & 2 deletions artifactory/commands/transferfiles/errorshandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/jfrog/jfrog-client-go/utils/io/fileutils"
"github.com/jfrog/jfrog-client-go/utils/log"
"os"
"path"
"time"
)

Expand Down Expand Up @@ -189,7 +190,7 @@ func (mng *TransferErrorsMng) writeErrorContent(e ExtendedFileUploadStatusRespon
}

func (mng *TransferErrorsMng) writeSkippedErrorContent(e ExtendedFileUploadStatusResponse) error {
log.Debug(fmt.Sprintf("Writing '%s' to file %s", e.Reason, mng.errorWriterMng.skipped.filePath))
logWritingArtifact(e, mng.errorWriterMng.skipped.filePath)
mng.errorWriterMng.skipped.writer.Write(e)
mng.errorWriterMng.skipped.errorCount++
// If file contains maximum number of errors - create and write to a new errors file
Expand All @@ -213,7 +214,7 @@ func (mng *TransferErrorsMng) writeSkippedErrorContent(e ExtendedFileUploadStatu
}

func (mng *TransferErrorsMng) writeRetryableErrorContent(e ExtendedFileUploadStatusResponse) error {
log.Debug(fmt.Sprintf("Writing '%s' to file %s", e.Reason, mng.errorWriterMng.retryable.filePath))
logWritingArtifact(e, mng.errorWriterMng.retryable.filePath)
mng.errorWriterMng.retryable.writer.Write(e)
mng.errorWriterMng.retryable.errorCount++
// If file contains maximum number of errors - create and write to a new errors file
Expand All @@ -236,6 +237,14 @@ func (mng *TransferErrorsMng) writeRetryableErrorContent(e ExtendedFileUploadSta
return nil
}

func logWritingArtifact(e ExtendedFileUploadStatusResponse, errorsFilePath string) {
msg := fmt.Sprintf("Writing artifact '%s' to errors file '%s'.", path.Join(e.Repo, e.Path, e.Name), errorsFilePath)
if e.Reason != "" {
RobiNino marked this conversation as resolved.
Show resolved Hide resolved
msg += fmt.Sprintf(" Reason: '%s'.", e.Reason)
}
log.Debug(msg)
RobiNino marked this conversation as resolved.
Show resolved Hide resolved
}

func (writerMng *errorWriter) closeWriter() error {
// Close content writer and move output file to our working directory
if writerMng.writer == nil {
Expand Down
5 changes: 5 additions & 0 deletions artifactory/commands/transferfiles/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ func runProducerConsumers(pcWrapper *producerConsumerWrapper) (executionErr erro
go func() {
// Wait till notified that the builder has no additional tasks, and close the builder producer consumer.
<-pcWrapper.chunkBuilderProducerConsumer.GetFinishedNotification()
log.Debug("Chunk builder producer consumer has completed all tasks. " +
"All files relevant to this phase were found and added to chunks that are being uploaded...")
pcWrapper.chunkBuilderProducerConsumer.Done()
}()

Expand Down Expand Up @@ -261,6 +263,7 @@ func pollUploads(phaseBase *phaseBase, srcUpService *srcUserPluginService, uploa
}
for i := 0; ; i++ {
if ShouldStop(phaseBase, nil, errorsChannelMng) {
log.Debug("Stop signal received while polling on uploads...")
return
}
time.Sleep(waitTimeBetweenChunkStatusSeconds * time.Second)
Expand All @@ -284,6 +287,7 @@ func pollUploads(phaseBase *phaseBase, srcUpService *srcUserPluginService, uploa
// it will be written to the error channel
if chunksLifeCycleManager.totalChunks == 0 {
if shouldStopPolling(doneChan) {
log.Debug("Stopping to poll on uploads...")
return
}
continue
Expand Down Expand Up @@ -386,6 +390,7 @@ func handleChunksStatuses(phase *phaseBase, chunksStatus *api.UploadChunksStatus
stopped := handleFilesOfCompletedChunk(chunk.Files, errorsChannelMng)
// In case an error occurred while writing errors status's to the errors file - stop transferring.
if stopped {
log.Debug("Stop signal received while handling chunks statuses...")
return true
}
err = setChunkCompletedInRepoSnapshot(phase.stateManager, chunk.Files)
Expand Down
Loading