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

Initial podman support #2794

Closed
wants to merge 7 commits into from
Closed

Initial podman support #2794

wants to merge 7 commits into from

Conversation

towe75
Copy link

@towe75 towe75 commented Jan 31, 2021

This PR adds simple support for podman based containers.

I tested it only with rootful containers, also there is no filesystem watcher yet. It simply uses the docker API client. A more sophisticated version would have to use the native podman API to access i.e. the storage graph details etc.

It's, however, a good starting point and might be useful for some people, see #2424

@google-cla
Copy link

google-cla bot commented Jan 31, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@k8s-ci-robot
Copy link
Collaborator

Hi @towe75. Thanks for your PR.

I'm waiting for a google 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.

@towe75
Copy link
Author

towe75 commented Jan 31, 2021

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Jan 31, 2021
Copy link
Collaborator

@Creatone Creatone left a comment

Choose a reason for hiding this comment

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

Could you provide tests?

container/podman/client.go Outdated Show resolved Hide resolved
container/podman/client.go Outdated Show resolved Hide resolved
container/podman/factory.go Outdated Show resolved Hide resolved
container/podman/factory.go Outdated Show resolved Hide resolved
container/podman/handler.go Outdated Show resolved Hide resolved
container/podman/podman.go Outdated Show resolved Hide resolved
info/v1/podman.go Outdated Show resolved Hide resolved
info/v1/podman.go Outdated Show resolved Hide resolved
container/podman/handler.go Outdated Show resolved Hide resolved
container/podman/factory.go Show resolved Hide resolved
@Creatone
Copy link
Collaborator

Creatone commented Feb 1, 2021

/ok-to-test

@towe75
Copy link
Author

towe75 commented Feb 1, 2021

@Creatone : thank you for having a look. I resolved most issues. Regarding tests: i will have a look but i wanted to learn if there is a general interest on a podman related PR before i put to much effort into into it.

@bobbypage
Copy link
Collaborator

/cc @mrunalp @haircommander since they may have some more experience with Podman.

@haircommander
Copy link
Contributor

code LGTM, as a note, you can probably scrape FS metrics the same way the crio handler does, as we share image and container storage.

@containers/podman-maintainers PTAL

@towe75
Copy link
Author

towe75 commented Feb 3, 2021

@haircommander : thank you for the FS hint! I will have a look but it will go into another PR.

@soinu
Copy link

soinu commented Feb 21, 2021

@containers/podman-maintainers PTAL

I hope it is okay to ping you, @mheon @rhatdan

@rhatdan
Copy link

rhatdan commented Feb 22, 2021

@soinu No problem, I love to see more users of Podman.

@rhatdan
Copy link

rhatdan commented Feb 22, 2021

@baude FYI

Copy link
Contributor

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

just some nits but LGTM

