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 the --wait flag to install #966

Merged

Conversation

anthonydahanne
Copy link
Contributor

  • work in progress, not working yet
  • the idea to have the status call returns something is there, but I guess the "something" needs to be reworked

What this PR does / why we need it:
Attempt to solve #964

Fixes #964

@anthonydahanne
Copy link
Contributor Author

cc @gerred

return errors.Wrap(err, "getting plan status")
}
if status.Pending {
time.Sleep(2 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

couple notes over this block:

I would consider replacing this with a for + select, and have a few channels you're selecting on. This will enable you to add timeouts in a nice, clean way. Eventually we might want to move this out to some Waiter package/func/interface as well.

Also, I'd think we'd want some sort of timeout, even if it's high (10 minutes?).

Check out the select block here to see a bit of what I mean on that:

https://gobyexample.com/timeouts

Where this gets interesting (and maybe we pair on Monday) is you'd need some sort of goroutine-based retry for actually fetching the planStatus.

Copy link
Member

Choose a reason for hiding this comment

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

actually, nevermind, this handles the client in the way we want it to. So we may just want to separate out the display and the logic into two separate functions. If you want to try your hand at that...that'd be a great next step before we do any refactoring into channel-based logic.

@gerred
Copy link
Member

gerred commented Oct 24, 2019

Hey @anthonydahanne following up on this. :) Can I help you in any way?

@kensipe
Copy link
Member

kensipe commented Nov 20, 2019

@anthonydahanne could you rebase or merge latest master into this please? I'll work with you to get this merge in when we get on the latest. Thanks!!

@anthonydahanne
Copy link
Contributor Author

hello @kensipe: tried to rebase with my conference fried brain, so, yeah, not super confident.

Since I submitted, a new install.go class was created under another namespace, and that makes the usage of PlanStatus, that requires a Settings object, kind of complicated?

Once again, maybe I don't make sense, I haven't even tested locally since I could not find quickly the instructions to rebuild and run Kudo...

@gerred
Copy link
Member

gerred commented Jan 6, 2020

Hey @anthonydahanne - great seeing you at KubeCon. Want to pair to finish and merge this?

@kensipe
Copy link
Member

kensipe commented Mar 2, 2020

ping @anthonydahanne any interest in pairing or finishing this?

@anthonydahanne
Copy link
Contributor Author

hey there! sorry for late reply!
Yes I'd love to. Please let me refresh my memory and ping you back!

@kensipe
Copy link
Member

kensipe commented Mar 3, 2020

sweet!

@anthonydahanne
Copy link
Contributor Author

anthonydahanne commented Mar 7, 2020

all fine now!

having a quick look; I'm on master, I built the cli with make cli (I'm on Mac and using DockerForMac that comes with kubernetes 1.1.5.5 ) and when I do a

bin/kubectl-kudo init

the kudo-controller-manager is stuck on:

{"level":"info","ts":1583615409.944507,"logger":"entrypoint","msg":"KUDO Version: version.Info{GitVersion:\"0.7.2\", GitCommit:\"b48cef30\", BuildDate:\"2019-09-30T20:43:12Z\", GoVersion:\"go1.13.1\", Compiler:\"gc\", Platform:\"linux/amd64\"}"}
{"level":"info","ts":1583615409.9446228,"logger":"entrypoint","msg":"setting up manager"}
{"level":"info","ts":1583615410.3500917,"logger":"controller-runtime.metrics","msg":"metrics server is starting to listen","addr":":8080"}
{"level":"info","ts":1583615410.3505058,"logger":"entrypoint","msg":"Registering Components."}
{"level":"info","ts":1583615410.3505895,"logger":"entrypoint","msg":"setting up scheme"}
{"level":"info","ts":1583615410.3508122,"logger":"entrypoint","msg":"Setting up operator controller"}
{"level":"info","ts":1583615410.3512084,"logger":"controller-runtime.controller","msg":"Starting EventSource","controller":"operator","source":"kind source: /, Kind="}
{"level":"error","ts":1583615410.351352,"logger":"controller-runtime.source","msg":"if kind is a CRD, it should be installed before calling Start","kind":"Operator.kudo.dev","error":"no matches for kind \"Operator\" in version \"kudo.dev/v1alpha1\"","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\t/Users/kensipe/projects/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128\nsigs.k8s.io/controller-runtime/pkg/source.(*Kind).Start\n\t/Users/kensipe/projects/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.2.0/pkg/source/source.go:88\nsigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Watch\n\t/Users/kensipe/projects/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.2.0/pkg/internal/controller/controller.go:122\nsigs.k8s.io/controller-runtime/pkg/builder.(*Builder).doWatch\n\t/Users/kensipe/projects/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.2.0/pkg/builder/controller.go:162\nsigs.k8s.io/controller-runtime/pkg/builder.(*Builder).Build\n\t/Users/kensipe/projects/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.2.0/pkg/builder/controller.go:151\nsigs.k8s.io/controller-runtime/pkg/builder.(*Builder).Complete\n\t/Users/kensipe/projects/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.2.0/pkg/builder/controller.go:129\ngithub.com/kudobuilder/kudo/pkg/controller/operator.(*Reconciler).SetupWithManager\n\t/Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/pkg/controller/operator/operator_controller.go:39\nmain.main\n\t/Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/cmd/manager/main.go:60\nruntime.main\n\t/usr/local/Cellar/go/1.13.1/libexec/src/runtime/proc.go:203"}
{"level":"error","ts":1583615410.351561,"logger":"entrypoint","msg":"unable to register operator controller to the manager","error":"no matches for kind \"Operator\" in version \"kudo.dev/v1alpha1\"","stacktrace":"github.com/go-logr/zapr.(*zapLogger).Error\n\t/Users/kensipe/projects/go/pkg/mod/github.com/go-logr/zapr@v0.1.0/zapr.go:128\nmain.main\n\t/Users/kensipe/projects/go/src/github.com/kudobuilder/kudo/cmd/manager/main.go:62\nruntime.main\n\t/usr/local/Cellar/go/1.13.1/libexec/src/runtime/proc.go:203"}

