-
Notifications
You must be signed in to change notification settings - Fork 104
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
Waiting For a Plan to Finish #1461
Conversation
Signed-off-by: Ken Sipe <kensipe@gmail.com> working version Signed-off-by: Ken Sipe <kensipe@gmail.com>
…ackage Signed-off-by: Ken Sipe <kensipe@gmail.com>
Signed-off-by: Ken Sipe <kensipe@gmail.com>
I received some feedback questioning the newly added cli command
|
@kensipe This is solvable with the admission webhook as that already marks Instance into a state where it's apparent that a plan will be run and it does not have to wait for controller to see it. Potentially without webhook, using generation and/or version of instance could be a solution but the wait then would have to be something like |
Signed-off-by: Ken Sipe <kensipe@gmail.com>
we currently have a solution when a plan is triggered / update or upgrade... the issue mentioned is the inability to have this information if a plan is trigger and another user (or same user later in time) wants to wait... for which we don't have the knowledge of the previous instance at that time. |
just updated with a new wait on plan status... super cool IMO. The plan status keeps refreshing in place on the terminal until the plan is complete (if The plan status without wait works the same. With
This is harder to see in a static image... so I create a video to show it off. (this is the feature I always wanted!) https://drive.google.com/file/d/1xp-Eax1XtmAKp9eEtpaUnqDcFU8U5-Dj/view?usp=sharing |
return fmt.Errorf("OperatorVersion %s from instance %s/%s does not exist", instance.Spec.OperatorVersion.Name, ns, options.Instance) | ||
} | ||
// for loop breaks if Wait==false, or when active plan completes (or when user exits process) | ||
for { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of this logic is really complex and there's some great Go constructs for doing this nicely. I'd prefer we do this with channels and select, which was well-designed for this and can be a lot more clear. Check this out:
https://www.sohamkamani.com/golang/2018-06-17-golang-using-context-cancellation/
Put the logic into a goroutine that takes a channel, and then select over that and a time.After(options.WaitTime * time.Second). The goroutine can use a for loop with time.Sleep (and then breaks), but there's also time.Ticker depending on what you want to do.
I'm not sure how important this use case is. The initial issue #966 is the 80/20 use case: wait for the instance update (or triggered plan) to finish. Doing that with two commands is inconvenient but more importantly racy (as @alenkacz mentioned above). While "the plan status has the same issue in that if you do a plan status, it could be the "status" prior to the plan" statement is correct in itself, a Tech debt introduced by the original #966 PR is still present and I suspect that the users will run into raciness issues when using this command after updating instances and triggering plans. Additionally, it is debatable whether |
Now that we have There is a "raciness" from a cli perspective regarding There is NO tech debt on #966 however... the imagined race condition does not exist with one small exception... if there is an uninstall and a rapid re-install with the same instance name... it is possible that the stale state of the previous instance isn't clean up yet. It is also important to note... that unlike a manager race condition... there is no ill side-effect of a racy condition. There is the potential of a confused user and poor UX. For users that know what they are doing it is still a worthy feature. |
@anthonydahann a community member made the first PR to introduce
--wait
to install.As outlined in the issue #1418 there is a desire to move this code into a reusable space (not the CLI) with a request to add it into
kudoClient
. This enables the ability to use kudo as a library from terraform in particular for https://github.com/kudobuilder/terraform-provider-kudo.WaitForInstance
in kudo.go now provides this ability.After modifying
kudo install
to use this wait, it made sense to add await-timeout
for client control. This is super important as it is very unclear how long a plan will take to "finish".The challenge from a user perspective at that point is what if the
timeout
expired and you want to wait again... or what if you didn't wait but now you want to. It just made sense to addkudo plan wait
with await-time
as well. Thekudo plan wait
works for any plan... it will wait for whatever the active plan is to finish.To use this new feature:
New feature in plan submenu:
help for plan wait
Fixes #1418
Tagging @anthonydahanne in case he wanted to see this work