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

[WIP] Support remote podman #2235

Closed

Conversation

afrittoli
Copy link

Gather info about the provider using podman info instead of
looking on the host directly. This allows starting a cluster
when the host is remote, for instance running in a VM on
a MacOS or Windows host.

Not all the info available via docker info is available in
podman info, so logging a warning when using podman.

Signed-off-by: Andrea Frittoli [email protected]

k8s-ci-robot and others added 6 commits April 27, 2021 17:02
potential fix for white space in source path
Gather info about the provider using `podman info` instead of
looking on the host directly. This allows starting a cluster
when the host is remote, for instance running in a VM on
a MacOS or Windows host.

Not all the info available via `docker info` is available in
`podman info`, so logging a warning when using podman.

Signed-off-by: Andrea Frittoli <[email protected]>
@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 7, 2021
@k8s-ci-robot
Copy link
Contributor

Welcome @afrittoli!

It looks like this is your first PR to kubernetes-sigs/kind 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kind has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @afrittoli. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: afrittoli
To complete the pull request process, please assign bentheelder after the PR has been reviewed.
You can assign the PR to them by writing /assign @bentheelder in a comment when ready.

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

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 7, 2021
@k8s-ci-robot k8s-ci-robot requested review from amwat and krzyzacy May 7, 2021 15:21
@k8s-ci-robot k8s-ci-robot added area/provider/docker Issues or PRs related to docker area/provider/podman Issues or PRs related to podman size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 7, 2021
info := &providers.ProviderInfo{
Rootless: euid != 0,
}
if _, err := os.Stat("/sys/fs/cgroup/cgroup.controllers"); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

and .... do we stop handling the local podman case?

@aojea
Copy link
Contributor

aojea commented May 7, 2021

is there a way to know if podman is working in remote or local mode?
I rather prefer to branch on that that removing current code

info := &providers.ProviderInfo{
Rootless: euid != 0,
}
if _, err := os.Stat("/sys/fs/cgroup/cgroup.controllers"); err == nil {
Copy link
Contributor

@aojea aojea May 7, 2021

Choose a reason for hiding this comment

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

maybe, we just need to skip this check if we can detect is a remote podman

if !podman_remote() && _, err := os.Stat("/sys/fs/cgroup/cgroup.controllers"); err == nil {

Copy link
Contributor

Choose a reason for hiding this comment

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

let me summon the expert,
@vrothberg can I know from the podman cli if is running remote or local?

Choose a reason for hiding this comment

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

Not yet but I opened containers/podman#10289. @baude, do you know a workaround?

Copy link
Contributor

Choose a reason for hiding this comment

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

@afrittoli can we try with this approach?
containers/podman#10289 (comment)
something like

// podman_remote returns true if podman is using a remote client
// xref: https://github.com/containers/podman/issues/10289
func podman_remote() bool{
  ... check https://github.com/containers/podman/issues/10289#issuecomment-838302394 ...
}

@BenTheElder
Copy link
Member

This change needs to be compatible with older podman versions.

I suspect instead of trying to detect if podman is remote or not it needs to check the podman version anyhow before selecting the format string to request, since go text templates explode on unknown fields.

@aojea
Copy link
Contributor

aojea commented May 14, 2021

This change needs to be compatible with older podman versions.

I suspect instead of trying to detect if podman is remote or not it needs to check the podman version anyhow before selecting the format string to request, since go text templates explode on unknown fields.

?

if _, err = os.exec(podman --remote info); err != nil {
 podman is local
}

@BenTheElder
Copy link
Member

I mean the fields available to the format string depend on the podman version. So we should just read the podman version and if it's new enough we request the new fields and if not we collect the other fields from podman and the rest from reading local as we already support?

You don't need to check if it's local or not, either it's new enough to get this info for remote and we do that, or it's too old and we should still get the info for local. That's purely based on version.

@aojea aojea mentioned this pull request May 18, 2021
@afrittoli
Copy link
Author

I mean the fields available to the format string depend on the podman version. So we should just read the podman version and if it's new enough we request the new fields and if not we collect the other fields from podman and the rest from reading local as we already support?

You don't need to check if it's local or not, either it's new enough to get this info for remote and we do that, or it's too old and we should still get the info for local. That's purely based on version.

If we want to support older versions of podman we do indeed check the version.
The alternative could be - since support is experimental anyways - to only support newer versions. I suspect that might break someone's workflow if they upgrade to the latest kind, but given the experimental tag on the feature, it feel like it would be acceptable to require a podman upgrade along with a kind upgrade?
In any case I'm happy to oblige is the kind team prefers to continue supporting the older versions of podman.

In terms of local vs. remote, the podman info command does not provide all the info that kind expects. It is possible to work with the info only (like I've done in this PR), but we could still detect the local case and collect the extra info there.

To sum up, based on the various comments, my proposal would be to:

  • detect podman version
  • parse the output of podman info according to the version
  • detect if running local of remote
  • if local collect the info not available from the podman info command from the local system
  • if not enough info is available to run, fail with a specific error message

Does this make sense?
This week I have no bandwidth to work on this, but I'd be happy to come back to it next week.

@aojea
Copy link
Contributor

aojea commented May 18, 2021

podman info will provide the "remote" info, it has merged in master containers/podman#10300

I honestly will not try to support older podman versions, we have too many if branches already and the remote case seems relatively new

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2021
@k8s-ci-robot
Copy link
Contributor

@afrittoli: PR needs rebase.

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/test-infra repository.

@BenTheElder
Copy link
Member

I would suggest a slightly more specific order:

  • detect podman version (and error if too old due to difficult to deal with bugs)
  • collect as much info as we can for the podman version, including an attempt to detect local vs remote
  • if we do not detect remote, assume local
  • if we are local and do not have enough info, detect from local host details (probe vfs etc.)

@aojea I think time has shown that we will need to switch on the version anyhow as we cannot depend on format structs to be stable. We already do this for e.g. port mapping.

@aojea
Copy link
Contributor

aojea commented Jun 10, 2021

I would suggest a slightly more specific order:

  • detect podman version (and error if too old due to difficult to deal with bugs)

THIS ^^^

  • collect as much info as we can for the podman version, including an attempt to detect local vs remote
  • if we do not detect remote, assume local
  • if we are local and do not have enough info, detect from local host details (probe vfs etc.)

@aojea I think time has shown that we will need to switch on the version anyhow as we cannot depend on format structs to be stable. We already do this for e.g. port mapping.

sounds great

@BenTheElder
Copy link
Member

Does anyone know if this general approach is still required? I think podman has made some improvements here 🤞

@afrittoli
Copy link
Author

I tried recently kind with podman on an M1 Mac and it all worked well, so this can be closed now.
I'm sorry o never followed up on this PR.

@afrittoli afrittoli closed this Oct 6, 2022
@BenTheElder
Copy link
Member

not at all, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/docker Issues or PRs related to docker area/provider/podman Issues or PRs related to podman cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants