Skip to content
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

e2e-test: enable real TEE on self-hosted runners #284

Merged

Conversation

mkulke
Copy link
Contributor

@mkulke mkulke commented Jan 10, 2024

Why

We want to be able to test PRs in a real TEE on self-hosted runners. By
default the tests are executed in the fork from which the PR is crated.
The fork does not have the self-hosted runners which provide the TEE. We
need to run them in the scope of the target repository in a safe fashion
that prevents untrusted PRs from running arbitrary code on self-hosted
runners.

fixes: #223

How

This change is modelled after simular workflows in kata and CAA repos.

The matrix-based kbs-e2e workflow has been turned into a reusable
workflow that is being called by specific TEE workflows. In this PR that
would be the "sample" and "az-snp-vtpm" TEE.

For a real TEE we follow the following ceremony:

  1. verify whether the PR is authorized to run (a maintainer needs to set
    a label on the PR).
  2. checkout the main branch from the target
  3. rebase the changes from the source atop the main branch (using a
    script copied verbatim from CAA)
  4. archive the resulting HEAD and upload it as artifact
  5. call the re-usable workflow with the required runners param
  6. extract the artifact
  7. run the test

For the sample TEE steps 1-3 are replaced by a simple checkout

Caveats

This yaml spaghetti is very hard to test. So while this passes actionlint,
it might need several iterations to always work.

The reusable workflow is targetting main and we cannot point it to a
fork, so no workflow run will successfully complete in this PR.

@mkulke mkulke requested a review from sameo as a code owner January 10, 2024 17:29
Copy link
Member

@fitzthum fitzthum left a comment

Choose a reason for hiding this comment

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

LGTM

@mkulke mkulke marked this pull request as draft January 10, 2024 18:03
@mkulke
Copy link
Contributor Author

mkulke commented Jan 10, 2024

ok we can't merge this yet, since the e2e test is scheduled on the PR's fork (mkulke/kbs) which is not what we want. we want it to run on a self-hosted runner in the scope of this repo, but only

  • after someone added an test-e2e label (@wainersm can you provide pointers on which yaml snippet to copypaste for that? afair think we need some additional rebase step)
  • and on pushes to main (i.e. after merge)

see this: #223 (comment)

let's do those changes to the workflow in the scope of this PR. sample e2e can still run anywhere

@mkulke mkulke force-pushed the mkulke/enable-az-snp-e2e-test branch from 8208cbd to 887379a Compare January 11, 2024 12:19
@mkulke mkulke changed the title e2e-test: enable az-snp-vtpm tee e2e-test: enable real TEE on self-hosted runners Jan 11, 2024
Copy link
Member

@Xynnn007 Xynnn007 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. We are excited to see the CI on real TEE.

@@ -0,0 +1,43 @@
#!/usr/bin/env bash
#
# Copyright (c) 2023 Intel Corporation
Copy link
Member

Choose a reason for hiding this comment

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

Is this Intel mark intended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's copied from CAA, which copied it from kata afaik, so I left the header in

@mkulke mkulke marked this pull request as ready for review January 12, 2024 11:52
We want to be able to test PRs in a real TEE on self-hosted runners. By
default the tests are executed in the fork from which the PR is crated.
The fork does not have the self-hosted runners which provide the TEE. We
need to run them in the scope of the target repository in a safe fashion
that prevents untrusted PRs from running arbitrary code on self-hosted
runners.

This change is modelled after simular workflows in kata and CAA repos.

The matrix-based kbs-e2e workflow has been turned into a reusable
workflow that is being called by specific TEE workflows. In this PR that
would be the "sample" and "az-snp-vtpm" TEE.

For a real TEE we follow the following ceremony:
1) verify whether the PR is authorized to run (a maintainer needs to set
   a label on the PR).
2) checkout the main branch from the target
3) rebase the changes from the source atop the main branch (using a
   script copied verbatim from CAA)
4) archive the resulting HEAD and upload it as artifact
5) call the re-usable workflow with the required runners param
6) extract the artifact
7) run the test

For the sample TEE steps 1-3 are replaced by a simple checkout

Signed-off-by: Magnus Kulke <[email protected]>
@mkulke mkulke force-pushed the mkulke/enable-az-snp-e2e-test branch from 887379a to 54606ce Compare January 12, 2024 11:53
@fitzthum fitzthum merged commit 5ef9aed into confidential-containers:main Jan 12, 2024
7 checks passed
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.

Enable e2e tests for real TEEs
3 participants