Skip to content

Commit 07bff04

Browse files
committed
change(uploader): some more comment/logging changes
1 parent ef04d8a commit 07bff04

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

uploader/copy.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,26 @@ func (u *Uploader) Copy(additionalRcloneParams []string) error {
2121
for _, remotePath := range u.Config.Remotes.Copy {
2222
// set variables
2323
attempts := 1
24-
rLog := u.Log.WithFields(logrus.Fields{
25-
"copy_remote": remotePath,
26-
"copy_local_path": u.Config.LocalFolder,
27-
"attempts": attempts,
28-
})
2924

3025
// copy to remote
3126
for {
32-
// get service account file
27+
// set log
28+
rLog := u.Log.WithFields(logrus.Fields{
29+
"copy_remote": remotePath,
30+
"copy_local_path": u.Config.LocalFolder,
31+
"attempts": attempts,
32+
})
33+
34+
// get service account(s)
3335
serviceAccounts, err := u.RemoteServiceAccountFiles.GetServiceAccount(remotePath)
3436
if err != nil {
3537
return errors.WithMessagef(err,
3638
"aborting further copy attempts of %q due to serviceAccount exhaustion",
3739
u.Config.LocalFolder)
38-
} else if len(serviceAccounts) > 0 {
39-
// reset log
40-
rLog = u.Log.WithFields(logrus.Fields{
41-
"copy_remote": remotePath,
42-
"copy_local_path": u.Config.LocalFolder,
43-
"attempts": attempts,
44-
})
40+
}
4541

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

78-
// ban service account(s)
76+
// ban service account(s) used
7977
for _, sa := range serviceAccounts {
8078
if err := cache.Set(sa.ServiceAccountPath, time.Now().UTC().Add(25*time.Hour)); err != nil {
8179
rLog.WithError(err).Error("Failed banning service account, cannot try again...")

uploader/move.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (u *Uploader) Move(serverSide bool, additionalRcloneParams []string) error
4242
extraParams = append(extraParams, additionalRcloneParams...)
4343
}
4444

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

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

7171
// display service accounts being used
@@ -119,7 +119,7 @@ func (u *Uploader) Move(serverSide bool, additionalRcloneParams []string) error
119119
}
120120
}
121121

122-
// attempt copy again
122+
// attempt move again
123123
rLog.Warnf("Move failed with retryable exit code %v, trying again...", exitCode)
124124
attempts++
125125
continue

0 commit comments

Comments
 (0)