ssh: move proxy usage to the sync subcommand

The only time we really need ssh proxies is when we want to run many
connections and reuse them.  That only happens when running sync.
Every other command makes at most two connections, and even then it's
only one or none.  So the effort of setting up & tearing down ssh
proxies isn't worth it most of the time.

The big reason we want to move this logic to sync is that it's now
using multiprocessing for parallel work.  The current ssh proxy code
is all based on threads, which means none of the logic is working
correctly.  The current ssh design makes it hard to fix when all of
the state lives in the global/module scope.

So the first step to fixing this is top move the setup & teardown to
the one place that really needs it: sync.  No other commands will use
proxies anymore, just direct connections.

Bug: https://crbug.com/gerrit/12389
Change-Id: Ibd351acdec39a87562b3013637c5df4ea34e03c6
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305485
Reviewed-by: Chris Mcdonald <cjmcdonald@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger
2021-05-05 19:44:35 -04:00
parent 4a58100251
commit 19e409c818
4 changed files with 32 additions and 22 deletions

View File

@ -57,6 +57,7 @@ from error import RepoChangedException, GitError, ManifestParseError
import platform_utils
from project import SyncBuffer
from progress import Progress
import ssh
from wrapper import Wrapper
from manifest_xml import GitcManifest
@ -357,6 +358,7 @@ later is required to fix a server side protocol bug.
optimized_fetch=opt.optimized_fetch,
retry_fetches=opt.retry_fetches,
prune=opt.prune,
ssh_proxy=True,
clone_filter=self.manifest.CloneFilter,
partial_clone_exclude=self.manifest.PartialCloneExclude)
@ -983,8 +985,12 @@ later is required to fix a server side protocol bug.
self._fetch_times = _FetchTimes(self.manifest)
if not opt.local_only:
self._FetchMain(opt, args, all_projects, err_event, manifest_name,
load_local_manifests)
try:
ssh.init()
self._FetchMain(opt, args, all_projects, err_event, manifest_name,
load_local_manifests)
finally:
ssh.close()
# If we saw an error, exit with code 1 so that other scripts can check.
if err_event.is_set():