Skip to content

Add gramine-manifest to GSC build#238

Open
DukeDavis12 wants to merge 1 commit into
gramineproject:masterfrom
DukeDavis12:uew_ibm_fix
Open

Add gramine-manifest to GSC build#238
DukeDavis12 wants to merge 1 commit into
gramineproject:masterfrom
DukeDavis12:uew_ibm_fix

Conversation

@DukeDavis12
Copy link
Copy Markdown
Contributor

@DukeDavis12 DukeDavis12 commented Apr 9, 2025

Description of the changes

Fixes #249, #251.

How to test this PR?


This change is Reviewable

@DukeDavis12 DukeDavis12 changed the title Add ManifestError exception class for error handling [WIP] Add ManifestError exception class for error handling Apr 9, 2025
@mkow mkow requested a review from woju April 15, 2025 21:02
@DukeDavis12 DukeDavis12 changed the title [WIP] Add ManifestError exception class for error handling Add ManifestError exception class for error handling Apr 16, 2025
@DukeDavis12 DukeDavis12 changed the title Add ManifestError exception class for error handling Add directory handling in expand_trusted_files Apr 16, 2025
Copy link
Copy Markdown
Member

@woju woju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: )


a discussion (no related file):
Directories are problematic far beyond this, from cursory look you'll need to account for symlinks, you didn't check for / as the last character and possibly other problems.

We already solved those in gramine-manifest. I think you need to either reuse that tool, or if you can't, you'll need to require that people have installed gramine and then you can import gramine.manifest and reuse gramine.manifest.Manifest class or gramine.manifest.TrustedFile. Lack of code reuse in this area is becoming untenable.

Otherwise you'll be condemned to repeat all our previous mistakes in this area yourself.

@DukeDavis12
Copy link
Copy Markdown
Contributor Author

DukeDavis12 commented Apr 16, 2025

@woju

you'll need to require that people have installed gramine and then you can import gramine.manifest and reuse gramine.manifest.Manifest class or gramine.manifest.TrustedFile. Lack of code reuse in this area is becoming untenable.

Thanks for the suggestion. Reusing gramine-manifest tool.

Can you review the changes ?

@DukeDavis12 DukeDavis12 requested a review from woju April 16, 2025 09:58
@DukeDavis12 DukeDavis12 changed the title Add directory handling in expand_trusted_files Add gramine-manifest to GSC build Apr 22, 2025
Copy link
Copy Markdown
Member

@woju woju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ), one-liner is not in imperative mood


-- commits line 14 at r2:
(n/b) All of this history probably needs to be squashed and reworded, possibly at merge.


templates/Dockerfile.common.build.template line 66 at r2 (raw file):

RUN {% block path %}{% endblock %} \
    && gramine-manifest /gramine/app_files/entrypoint.manifest \
    /gramine/app_files/entrypoint.manifest \

This depends on an edge behaviour of click that the file is opened for writing on first write, not when main() is called. If not for it, having same file for input and output would truncate(2) it before it is even read, resulting in empty file and likely parse error. Click has it documented, but I think it's quirky: https://click.palletsprojects.com/en/stable/handling-files/#file-opening-behaviors.

@mkow do we want to leave it like that? It works, it's officially documented and it's reasonably robust (I think it won't ever break), but it is surprising. Alternatives: 1) we can have separate file as the manifest, 2) we can comment (here and/or in main repo, python/gramine-manifest to uphold an invariant that we need to fully read manifest before calling manifest.dump(file)).


templates/Dockerfile.common.build.template line 67 at r2 (raw file):

    && gramine-manifest /gramine/app_files/entrypoint.manifest \
    /gramine/app_files/entrypoint.manifest \
    && gramine-manifest-check /gramine/app_files/entrypoint.manifest

If calling gramine-manifest directly, you can remove gramine-manifest-check, because the check is called internally. Alternatively you can add --no-check to gramine-manifest and leave this explicit call, if you want it for some reason.

@DukeDavis12 DukeDavis12 requested a review from woju April 29, 2025 19:12
Copy link
Copy Markdown
Contributor Author

@DukeDavis12 DukeDavis12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ), one-liner is not in imperative mood (waiting on @woju)


a discussion (no related file):

Previously, woju (Wojtek Porczyk) wrote…

Directories are problematic far beyond this, from cursory look you'll need to account for symlinks, you didn't check for / as the last character and possibly other problems.

We already solved those in gramine-manifest. I think you need to either reuse that tool, or if you can't, you'll need to require that people have installed gramine and then you can import gramine.manifest and reuse gramine.manifest.Manifest class or gramine.manifest.TrustedFile. Lack of code reuse in this area is becoming untenable.

