Skip to content

Conversation

@rhatdan
Copy link
Member

@rhatdan rhatdan commented Apr 24, 2019

We should support ',' separated lists of descriptors and ignore any ps options
handed to us. This will make it easier to convert from Docker to Podman.

Signed-off-by: Daniel J Walsh [email protected]

We should support ',' separated lists of descriptors and ignore any ps options
handed to us.  This will make it easier to convert from Docker to Podman.

Signed-off-by: Daniel J Walsh <[email protected]>
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan

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

The pull request process is described here

Details 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

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S labels Apr 24, 2019
markFlagHiddenForRemoteClient("latest", flags)
}

func genDescriptors(args []string) []string {
Copy link
Member

Choose a reason for hiding this comment

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

Uh. Do we really want to do this? Some of those options do things...

Might be safer to add -e and -o as NOOPs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Docker supports a bunch that we do not. I think we should just ignore for now, and then let @vrothberg work on a better solution in the long run.

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically Docker allows you to pass any option that the ps command supports.

Copy link
Member

Choose a reason for hiding this comment

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

-o might actually be a good idea to implement as its own flag - it specifies that format specifiers will follow in comma-separated format, so different than our default.

Potential problem: I don't know if Cobra allows mixing flags with arguments and flags without for single-character flags, so -eo might not work together.

-e is a NO-OP with our current implementation, we always do what it specifies.

Copy link
Member

Choose a reason for hiding this comment

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

Huh. Cobra does allow it.
podman run --rm -tiv /tmp:/tmp:rw fedora bash works

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I know, we have different options in podman top, I am just trying to make sure we can handle basic docker top commands but still support our own versions.

Copy link
Member Author

Choose a reason for hiding this comment

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

We are more lax about the syntax and not tied to the way the ps command handles it.

Copy link
Member

Choose a reason for hiding this comment

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

We can pretty easily implement -o as a flag that supports comma-separated format specifiers, though

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sure,but I think Docker might require the ps command inside of the container. We do not since @vrothberg wrote a native go implementation psgo.

https://github.com/containers/psgo

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't have to, this patch allows that syntax.

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

I am not a big fan of trying to emulate the ps flags other than the descriptors. That was the trade-off we made (and agreed on) when using the c/psgo library.

Considering https://bugzilla.redhat.com/show_bug.cgi?id=1702787 the sacrifice of using psgo is incompatibility with ps flags (the descriptors are 100% compatible). Now, just ignoring the flags will make the BZ work again but others will still fail (see ps -e vs ps -ef) which makes me believe this PR is a symptomatic fix for one specific bug, so I don't feel comfortable merging it. I'd rather prefer to continue be incompatible than giving a false impression of compatibility.

My question is: are we suddenly considering the CLI-incompatibility to be a bug? If users want to use ps they can still podman exec $CTR ps ..., which is what docker is doing behind the docker-top.

If we consider it a bug now, I'd still object the PR as it's a symptomatic fix and may cause follow-up issues: "ps -eo a,b,c" works but "ps -ef" doesn't return what I expect. I'd prefer extending c/psgo so that other users can benefit as well. Warning: looking at man ps, I really don't think we should go this path as we will end up implementing the entire ps CLI which looks like a scary rabbit hole and does not seem worth investing time in. I suggest we first attempt to parse the user-input and fall-back to execing ps in the container.

My preference is asking users to use podman/docker exec ... ps ... but I understand that doesn't count as a drop-in-replacement.

(background for the record)
The reason why we implemented c/psgo is because ps does not allow for parsing its output as entries are separated with whitespaces only breaking all kinds of heuristics to turn the ps output into a tabular format. Then we added all kinds of improvements on-top as psgo knows about namespaces (and hence about a ~container). This will not help users expecting podman-top and docker-top to be identical, but podman-top could return everything as a json to make it even simpler to parse.

@rhatdan
Copy link
Member Author

rhatdan commented Apr 25, 2019

@vrothberg how about we just add support for the "," separated list of descriptors as well as the " " separated?

@vrothberg
Copy link
Member

vrothberg commented Apr 25, 2019

@vrothberg how about we just add support for the "," separated list of descriptors as well as the " " separated?

Sure, this could be done in top.go. Currently we just pass the args around but could check for a comma and split if necessary.

@vrothberg
Copy link
Member

@rhatdan, we can also cheat and make psgo return a typed parsing error. If that's the case, we exec ps. But I leave that decision up to you as it feels a bit magical to me.

@rhatdan
Copy link
Member Author

rhatdan commented Apr 25, 2019

No I don't want this leaking into psgo.

@vrothberg
Copy link
Member

No I don't want this leaking into psgo.

The only change to psgo would be to return a typed error to know if it couldn't parse the input. Everything else must be handled by users of psgo.

@rhatdan
Copy link
Member Author

rhatdan commented Apr 25, 2019

Ok that works for me.

@vrothberg
Copy link
Member

🙊 ... we already have that https://github.com/containers/psgo/blob/master/psgo.go#L108.

if errors.Cause(err) == psgo.ErrUnkownDescriptor {
   container.Exec("ps", args...)
}

Will still change the typo in psgo s/ErrUnkownDescriptor/ErrUnkNownDescriptor/

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #3014) made this pull request unmergeable. Please resolve the merge conflicts.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 26, 2019
@openshift-ci-robot
Copy link
Collaborator

@rhatdan: PR needs rebase.

Details

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.

@rhatdan
Copy link
Member Author

rhatdan commented Apr 29, 2019

Closed since we will use @vrothberg PR

@rhatdan rhatdan closed this Apr 29, 2019
@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 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants