Audit the number of SQL queries we make in writing manifests, and significantly reduce in the common case

Instead of 41 queries now for the simple manifest, we are down to 14.

The biggest changes:
  - Only synthesize the V1 image rows if we haven't already found them in the database
  - Thread the repository object through to the other model method calls, and use it instead of loading again and again
This commit is contained in:
Joseph Schorr 2018-01-11 16:25:38 -05:00
parent 4f47808e99
commit 9e16a989f5
8 changed files with 145 additions and 66 deletions

View file

@ -165,7 +165,7 @@ class DockerSchema1Manifest(object):
try:
validate_schema(self._parsed, DockerSchema1Manifest.METASCHEMA)
except ValidationError as ve:
raise MalformedSchema1Manifest('malformed manifest data: %s' % ve)
raise MalformedSchema1Manifest('manifest data does not match schema: %s' % ve)
self._signatures = self._parsed[DOCKER_SCHEMA1_SIGNATURES_KEY]
self._tag = self._parsed[DOCKER_SCHEMA1_REPO_TAG_KEY]