Otherwise you'll be condemned to repeat all our previous mistakes in this area yourself.

Using gramine-manifest tool now instead of handling it in code.


-- commits line 14 at r2:

Previously, woju (Wojtek Porczyk) wrote…

(n/b) All of this history probably needs to be squashed and reworded, possibly at merge.

Will squash once I get approval from your side.


templates/Dockerfile.common.build.template line 67 at r2 (raw file):

Previously, woju (Wojtek Porczyk) wrote…

If calling gramine-manifest directly, you can remove gramine-manifest-check, because the check is called internally. Alternatively you can add --no-check to gramine-manifest and leave this explicit call, if you want it for some reason.

Removed gramine-manifest-check.

Copy link
Copy Markdown
Contributor Author

@DukeDavis12 DukeDavis12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 2 files reviewed, 3 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ), one-liner is not in imperative mood (waiting on @mkow and @woju)


templates/Dockerfile.common.build.template line 66 at r2 (raw file):

Previously, woju (Wojtek Porczyk) wrote…

This depends on an edge behaviour of click that the file is opened for writing on first write, not when main() is called. If not for it, having same file for input and output would truncate(2) it before it is even read, resulting in empty file and likely parse error. Click has it documented, but I think it's quirky: https://click.palletsprojects.com/en/stable/handling-files/#file-opening-behaviors.

@mkow do we want to leave it like that? It works, it's officially documented and it's reasonably robust (I think it won't ever break), but it is surprising. Alternatives: 1) we can have separate file as the manifest, 2) we can comment (here and/or in main repo, python/gramine-manifest to uphold an invariant that we need to fully read manifest before calling manifest.dump(file)).

@mkow What's your take ?

Copy link
Copy Markdown
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3.
Reviewable status: all files reviewed, 3 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ), one-liner is not in imperative mood (waiting on @woju)


templates/Dockerfile.common.build.template line 66 at r2 (raw file):

Previously, DukeDavis12 (Davis Benny) wrote…

@mkow What's your take ?

We can keep it, but we'd need to document that on the python/gramine-manifest side + add a test there. It's IMO not obvious otherwise that it works.

@DukeDavis12
Copy link
Copy Markdown
Contributor Author

@woju @mkow Please review.

Copy link
Copy Markdown
Member

@mkow mkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 2 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ), one-liner is not in imperative mood (waiting on @woju)

Copy link
Copy Markdown
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kailun-qin made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ), one-liner is not in imperative mood (waiting on woju).


a discussion (no related file):
@DukeDavis12: Same question here, Davis -- do you plan to continue working on this PR? Otherwise, I can take care of it.

@DukeDavis12
Copy link
Copy Markdown
Contributor Author

@kailun-qin made 1 comment.
Reviewable status: all files reviewed, 3 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ), one-liner is not in imperative mood (waiting on woju).

a discussion (no related file): @DukeDavis12: Same question here, Davis -- do you plan to continue working on this PR? Otherwise, I can take care of it.

I am working on a different Project now. @kailun-qin Can you take care of it ?

Previously, GSC commit 67d8235 "Add trusted files expansion in
finalize_manifest.py" introduced manual URI expansion and SHA256
hashing. However, this logic is fragile and fails to handle several
edge cases.

This commit reverts that implementation and instead leverages the
`gramine-manifest` tool. With this reuse, we can also safely remove the
deprecated `loader.entrypoint.uri` syntax as it is now automatically
populated during manifest preprocessing. This aligns with core Gramine
commit 87c752f "[PAL] Drop deprecated syntax of loader.entrypoint".

Co-authored-by: Davis Benny <davis.benny@intel.com>
Signed-off-by: Davis Benny <davis.benny@intel.com>
Signed-off-by: Kailun Qin <kailun.qin@intel.com>
Copy link
Copy Markdown
Contributor

@kailun-qin kailun-qin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kailun-qin reviewed 5 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions, not enough approvals from maintainers (2 more required), not enough approvals from different teams (2 more required, approved so far: ) (waiting on mkow and woju).


a discussion (no related file):

Previously, DukeDavis12 (Davis Benny) wrote…

I am working on a different Project now. @kailun-qin Can you take care of it ?

Thanks! Updated.


-- commits line 14 at r2:

Previously, DukeDavis12 (Davis Benny) wrote…

Will squash once I get approval from your side.

Done.


templates/Dockerfile.common.build.template line 66 at r2 (raw file):
Done.

but we'd need to document that on the python/gramine-manifest side + add a test there

I'll submit a PR to the core Gramine repo later. For now, I'm adding a note here as suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GSC v1.9 fails for ubuntu 22.04

4 participants