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

feat(libpod): support kube play tar content-type #24015

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

fixomatic-ctrl
Copy link
Contributor

@fixomatic-ctrl fixomatic-ctrl commented Sep 19, 2024

Part of #14527

Does this PR introduce a user-facing change?

Operation PlayKubeLibpodapi support Content-Type `application/x-tar`

Testing with a tar file

Create a test directory with the following structure

.
└── example/
    ├── play.yaml
    └── foobar/
        └── Containerfile
play.yaml
apiVersion: v1
kind: Pod
metadata:
  name: demo-build-remote
spec:
  containers:
    - name: container
      image: foobar
example/foobar/Containerfile
FROM docker.io/library/alpine:latest
  1. make binaries
    Create a podman system service
  2. ./bin/podman system service --time=0 tcp://localhost:8888
    Create a tar file example.tar with our example content
  3. cd ./example && tar cvf example.tar *
$: curl --location 'http://localhost:8888/v5.0.0/libpod/kube/play' \
    --header 'Content-Type: application/x-tar' \
    --data '@./example/example.tar'
{
    "Pods": [
        {
            "ID": "<omitted>",
            "Containers": [
                "<omitted>"
            ],
            "InitContainers": null,
            "Logs": null,
            "ContainerErrors": null
        }
    ],
    "Volumes": null,
    "StopReport": null,
    "RmReport": null,
    "VolumeRmReport": null,
    "SecretRmReport": null,
    "Secrets": null,
    "ServiceContainerID": "",
    "ExitCode": null
}

Testing backward compatibilty

Let's check we did not break the basic support

play.yaml

Change to

apiVersion: v1
kind: Pod
metadata:
  name: demo-build-remote
spec:
  containers:
    - name: container
      image: docker.io/library/nginx:latest
  1. ./bin/podman kube play example/play.yaml

Copy link
Contributor

openshift-ci bot commented Sep 19, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fixomatic-ctrl
Once this PR has been reviewed and has the lgtm label, please assign edsantiago for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Sep 19, 2024
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

This does sound like a good approach to me, you should update the swagger doc for this endpoint to specify the accept content-tpye and what format it expects in the tar

pkg/util/kube.go Outdated Show resolved Hide resolved
pkg/util/kube.go Outdated Show resolved Hide resolved
@fixomatic-ctrl fixomatic-ctrl force-pushed the feat/libpod-remote-tar-support branch 3 times, most recently from cf19d57 to 6ee082d Compare September 20, 2024 11:46
@fixomatic-ctrl
Copy link
Contributor Author

/retest

Copy link
Contributor

openshift-ci bot commented Sep 20, 2024

@fixomatic-ctrl: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@mheon
Copy link
Member

mheon commented Sep 20, 2024

Wonder if this is worth implementing for the CLI side of things for Podman Desktop.
Code LGTM

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Code wise LGTM

It would be nice to have an actual API level test here with a tarball, please see test/apiv2 for such test. There are already some libpod/build tests there that show how it should be done.

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@fixomatic-ctrl
Copy link
Contributor Author

fixomatic-ctrl commented Sep 24, 2024

It would be nice to have an actual API level test here with a tarball, please see test/apiv2 for such test. There are already some libpod/build tests there that show how it should be done.

@Luap99 while making the tests, I noticed that if we already build the image(s), we do not have any way to force the re-build. It would re-use the existing image. Therefore I added a query parameter build, which would be translated to the PlayKubeOptions.

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Thanks this looks mostly good but you have to use $IMAGE in the tests to make them work in CI reliably

test/apiv2/80-kube.at Outdated Show resolved Hide resolved
test/apiv2/80-kube.at Outdated Show resolved Hide resolved
test/apiv2/80-kube.at Outdated Show resolved Hide resolved
Signed-off-by: fixomatic-ctrl <[email protected]>
@Luap99 Luap99 merged commit 1dd90db into containers:main Sep 27, 2024
72 of 79 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/api-change Change to remote API; merits scrutiny release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants