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

Add 'oc set probe' for setting readiness and liveness #7331

Merged
merged 1 commit into from
Feb 24, 2016

Conversation

smarterclayton
Copy link
Contributor

Adds a new helper which should be used for getting patches for
changes (can be abstracted further).

@spadgett FYI

Mapper meta.RESTMapper

PrintObject func(runtime.Object) error
UpdatePodSpecForObject func(runtime.Object, func(spec *kapi.PodSpec) error) (bool, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

please start typing these or this will become another Factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For a single use field the type doesn't make anything better less
understandable (I have to go find the method, add Godoc to it, etc). Also,
Factory isn't the wrong pattern - this is the simplest way to express a set
of common behaviors that multiple commands use that can be abstracted.
Passing the factory onto Options is definitely the wrong pattern.

On Tue, Feb 16, 2016 at 4:08 PM, David Eads notifications@github.com
wrote:

In pkg/cmd/cli/cmd/set/probe.go
#7331 (comment):

  • Filenames []string
  • ContainerSelector string
  • Selector string
  • All bool
  • Builder *resource.Builder
  • Infos []*resource.Info
  • Encoder runtime.Encoder
  • ShortOutput bool
  • Mapper meta.RESTMapper
  • PrintObject func(runtime.Object) error
  • UpdatePodSpecForObject func(runtime.Object, func(spec *kapi.PodSpec) error) (bool, error)

please start typing these or this will become another Factory.


Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/7331/files#r53078585.

Copy link
Contributor

Choose a reason for hiding this comment

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

Factory with a bunch of specialized function types that themselves end up being overridden by other things that just happen to know they want exactly the same shape of function without an named type makes rebasing and keeping the bits in sync very difficult. It has also make it nearly impossible to split the Factory apart into sub-chunks that have bits that we want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Splitting the factory isn't really worth it - seventeen different
interfaces being passed in 5 different shapes of interface holder objects
to a hundred commands is madness. Going from function pointers to
interfaces is a worthy goal, it just isn't on my list of "things that are
causing users or programmers problems"

On Wed, Feb 17, 2016 at 9:36 AM, David Eads notifications@github.com
wrote:

In pkg/cmd/cli/cmd/set/probe.go
#7331 (comment):

  • Filenames []string
  • ContainerSelector string
  • Selector string
  • All bool
  • Builder *resource.Builder
  • Infos []*resource.Info
  • Encoder runtime.Encoder
  • ShortOutput bool
  • Mapper meta.RESTMapper
  • PrintObject func(runtime.Object) error
  • UpdatePodSpecForObject func(runtime.Object, func(spec *kapi.PodSpec) error) (bool, error)

Factory with a bunch of specialized function types that themselves end up
being overridden by other things that just happen to know they want exactly
the same shape of function without an named type makes rebasing and keeping
the bits in sync very difficult. It has also make it nearly impossible to
split the Factory apart into sub-chunks that have bits that we want.


Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/7331/files#r53171584.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now using pointers instead of flag set.

On Wed, Feb 17, 2016 at 9:55 AM, Clayton Coleman ccoleman@redhat.com
wrote:

Splitting the factory isn't really worth it - seventeen different
interfaces being passed in 5 different shapes of interface holder objects
to a hundred commands is madness. Going from function pointers to
interfaces is a worthy goal, it just isn't on my list of "things that are
causing users or programmers problems"

On Wed, Feb 17, 2016 at 9:36 AM, David Eads notifications@github.com
wrote:

In pkg/cmd/cli/cmd/set/probe.go
#7331 (comment):

  • Filenames []string
  • ContainerSelector string
  • Selector string
  • All bool
  • Builder *resource.Builder
  • Infos []*resource.Info
  • Encoder runtime.Encoder
  • ShortOutput bool
  • Mapper meta.RESTMapper
  • PrintObject func(runtime.Object) error
  • UpdatePodSpecForObject func(runtime.Object, func(spec *kapi.PodSpec) error) (bool, error)

Factory with a bunch of specialized function types that themselves end up
being overridden by other things that just happen to know they want exactly
the same shape of function without an named type makes rebasing and keeping
the bits in sync very difficult. It has also make it nearly impossible to
split the Factory apart into sub-chunks that have bits that we want.


Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/7331/files#r53171584.

Copy link
Contributor

Choose a reason for hiding this comment

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

it just isn't on my list of "things that are
causing users or programmers problems"

Wait, I'm a programmer and it causes me problems on a rebase! Take the last one as a for instance. I spent hours chasing down the duplicate definitions of one logical type for a clientmapper function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, the interface stuff would help that (not opposed to that change). Am
opposed to splitting up factory or anything other than "Factory is a struct
{ interface1 interface2 interface3 }" which I still think is vulnerable to
the problem you describe.

On Wed, Feb 17, 2016 at 10:37 AM, David Eads notifications@github.com
wrote:

In pkg/cmd/cli/cmd/set/probe.go
#7331 (comment):

  • Filenames []string
  • ContainerSelector string
  • Selector string
  • All bool
  • Builder *resource.Builder
  • Infos []*resource.Info
  • Encoder runtime.Encoder
  • ShortOutput bool
  • Mapper meta.RESTMapper
  • PrintObject func(runtime.Object) error
  • UpdatePodSpecForObject func(runtime.Object, func(spec *kapi.PodSpec) error) (bool, error)

it just isn't on my list of "things that are
causing users or programmers problems"

Wait, I'm a programmer and it causes me problems on a rebase! Take the
last one as a for instance. I spent hours chasing down the duplicate
definitions of one logical type for a clientmapper function.


Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/7331/files#r53181031.

@smarterclayton
Copy link
Contributor Author

UI depends on kubernetes/kubernetes#21341

ContainerSelector: "*",
}
cmd := &cobra.Command{
Use: "probe RESOURCE/NAME [--readiness|--liveness] ...",
Copy link
Member

Choose a reason for hiding this comment

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

At least one of readiness or liveness are required, so it doesn't take brackets here: --readiness|--liveness.

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 suggest this usage line:

probe (RESOURCE/NAME | RESOURCE --all) --readiness|--liveness [--get-url=URL] [--open-tcp=PORT] [-- COMMAND]

Copy link
Member

Choose a reason for hiding this comment

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

In fact I just noticed in Validate that you can only set one of the probe rules, so it could actually be

probe (RESOURCE/NAME | RESOURCE --all) --readiness|--liveness (--unset | --get-url=URL | --open-tcp=PORT | -- COMMAND)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's probably too long to fit on a normal screen, but I'll check it

Copy link
Member

Choose a reason for hiding this comment

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

Probably. Resource arg can be just RESOURCE/NAME, we do that already in other commands even when they accept --all. If the rest fits it would be good, makes it pretty clear what options you have.

@smarterclayton smarterclayton force-pushed the implement_set_probe branch 2 times, most recently from e8ada65 to 5bfb4c4 Compare February 18, 2016 23:29
@smarterclayton
Copy link
Contributor Author

[test]

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 19, 2016
@smarterclayton smarterclayton force-pushed the implement_set_probe branch 2 times, most recently from 67f4062 to 1353b8c Compare February 19, 2016 22:34
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 19, 2016
@smarterclayton smarterclayton force-pushed the implement_set_probe branch 2 times, most recently from da22041 to 6e28ecf Compare February 20, 2016 06:12
@smarterclayton
Copy link
Contributor Author

https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/11465/console

FAILURE after 0.172s: hack/../test/cmd/basicresources.sh:195: executing 'oc new-project --token=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJjbWQtYmFzaWNyZXNvdXJjZXMiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlY3JldC5uYW1lIjoiYnVpbG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gW4v1kvcZyywzU9ufa3q0StVoSI1o-loy7VkzmxX4i9SexWymqK8KspywlqKp07p7K3JuIyF5vw2TV9U5TlBmn7tf5_qmiTOHwusTS6efJeaM-YeCIkj0-Y1buA3KdSObsvr-FKkHBliFr_xKpH_9sUUAOwXJ2RJBXXRWOXL45DZNARRkO-lgX_dD0zEOUptxEjzJZSrU770djqEdEri2QATF651xYDF4wfqKA will-fail' expecting failure and text 'Error from server: You may not request a new project via this API': the output content test failed
There was no output from the command.
Standard error from the command:
Error from server: the server has asked for the client to provide credentials
!!! Error in hack/../test/cmd/../../hack/cmd_util.sh:195
    'return 1' exited with status 1
Call stack:
    1: hack/../test/cmd/../../hack/cmd_util.sh:195 os::cmd::expect_failure_and_text(...)
    2: hack/../test/cmd/basicresources.sh:195 main(...)
Exiting with status 1

@smarterclayton
Copy link
Contributor Author

[test]

@smarterclayton
Copy link
Contributor Author

This is ready for final review @fabianofranz or @Kargakis

cmd.Flags().BoolVar(&options.All, "all", options.All, "Select all resources in the namespace of the specified resource types")
cmd.Flags().StringSliceVarP(&options.Filenames, "filename", "f", options.Filenames, "Filename, directory, or URL to file to use to edit the resource.")

cmd.Flags().BoolVar(&options.Remove, "remove", options.Remove, "If true, remove the specified probe(s).")
Copy link
Member

Choose a reason for hiding this comment

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

Add --remove-all like in triggers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are only two, so it didn't seem like we needed it. Triggers are a
list, this is more of a named struct.

On Sun, Feb 21, 2016 at 7:59 PM, Fabiano Franz notifications@github.com
wrote:

In pkg/cmd/cli/cmd/set/probe.go
#7331 (comment):

  •           // TODO: move met to kcmdutil
    
  •           if err == cmdutil.ErrExit {
    
  •               os.Exit(1)
    
  •           }
    
  •           kcmdutil.CheckErr(err)
    
  •       }
    
  •   },
    
  • }
  • kcmdutil.AddPrinterFlags(cmd)
  • cmd.Flags().StringVarP(&options.ContainerSelector, "containers", "c", options.ContainerSelector, "The names of containers in the selected pod templates to change - may use wildcards")
  • cmd.Flags().StringVarP(&options.Selector, "selector", "l", options.Selector, "Selector (label query) to filter on")
  • cmd.Flags().BoolVar(&options.All, "all", options.All, "Select all resources in the namespace of the specified resource types")
  • cmd.Flags().StringSliceVarP(&options.Filenames, "filename", "f", options.Filenames, "Filename, directory, or URL to file to use to edit the resource.")
  • cmd.Flags().BoolVar(&options.Remove, "remove", options.Remove, "If true, remove the specified probe(s).")

