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

Make the healthcheck flags compatible with Docker CLI #3508

Merged
merged 3 commits into from Jul 16, 2019
Merged

Make the healthcheck flags compatible with Docker CLI #3508

merged 3 commits into from Jul 16, 2019

Conversation

csomh
Copy link
Contributor

@csomh csomh commented Jul 8, 2019

Docker CLI calls the healthcheck flags --health-*, instead of
--healthcheck-*. Introduce the former, in order to keep compatibility,
and alias the later, in order to avoid breaking current usage.

See discussion on #3455.

@openshift-ci-robot
Copy link
Collaborator

Hi @csomh. Thanks for your PR.

I'm waiting for a containers or openshift 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.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 8, 2019
createFlags.String(
"health-cmd", "",
"set a healthcheck command for the container ('none' disables the existing healthcheck)",
)
createFlags.String(
"healthcheck-command", "",
Copy link
Member

Choose a reason for hiding this comment

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

I think Cobra allows aliases for flags - it'd be better to add these as aliases to the existing flags, not entirely new ones

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you point me to some docs, please? I've looked but could not find anything. This is why I've followed the same pattern that was used for the --net, --network pair.

(Cobra allows shorthands, as in --publish, -p with StringP, but that's not what is needed in this case.)

Copy link
Member

Choose a reason for hiding this comment

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

I'm almost certain we used this somewhere... Let me poke around

Copy link
Member

Choose a reason for hiding this comment

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

I might have been thinking of urfave/cli instead, which AFAIK allowed arbitrary numbers of flag aliases. Which, in cases like this, was a good bit more convenient...

@mheon
Copy link
Member

mheon commented Jul 8, 2019

/ok-to-test
/approve

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 8, 2019
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: csomh, mheon

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

The pull request process is described 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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 8, 2019
@@ -91,7 +91,11 @@ func CreateContainer(ctx context.Context, c *GenericCLIResults, runtime *libpod.

var healthCheckCommandInput string
// if the user disabled the healthcheck with "none", we skip adding it
healthCheckCommandInput = c.String("healthcheck-command")
healthCheckCommandInput = c.String("health-cmd")
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer we error here if both are set, instead of unconditionally overwriting

@rh-atomic-bot
Copy link
Collaborator

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

@rhatdan
Copy link
Member

rhatdan commented Jul 8, 2019

Inside of cobra they explain how to do this.

Example #2: You want to alias two flags. aka --old-flag-name == --new-flag-name

func aliasNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
	switch name {
	case "old-flag-name":
		name = "new-flag-name"
		break
	}
	return pflag.NormalizedName(name)
}

myFlagSet.SetNormalizeFunc(aliasNormalizeFunc)

@csomh
Copy link
Contributor Author

csomh commented Jul 9, 2019

Thanks @rhatdan! That's what I was looking for.

I've updated the PR to use aliases instead.

Varlink and GenericCLIResults were not changed, but I'm not entirely confident, that I understand those parts correctly, so let me know if those also need a change.

docs/podman-create.1.md Outdated Show resolved Hide resolved
docs/podman-run.1.md Outdated Show resolved Hide resolved
@mheon
Copy link
Member

mheon commented Jul 9, 2019

Slight touchups needed on the manpages, otherwise LGTM

@mheon
Copy link
Member

mheon commented Jul 10, 2019

@csomh Mind rebasing? There are fixes for test failures on master

@csomh
Copy link
Contributor Author

csomh commented Jul 10, 2019

@mheon some are still failing. Would it make sense to rebase onto the latest green commit instead?

@mheon
Copy link
Member

mheon commented Jul 10, 2019

Checking, let me see if we're looking at flakes or real failures

@mheon
Copy link
Member

mheon commented Jul 10, 2019

[+2083s] panic: unable to find generic flag for varlink health-cmd
[+2083s] 
[+2083s] goroutine 1 [running]:
[+2083s] github.com/containers/libpod/cmd/podman/shared.GenericCLIResults.Find(...)
[+2083s] 	cmd/podman/shared/intermediate_varlink.go:433
[+2083s] github.com/containers/libpod/cmd/podman/shared.GenericCLIResults.MakeVarlink(0xc000390330, 0xc0003fd770, 0x2, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
[+2083s] 	cmd/podman/shared/intermediate_varlink.go:107 +0x64b1
[+2083s] github.com/containers/libpod/pkg/adapter.(*LocalRuntime).Run(0xc0000ae048, 0x1a709a0, 0xc0000aa018, 0x2a07080, 0x7d, 0x0, 0x0, 0x0)
[+2083s] 	pkg/adapter/containers_remote.go:463 +0x77
[+2083s] main.runCmd(0x2a07080, 0x0, 0x0)
[+2083s] 	cmd/podman/run.go:60 +0x164
[+2083s] main.glob..func29(0x29a4180, 0xc0003fd770, 0x2, 0x3, 0x0, 0x0)
[+2083s] 	cmd/podman/run.go:23 +0x86
[+2083s] github.com/containers/libpod/vendor/github.com/spf13/cobra.(*Command).execute(0x29a4180, 0xc0000b4020, 0x3, 0x3, 0x29a4180, 0xc0000b4020)
[+2083s] 	vendor/github.com/spf13/cobra/command.go:826 +0x465
[+2083s] github.com/containers/libpod/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0x29a9900, 0xc00009ccf0, 0x7fffb074ded9, 0x3e)
[+2083s] 	vendor/github.com/spf13/cobra/command.go:914 +0x2fc
[+2083s] github.com/containers/libpod/vendor/github.com/spf13/cobra.(*Command).Execute(...)
[+2083s] 	vendor/github.com/spf13/cobra/command.go:864
[+2083s] main.main()
[+2083s] 	cmd/podman/main.go:147 +0x88

@mheon
Copy link
Member

mheon commented Jul 10, 2019

I think we might have a real panic here

@csomh
Copy link
Contributor Author

csomh commented Jul 10, 2019

Of course we had... un-did the changes in MakeVarlink().

@mheon
Copy link
Member

mheon commented Jul 10, 2019

Last failure looks like a flake, restarted

@rhatdan
Copy link
Member

rhatdan commented Jul 12, 2019

Command completions in contrib/bash/podman also need to be updated.

@csomh
Copy link
Contributor Author

csomh commented Jul 13, 2019

Do you mean completions/bash/podman?

--health-start-period was added to that one (the other --health-* flags were already there), and --no-healthcheck removed, as it's currently not an option in podman (--health-cmd=none might mean the same 😕)

I did not update completion with the --healhtcheck-* variants, as I think this would make completing --health confusing (would bring up both variants, users might be confused which one to use), and might lead to users crafting incompatible commands as a result.

Let me know if you think otherwise.

@@ -268,26 +268,26 @@ The following example maps uids 0-2000 in the container to the uids 30000-31999

Add additional groups to run as

**--healthcheck-command**=*command*
**--health-cmd**, **--healthcheck-command**=*command*
Copy link
Member

Choose a reason for hiding this comment

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

Can you just remove the old options, they should be gone now from --help, so no reason to document, as long as people using the old option continue to work, we don't need to document.

@rhatdan
Copy link
Member

rhatdan commented Jul 13, 2019

Good on the completions. I agree on not exposing --healthcheck* at all.

Bottom line is remove it from being exposed anywhere but support it if a user used it within a script.

@csomh
Copy link
Contributor Author

csomh commented Jul 14, 2019

Removed --healthcheck-* from the docs and updated all the tests to use the documented flags.

@csomh
Copy link
Contributor Author

csomh commented Jul 15, 2019

/retest

@rh-atomic-bot
Copy link
Collaborator

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

Hunor Csomortáni added 3 commits July 16, 2019 05:50
Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
Docker CLI calls the healthcheck flags "--health-*", instead of
"--healthcheck-*".

Introduce the former, in order to keep compatibility, and alias
the later, in order to avoid breaking current usage.

Change "--healthcheck-*" to "--health-*" in the docs and tests.

Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
Signed-off-by: Hunor Csomortáni <csomh@redhat.com>
@csomh
Copy link
Contributor Author

csomh commented Jul 16, 2019

/retest

@csomh
Copy link
Contributor Author

csomh commented Jul 16, 2019

@rhatdan @mheon could you please help me to re-run the failing tests? They don't seem to be related to the changes made. Prow does not seem to listen to my commands. Thanks!

@mheon
Copy link
Member

mheon commented Jul 16, 2019

Restarted them both - looked like known flakes

@rhatdan
Copy link
Member

rhatdan commented Jul 16, 2019

@TomSweeneyRedHat
Copy link
Member

LGTM and happy green test buttons. TYVM @csomh !

@mheon
Copy link
Member

mheon commented Jul 16, 2019

Merging
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 16, 2019
@openshift-merge-robot openshift-merge-robot merged commit 400851a into containers:master Jul 16, 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. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants