-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add manifest arch, os, and compressed layers size fields #1782
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of remarks:
- If we need to store the "architecture" and "os" fields on the Manifest model, we should try to fetch the values from a manifest list first. An OCI Index has the "architecture" and "os" fields required. There is no need to read the data from a config blob if a manifest is listed within an index (https://github.com/opencontainers/image-spec/blob/main/image-index.md#image-index-property-descriptions).
- Currently, there are three separate migrations. I would like to squash them. Every migration takes time to run some boilerplate which is transparent to us.
- Currently, there are three commits referencing the same issue. I would like to squash them. Such a separation is not necessary.
- If we decided to create another django-admin command, we should align with Katello to see if it makes sense for them to run a management command reading data from the storage.
CHANGES/1767.feature
Outdated
The Manifest model has been enhanced with a new: | ||
* `architecture` field, which specifies the CPU architecture for which the binaries in the | ||
image are designed to run. | ||
* `os` field, which specifies the operating system which the image is built to run on. | ||
* `compressed_layers_size` field, which specifies the sum of the sizes of all compressed layers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite wordy. We should stick to shorter changelog messages (see https://pulpproject.org/pulpcore/changes/ for reference). It is not necessary to describe every manifest field in detail.
pulp_container/app/management/commands/container-repair-manifest-metadatas.py
Outdated
Show resolved
Hide resolved
pulp_container/app/models.py
Outdated
@@ -103,6 +108,9 @@ class Manifest(Content): | |||
|
|||
annotations = models.JSONField(default=dict) | |||
labels = models.JSONField(default=dict) | |||
architecture = models.TextField(null=True) | |||
os = models.TextField(null=True) | |||
compressed_layers_size = models.TextField(null=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to use IntegerField
here?
From the Katello side, we're okay with the command being the same as before or a new one. Choose whatever is most efficient from the Pulp side. |
Also I wanted to clarify to be super sure -- OCI Image Index manifests will always have a |
Thank you for bringing this! |
After re-reading the specs, I realized that So, please, ignore my last comment and yes, "OCI Image Index manifests will always have a null arch, OS, and size". |
Nice catch! I didn't notice it was under manifests, so that's perfect. |
c6cc26f
to
27cfe78
Compare
I did some investigation in each workflow, and here are my findings:
I couldn't find how to fetch these values from the manifest list in advance. I'm not sure if I overlooked something or misunderstood the code workflow. |
|
27cfe78
to
c7816f8
Compare
Thank you for the help and the suggestions/optimizations! |
c7816f8
to
8b53a1e
Compare
ef816f0
to
c152cf4
Compare
cc @sjha4 @qcjames53 we should keep an eye on this and integrate with it in Katello sooner rather than later to avoid excess reindexing of container manifests. |
c152cf4
to
8f390fa
Compare
pulp_container/app/models.py
Outdated
@@ -103,6 +108,9 @@ class Manifest(Content): | |||
|
|||
annotations = models.JSONField(default=dict) | |||
labels = models.JSONField(default=dict) | |||
architecture = models.TextField(null=True) | |||
os = models.TextField(null=True) | |||
compressed_layers_size = models.IntegerField(null=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about compressed_image_size
@git-hyagi, please, rebase this PR against the main branch and prepare it for the final review. |
8f390fa
to
91147ca
Compare
88bda0e
to
ec2d14e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the migration is zero downtime safe. And also i don't see any code failing before the fields get populated (The results may be incomplete, but you are supposed to run the command anyway.).
None of the comments should be blocking here.
if platform := listed_manifest.get("platform"): | ||
manifest_list_manifest.architecture = platform["architecture"] | ||
manifest_list_manifest.os = platform["os"] | ||
manifest_list_manifest.features = platform.get("features") | ||
manifest_list_manifest.variant = platform.get("variant") | ||
manifest_list_manifest.os_version = platform.get("os.version") | ||
manifest_list_manifest.os_features = platform.get("os.features") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is at least the third time i'm seeing this pattern now.
Maybe a dataclass together with asdict
can help here? (Maybe not in this PR.)
https://docs.python.org/3/library/dataclasses.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this and agreed on opening a task issue to investigate this later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why this cannot be addressed in this PR. Also, notice how in some cases you are initializing os_version
as p.get("os.version")
and in some cases as p.get("os.version", "")
. Not to mention that you even do (p.get("os.version", ""),)
. I am not a fan of such discrepancies. Please, resolve this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to use the @dataclass
decorator, but I had trouble to make it work (probably because of the image_manifest
and manifest_list
foreignkey fields).
if platform := listed_manifest.get("platform"): | ||
manifest_list_manifest.architecture = platform["architecture"] | ||
manifest_list_manifest.os = platform["os"] | ||
manifest_list_manifest.features = platform.get("features") | ||
manifest_list_manifest.variant = platform.get("variant") | ||
manifest_list_manifest.os_version = platform.get("os.version") | ||
manifest_list_manifest.os_features = platform.get("os.features") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why this cannot be addressed in this PR. Also, notice how in some cases you are initializing os_version
as p.get("os.version")
and in some cases as p.get("os.version", "")
. Not to mention that you even do (p.get("os.version", ""),)
. I am not a fan of such discrepancies. Please, resolve this.
ec2d14e
to
c182212
Compare
c182212
to
aad0286
Compare
closes: #1767