Add --remove-all like in triggers?


Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/7331/files#r53578238.

@fabianofranz
Copy link
Member

Minor comments but LGTM.

$ %[1]s probe dc/router --readiness --get-url=https://127.0.0.1:1936/stats

# Set only the initial-delay-seconds field on all deployments
$ %[1]s probe dc --all --readiness --initial-delay-seconds=30`
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW, most commands don't use --all and have the same effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to make requiring --all for any mutation command, and make that part of kubectl conventions. kubectl delete pods lacks specificity as to user intent, and for the other commands we are "safe" when someone does the simple thing, so we should be safe on mutation.

Copy link
Contributor

Choose a reason for hiding this comment

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

will this support 30s or 1m ? it always has to be seconds, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It has to be seconds because that's what the API supports. We could
support integer durations in the future, but practically this will always
be a number between 0 and 240

On Tue, Feb 23, 2016 at 8:05 AM, Michal Fojtik notifications@github.com
wrote:

In pkg/cmd/cli/cmd/set/probe.go
#7331 (comment):

  • $ %[1]s probe dc/registry --remove --readiness --liveness
  • Set an exec action as a liveness probe to run 'echo ok'

  • $ %[1]s probe dc/registry --liveness -- echo ok
  • Set a readiness probe to try to open a TCP socket on 3306

  • $ %[1]s probe rc/mysql --readiness --open-tcp=3306
  • Set an HTTP readiness probe for port 8080 and path /healthz over HTTP on the pod IP

  • $ %[1]s probe dc/webapp --readiness --get-url=http://:8080/healthz
  • Set an HTTP readiness probe over HTTPS on 127.0.0.1 for a hostNetwork pod

  • $ %[1]s probe dc/router --readiness --get-url=https://127.0.0.1:1936/stats
  • Set only the initial-delay-seconds field on all deployments

  • $ %[1]s probe dc --all --readiness --initial-delay-seconds=30`

will this support 30s or 1m ? it always has to be seconds, right?


Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/7331/files#r53776601.

@smarterclayton
Copy link
Contributor Author

Updated, PTAL

@smarterclayton
Copy link
Contributor Author

[test]

@smarterclayton
Copy link
Contributor Author

[test]

On Tue, Feb 23, 2016 at 7:30 AM, OpenShift Bot notifications@github.com
wrote:

continuous-integration/openshift-jenkins/test NOTFOUND (
https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/1507/)


Reply to this email directly or view it on GitHub
#7331 (comment).

@smarterclayton
Copy link
Contributor Author

Any other comments? Will merge at 11am EST otherwise

@0xmichalis
Copy link
Contributor

LGTM

Adds a new helper which should be used for getting patches for
changes (can be abstracted further).
@smarterclayton
Copy link
Contributor Author

[merge]

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/1558/) (Image: devenv-rhel7_3525)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to b2de291

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to b2de291

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/1558/)

openshift-bot pushed a commit that referenced this pull request Feb 24, 2016
@openshift-bot openshift-bot merged commit c1f0006 into openshift:master Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants