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

Allow podman wait to wait on healthy state #13627

Closed
svenstaro opened this issue Mar 23, 2022 · 40 comments
Closed

Allow podman wait to wait on healthy state #13627

svenstaro opened this issue Mar 23, 2022 · 40 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. needs-design-doc

Comments

@svenstaro
Copy link

/kind feature

Description

I'd like for podman wait to be able to wait until a container is healthy. Currently we are using an external blocking command that's exactly the same as the health command and I think this could be made to be more elegant. This scenario crops up if starting a container in detached mode for integration testing, for instance.

I think this might be easy to add considering podman is already internally aware of the health state. I know that podman wait has the tag line "Block until one or more containers stop and then print their exit codes." but why limit it to just that?

Steps to reproduce the issue:

  1. podman wait --condition healthy

Describe the results you received:

Currently this is not supported.

Describe the results you expected:

Would be great if podman wait could block until the container is considered healthy.

@openshift-ci openshift-ci bot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 23, 2022
@rhatdan
Copy link
Member

rhatdan commented Mar 24, 2022

@vrothberg @baude @mheon Thoughts?

@vrothberg
Copy link
Member

I like the idea, thanks for proposing

@keonchennl
Copy link

May I work on this?

@rhatdan
Copy link
Member

rhatdan commented Mar 26, 2022

Sure

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@svenstaro
Copy link
Author

@keonchennl Did you get some work done on this?

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented May 27, 2022

@vrothberg care to take this over if you have time or hand it to an intern?

@vrothberg vrothberg assigned vrothberg and unassigned keonchennl May 27, 2022
@vrothberg
Copy link
Member

Sure, I can take a look.

@vrothberg
Copy link
Member

@mheon, are you cool if I add new container states (ContainerStatus{Healthy,Unhealthy})?

Unfortunately, the (remote) API uses []define.ContainerStatus for the waiting conditions instead of strings. Without breaking the API or ugly workarounds, I don't see another way.

@vrothberg
Copy link
Member

@mheon ping

@mheon
Copy link
Member

mheon commented Jun 8, 2022

Github somehow ate my response. Copying and pasting:

Feels like a bad idea, we'd be enshrining a hack into the API and forcing us to support it for the foreseeable future. Maybe add an extra bool flag for "Healthy" state, so we can wait on ContainerStateRunning and Healthy=true?

@vrothberg
Copy link
Member

Feels like a bad idea, we'd be enshrining a hack into the API and forcing us to support it for the foreseeable future. Maybe add an extra bool flag for "Healthy" state, so we can wait on ContainerStateRunning and Healthy=true?

Not sure how to do that without breaking the (remote) API and the bindings:

type WaitOptions struct {                 
        Condition []define.ContainerStatus
        Interval  time.Duration           
        Latest    bool                    
}                                         

@vrothberg vrothberg removed their assignment Jun 16, 2022
@vrothberg
Copy link
Member

@rhatdan I am freeing this for interns since I'll be on PTO next week but let's first discuss what needs to be done before re-assigning it.

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@svenstaro
Copy link
Author

I still have interest in getting this feature request filled and there seemed to be some interest from upstream to implement it.

@rhatdan
Copy link
Member

rhatdan commented Jul 17, 2022

@ashley-cui @vrothberg @mheon @umohnani8 Something for interns?

@vrothberg
Copy link
Member

Maybe but it must be groomed/designed. There is also a request to support restart policies (i.e., restart when unhealthy) which would be considered.

@mheon
Copy link
Member

mheon commented Sep 30, 2022

IMO: Add a Healthy bool to the existing struct (or create a new, separate array just of strings, to allow more versatile argument passing), and allow that to be set instead of the existing conditions array. That allows us to not make a breaking change, but support new functionality.

@rhatdan
Copy link
Member

rhatdan commented Oct 1, 2022

Seems like we would have three states, unkown, healthy and unhealthy. So I don't think a bool would work

@mheon
Copy link
Member

mheon commented Oct 11, 2022 via email

@svenstaro
Copy link
Author

Has there been any movement on this?

@rhatdan
Copy link
Member

rhatdan commented Apr 17, 2023

Not that I am aware of, interested in opening a PR?

@svenstaro
Copy link
Author

There seems to have been some back and forth on the design of this and until that's decided on ideally by the project, I think a PR would likely not get merged.

@rhatdan
Copy link
Member

rhatdan commented Apr 17, 2023

I think if you opened a PR matching what @mheon suggested it would be more likely to get merged.

@vrothberg
Copy link
Member

I'm no fan of adding a single boolean since it allows for only one state but I think we need means to further extend the wait endpoint to handle more conditions.

Currently, the endpoint uses define.ContainerStatus which @mheon does not want to extend with non-status conditions (e.g., health):

type WaitOptions struct {                 
        Condition []define.ContainerStatus
        Interval  time.Duration           
        Latest    bool                    
}                                         

Hence, I think we should add a new field Conditions []string:

type WaitOptions struct {                 
        // Condition is deprecated, please use the `Conditions` field instead.
        Condition []define.ContainerStatus
        // ...
        Conditions []string
        Interval  time.Duration           
        Latest    bool                    
}  

The untyped string can be easier dealt with and extended.

Since this is blocking #6160, I'd like to push things forward.

@Luap99 @mheon @rhatdan WDYT?

@Luap99
Copy link
Member

Luap99 commented Jun 19, 2023

Adding a new field sounds good to me.

@danishprakash
Copy link
Contributor

@vrothberg are you still looking into this?

@vrothberg
Copy link
Member

Yes, currently waiting for feedback from more maintainers. Once the design is agreed on, we can implement it.

@mheon
Copy link
Member

mheon commented Jun 20, 2023

Adding a new field SGTM. Was thinking we wouldn't deprecate the old one, but I suppose it doesn't make sense to have two separate ways of requesting conditions, so I won't argue.

@vrothberg vrothberg self-assigned this Jun 22, 2023
@vrothberg
Copy link
Member

Great, I'll take a stab at it.

@vrothberg
Copy link
Member

Opened #18974

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. needs-design-doc
Projects
None yet
Development

No branches or pull requests

7 participants