-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Initial podman support #2794
Conversation
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 What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
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 Once the patch is verified, the new status will be reflected by the 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. |
@googlebot I signed it! |
There was a problem hiding this 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?
/ok-to-test |
@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. |
/cc @mrunalp @haircommander since they may have some more experience with Podman. |
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 |
@haircommander : thank you for the FS hint! I will have a look but it will go into another PR. |
@soinu No problem, I love to see more users of Podman. |
@baude FYI |
There was a problem hiding this 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/podman.go
Outdated
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) |
There was a problem hiding this comment.
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"?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 :)
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
Oh, there are no tests in this PR at all. What is your testing strategy for this code? |
@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. |
@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 :) |
@iwankgb : no worries. So maybe the podman package can become "the goto example" of how to support new container types ;-) |
/retest |
@towe75 are you still working on this PR? |
@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! |
Go for it. |
Moved to #3021. |
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