Skip to content

Commit

Permalink
change(uploader): some more comment/logging changes
Browse files Browse the repository at this point in the history
  • Loading branch information
l3uddz committed Apr 21, 2020
1 parent ef04d8a commit 07bff04
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
26 changes: 12 additions & 14 deletions uploader/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,26 @@ func (u *Uploader) Copy(additionalRcloneParams []string) error {
for _, remotePath := range u.Config.Remotes.Copy {
// set variables
attempts := 1
rLog := u.Log.WithFields(logrus.Fields{
"copy_remote": remotePath,
"copy_local_path": u.Config.LocalFolder,
"attempts": attempts,
})

// copy to remote
for {
// get service account file
// set log
rLog := u.Log.WithFields(logrus.Fields{
"copy_remote": remotePath,
"copy_local_path": u.Config.LocalFolder,
"attempts": attempts,
})

// get service account(s)
serviceAccounts, err := u.RemoteServiceAccountFiles.GetServiceAccount(remotePath)
if err != nil {
return errors.WithMessagef(err,
"aborting further copy attempts of %q due to serviceAccount exhaustion",
u.Config.LocalFolder)
} else if len(serviceAccounts) > 0 {
// reset log
rLog = u.Log.WithFields(logrus.Fields{
"copy_remote": remotePath,
"copy_local_path": u.Config.LocalFolder,
"attempts": attempts,
})
}

// display service account(s) being used
if len(serviceAccounts) > 0 {
for _, sa := range serviceAccounts {
rLog.Infof("Using service account %q: %v", sa.RemoteEnvVar, sa.ServiceAccountPath)
}
Expand Down Expand Up @@ -75,7 +73,7 @@ func (u *Uploader) Copy(additionalRcloneParams []string) error {
return fmt.Errorf("copy failed with exit code: %v", exitCode)
}

// ban service account(s)
// ban service account(s) used
for _, sa := range serviceAccounts {
if err := cache.Set(sa.ServiceAccountPath, time.Now().UTC().Add(25*time.Hour)); err != nil {
rLog.WithError(err).Error("Failed banning service account, cannot try again...")
Expand Down
10 changes: 5 additions & 5 deletions uploader/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (u *Uploader) Move(serverSide bool, additionalRcloneParams []string) error
extraParams = append(extraParams, additionalRcloneParams...)
}

// iterate all remotes and run copy
// iterate all remotes and run move
for _, move := range moveRemotes {
// set variables
attempts := 1
Expand All @@ -59,13 +59,13 @@ func (u *Uploader) Move(serverSide bool, additionalRcloneParams []string) error
"attempts": attempts,
})

// get service account file(s) for non server side move
// get service account(s) for non server side move
if !serverSide {
serviceAccounts, err = u.RemoteServiceAccountFiles.GetServiceAccount(move.To)
if err != nil {
return errors.WithMessagef(err,
"aborting further copy attempts of %q due to serviceAccount exhaustion",
u.Config.LocalFolder)
"aborting further move attempts of %q due to serviceAccount exhaustion",
move.From)
}

// display service accounts being used
Expand Down Expand Up @@ -119,7 +119,7 @@ func (u *Uploader) Move(serverSide bool, additionalRcloneParams []string) error
}
}

// attempt copy again
// attempt move again
rLog.Warnf("Move failed with retryable exit code %v, trying again...", exitCode)
attempts++
continue
Expand Down

0 comments on commit 07bff04

Please sign in to comment.