Skip to content

Commit

Permalink
draft/wip
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hyagi committed Apr 24, 2024
1 parent 587c154 commit d8fcca3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 20 deletions.
3 changes: 1 addition & 2 deletions pulp_container/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ def init_labels(self):
config = json.loads(self.config_blob.config_blob.instance.data)["config"]
if "Labels" in config.keys():
self.labels = config["Labels"] or {}
# TODO: DO NOT USE BARE 'EXCEPT'
except:
except KeyError:
# if not, we'll retrieve the config from file
config_artifact = self.config_blob._artifacts.get()

Expand Down
19 changes: 3 additions & 16 deletions pulp_container/app/registry_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
validate_manifest,
)
from pulp_container.constants import (
CONFIG_BLOB_SIZE,
ARTIFACTLESS_BLOB_SIZE,
EMPTY_BLOB,
MEDIA_TYPE,
SIGNATURE_API_EXTENSION_VERSION,
Expand Down Expand Up @@ -792,7 +792,7 @@ def create_blob(self, artifact, digest):
blob.touch()

blob_size = artifact.file.size
if blob_size > CONFIG_BLOB_SIZE:
if blob_size > ARTIFACTLESS_BLOB_SIZE:
self._create_blob_content_artifact(artifact, blob, digest)
else:
with storage.open(artifact.file.name) as artifact_file:
Expand All @@ -804,7 +804,7 @@ def create_blob(self, artifact, digest):

def _create_blob_content_artifact(self, artifact, blob, digest):
"""
Blobs with size > CONFIG_BLOB_SIZE will be considered layer blobs and
Blobs with size > ARTIFACTLESS_BLOB_SIZE are often layer blobs and
will be stored as artifacts.
"""
try:
Expand Down Expand Up @@ -1004,19 +1004,6 @@ def handle_safe_method(self, request, path, pk):
blob = repository.pending_blobs.get(digest=pk)
blob.touch()
except models.Blob.DoesNotExist:
# try:
# # configblobs do not have a repository_version nor artifact
# blob = models.Blob.objects.get(digest=pk)
# media_type = MEDIA_TYPE.CONFIG_BLOB_OCI
# headers = {
# "Content-Type": media_type,
# "Docker-Content-Digest": pk,
# "Docker-Distribution-API-Version": "registry/2.0",
# }
# #return web.Response(text=blob.data,headers=headers)
# #return UploadResponse(upload=blob, path=path, request=request)
# return Response(data=blob.data)
# except models.Blob.DoesNotExist:
raise BlobNotFound(digest=pk)

if blob.data:
Expand Down
5 changes: 3 additions & 2 deletions pulp_container/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@
MEGABYTE = 1_000_000
SIGNATURE_PAYLOAD_MAX_SIZE = 4 * MEGABYTE

# TO-DO: ADD A COMMENT EXPLAINING WHY WE CHOSEN SUCH VALUE
CONFIG_BLOB_SIZE = 2000
# we defined the following size based on the average container config size of some
# ubi and bootable images
ARTIFACTLESS_BLOB_SIZE = 22000

SIGNATURE_API_EXTENSION_VERSION = 2

Expand Down

0 comments on commit d8fcca3

Please sign in to comment.