Skip to content

Commit

Permalink
change(syncer): only remove temporary bans when service account serve…
Browse files Browse the repository at this point in the history
…r is not running

this is because we cannot guarantee the service account(s) used on gclone/rclone start, are the ones that it finished with due to on-fly sa cycling
  • Loading branch information
l3uddz committed May 16, 2020
1 parent e989d56 commit 71276f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion syncer/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ func (s *Syncer) Copy(additionalRcloneParams []string) error {
return errors.WithMessagef(err, "copy failed unexpectedly with exit code: %v", exitCode)
} else if success {
// successful exit code
rclone.RemoveServiceAccountsFromTempCache(serviceAccounts)
if !s.Ws.Running {
// web service is not running (no gclone)
rclone.RemoveServiceAccountsFromTempCache(serviceAccounts)
}
break
}

Expand Down
5 changes: 4 additions & 1 deletion syncer/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ func (s *Syncer) Sync(additionalRcloneParams []string) error {
return errors.WithMessagef(err, "sync failed unexpectedly with exit code: %v", exitCode)
} else if success {
// successful exit code
rclone.RemoveServiceAccountsFromTempCache(serviceAccounts)
if !s.Ws.Running {
// web service is not running (no gclone)
rclone.RemoveServiceAccountsFromTempCache(serviceAccounts)
}
break
}

Expand Down
4 changes: 4 additions & 0 deletions syncer/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
type WebServer struct {
Host string
Port int
Running bool
app *fiber.App
log *logrus.Entry
syncerName string
Expand Down Expand Up @@ -86,10 +87,13 @@ func newWebServer(host string, log *logrus.Entry, syncerName string, sa *rclone.
func (ws *WebServer) Run() {
go func() {
ws.log.Infof("Starting service account server on %s:%d", ws.Host, ws.Port)
ws.Running = true

if err := ws.app.Listen(fmt.Sprintf("%s:%d", ws.Host, ws.Port)); err != nil {
ws.log.WithError(err).Error("Service account server failed...")
}

ws.Running = false
}()
}

Expand Down

0 comments on commit 71276f9

Please sign in to comment.