@anthonydahanne
Copy link
Contributor Author

anthonydahanne commented Mar 7, 2020

ok! memory refreshed: there's a cycle because I want to use plan package from util/kudo package (I want to check on the Status; if it's empty, it means the install done and I can return, otherwise it's pending and I wait)

It's not necessary to rely on package

ERRO Running error: buildssa: analysis skipped: errors in package: [/Users/anthony/workspaces/kudo/pkg/kudoctl/cmd/plan/plan_history.go:14:2: could not import github.com/kudobuilder/kudo/pkg/kudoctl/env (pkg/kudoctl/cmd/get/get.go:10:2: import cycle not allowed: import stack: [github.com/kudobuilder/kudo/cmd/kubectl-kudo github.com/kudobuilder/kudo/pkg/kudoctl/cmd github.com/kudobuilder/kudo/pkg/kudoctl/cmd/get github.com/kudobuilder/kudo/pkg/kudoctl/env github.com/kudobuilder/kudo/pkg/kudoctl/util/kudo github.com/kudobuilder/kudo/pkg/kudoctl/cmd/plan github.com/kudobuilder/kudo/pkg/kudoctl/env]) /Users/anthony/workspaces/kudo/pkg/kudoctl/cmd/plan/plan_status.go:12:2: could not import github.com/kudobuilder/kudo/pkg/kudoctl/util/kudo (pkg/kudoctl/env/environment.go:11:2: import cycle not allowed: import stack: [github.com/kudobuilder/kudo/cmd/kubectl-kudo github.com/kudobuilder/kudo/pkg/kudoctl/cmd github.com/kudobuilder/kudo/pkg/kudoctl/cmd/get github.com/kudobuilder/kudo/pkg/kudoctl/env github.com/kudobuilder/kudo/pkg/kudoctl/util/kudo github.com/kudobuilder/kudo/pkg/kudoctl/cmd/plan github.com/kudobuilder/kudo/pkg/kudoctl/util/kudo]) -: could not load export data: dependency "github.com/kudobuilder/kudo/pkg/kudoctl/util/kudo" hasn't been loaded yet]

Please hit me up on Slack!

* get the status of the current plan, until it is completed then return

Signed-off-by: Anthony Dahanne <anthony.dahanne@gmail.com>
@anthonydahanne anthonydahanne marked this pull request as ready for review March 10, 2020 13:28
@@ -63,6 +64,26 @@ func InstallPackage(kc *Client, resources *packages.Resources, skipInstance bool
if _, err := kc.InstallInstanceObjToCluster(resources.Instance, namespace); err != nil {
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 I would rather the logic for this "wait" to be included in the client so that people using the client to install can leverage this. Eventually we would have the update call also have a "wait" option

Copy link
Member

Choose a reason for hiding this comment

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

I had to add my own "wait" function in the TF provider since there wasn't one in the client. Adding this wait like you've done won't let me eliminate the wait I have:

https://github.com/runyontr/terraform-provider-kudo/blob/master/kudo/resource_kudo_instance.go#L547-L576

@kensipe
Copy link
Member

kensipe commented Mar 10, 2020

This can be tough on a new community contribution but there has been some evolution of thought here which sets a new acceptance criteria. I am willing to merge this as a good starting point and thank you for the contribution! Or we can see the full impl on this PR.

Here is what we are looking to do with this:

  1. we need wait for more than just install. So we should have a separate function for wait on a plan.
  2. the wait should be part of the kudo.Client allowing it to be used as a lib... for instance for terraform
  3. It is likely we need to change the timeout for waits (I was initially thinking timeout was defined when acquiring a kudo.Client but I can see wait requiring it for each invocation.
  4. the wait should work for an update, the code for terraform provide is a good start: https://github.com/runyontr/terraform-provider-kudo/blob/master/kudo/resource_kudo_instance.go#L547-L576. however it doesn't work well for update. It needs to check the meta.generation to verify that the plan actually started. Without the meta.generation it is possible that the "last plan" is "finished" and that is the wait func view of the world... which is incorrect.

To narrow the scope... we are not looking for wait to work with upgrade and update... just that the solution should have that in mind and provide a solution that can be leveraged.

@kensipe kensipe self-assigned this Mar 10, 2020
@kensipe
Copy link
Member

kensipe commented Mar 10, 2020

The assign at this point (to me) is as a shepard to @anthonydahanne

@kensipe
Copy link
Member

kensipe commented Mar 10, 2020

The plan for this now after talking with anthony is to merge this in (with the value it brings) and take ownership of the new scope listed ^^. I want to hold until after the 0.11.0 release which is scheduled for tomorrow.

@kensipe kensipe added this to the 0.12.0 milestone Mar 10, 2020
@kensipe kensipe mentioned this pull request Mar 11, 2020
Copy link
Member

@kensipe kensipe left a comment

Choose a reason for hiding this comment

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

lgtm for the initial commit. Follow on work has been identified in Issue #1418

@kensipe kensipe merged commit 451d5c4 into kudobuilder:master Mar 11, 2020
@kensipe kensipe added this to Done in KUDO Global via automation Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
KUDO Global
  
Done
Development

Successfully merging this pull request may close these issues.

Support "kudo install $operator --wait"
5 participants