container/podman/factory.go Outdated Show resolved Hide resolved
for index, versionStr := range versionStringArray {
version, err := strconv.Atoi(versionStr)
if err != nil {
return nil, fmt.Errorf("error while parsing \"%v\" in \"%v\"", versionStr, versionString)
Copy link
Contributor

Choose a reason for hiding this comment

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

could it be %q instead of "%v"?

Copy link
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 docker/docker.go and boils IMHO down to a "\d+" match and thus could be multi-char string in case of a version segment greater "9". docker_test.go checks for this case and thus i think it's ok.

Refactoring this version parser stuff into a separate driver independent package would be a good idea.

Copy link
Collaborator

@iwankgb iwankgb left a comment

Choose a reason for hiding this comment

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

Take a look at my comments, please :)

container/podman/client.go Outdated Show resolved Hide resolved
container/podman/factory.go Outdated Show resolved Hide resolved
container/podman/factory.go Outdated Show resolved Hide resolved
container/podman/podman.go Outdated Show resolved Hide resolved
container/podman/client.go Outdated Show resolved Hide resolved
case context.DeadlineExceeded:
klog.Warningf("Timeout trying to communicate with podman during initialization, will retry")
default:
klog.V(5).Infof("Podman not connected: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is were you should call CancelFunc, I believe.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, use %w, please :)


switch err {
case context.DeadlineExceeded:
klog.Warningf("Timeout trying to communicate with podman during initialization, will retry")
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems to me that if we keep getting context timeout then the for loop will become an infinite one. You must define a condition that will break it at some point.

NumContainers int `json:"num_containers"`
}

type PodmanImage struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I might have missed it but I can't recall this struct being used. Is it needed?

return StatusWithContext(defaultContext())
}

func StatusWithContext(ctx context.Context) (v1.PodmanStatus, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this function must be exported? This is more general remark: there is substantial amount of exported function in podman package that do not seem to implement an interface and are not used anywhere outside of the package. Can you unexplored them? I would rather expect them to be exported on case-by-case basis when we clearly see a use case for them.


// Checks whether the podmanInfo reflects a valid docker setup, and returns it if it does, or an
// error otherwise.
func ValidateInfo() (*dockertypes.Info, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this function used?

@iwankgb
Copy link
Collaborator

iwankgb commented Mar 25, 2021

Oh, there are no tests in this PR at all. What is your testing strategy for this code?

@towe75
Copy link
Author

towe75 commented Apr 3, 2021

@iwankgb : thank you for the detailed review.

I am a bit surprised about the effort that is put into reviewing this code. But up to now nobody recognized that most of the plumbing/boilerplate code is copied from the docker support. Working on cadvisor is completely new to me but i did of course not start from scratch. I copied the docker package and ripped out all what i did not need for a very basic, barebones, podman support. So i guessed that this might be the kind of code/style that you want to have in this project.

Anyhow. I will certainly improve the code and i can add some tests, too. But i strongly recommend a re-review of the docker and maybe other packages if you want to enforce a certain coding style. Otherwise it's somewhat hard for contributors to learn about your teams expectations.

@iwankgb
Copy link
Collaborator

iwankgb commented Apr 3, 2021

@towe75 I hope that one day cAdvisor will be more consistent but it's next to impossible to achieve this when Kubernetes depends on us (imagine what happens when you want to make exported field names to match Go style). I don't think that we should not try to improve the project by scrutinising new code even if it's based on existing parts of the project :)

@towe75
Copy link
Author

towe75 commented Apr 3, 2021

@iwankgb : no worries. So maybe the podman package can become "the goto example" of how to support new container types ;-)

grouped some const() and var()
renamed Client() to NewClient()
@iwankgb
Copy link
Collaborator

iwankgb commented May 8, 2021

/retest

@giuseppe
Copy link
Contributor

@towe75 are you still working on this PR?

@towe75
Copy link
Author

towe75 commented Nov 29, 2021

@giuseppe : TBH no. I lost track of it and i don't have enough spare time recently. It was obviously a bad idea to clone older code from the docker support. We can as well close it and start from scratch on another day if there is some demand for it. Sorry.

@giuseppe
Copy link
Contributor

@giuseppe : TBH no. I lost track of it and i don't have enough spare time recently. It was obviously a bad idea to clone older code from the docker support. We can as well close it and start from scratch on another day if there is some demand for it. Sorry.

thanks for the update! I think cAdvisor support for Podman is still needed

@Creatone
Copy link
Collaborator

@giuseppe : TBH no. I lost track of it and i don't have enough spare time recently. It was obviously a bad idea to clone older code from the docker support. We can as well close it and start from scratch on another day if there is some demand for it. Sorry.

thanks for the update! I think cAdvisor support for Podman is still needed

So I would like to implement that!

@rhatdan
Copy link

rhatdan commented Nov 29, 2021

Go for it.

@Creatone
Copy link
Collaborator

Creatone commented Dec 1, 2021

Moved to #3021.

@Creatone Creatone closed this Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants