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

Implement Ready condition for Instance type #1706

Merged
merged 6 commits into from
Oct 9, 2020
Merged

Implement Ready condition for Instance type #1706

merged 6 commits into from
Oct 9, 2020

Conversation

alenkacz
Copy link
Contributor

@alenkacz alenkacz commented Oct 7, 2020

Signed-off-by: Alena Varkockova varkockova.a@gmail.com

What this PR does / why we need it:
This is an implementation of KEP-34. It adds Status.Conditions.Ready to an Instance while this property is being computed from the owned resources of certain types.

@alenkacz alenkacz force-pushed the av/readiness branch 6 times, most recently from 07dca3f to 952bf5e Compare October 7, 2020 10:14
@alenkacz alenkacz added this to the 0.17.0 milestone Oct 7, 2020
@alenkacz alenkacz changed the title WIP: Implement Ready condition for Instance type Implement Ready condition for Instance type Oct 7, 2020
@alenkacz alenkacz force-pushed the av/readiness branch 2 times, most recently from 3840d31 to 25329ed Compare October 7, 2020 10:55
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

This looks great already! Found some nits, but also have some questions around setting the "Unknown" state.

pkg/apis/kudo/v1beta1/instance_types_helpers.go Outdated Show resolved Hide resolved
pkg/apis/kudo/v1beta1/instance_types_helpers.go Outdated Show resolved Hide resolved
pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/kubernetes/status/readiness.go Outdated Show resolved Hide resolved
pkg/kubernetes/status/readiness.go Show resolved Hide resolved
Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

Good start, left a few comments and nits 👍

pkg/apis/kudo/v1beta1/instance_types_helpers.go Outdated Show resolved Hide resolved
pkg/apis/kudo/v1beta1/instance_types_helpers.go Outdated Show resolved Hide resolved
@@ -536,5 +560,6 @@ func scheduledPlan(i *kudoapi.Instance, ov *kudoapi.OperatorVersion) (string, ty
i.Spec.PlanExecution.Status = kudoapi.ExecutionNeverRun
}

i.SetReadinessUnknownForDeploy()
Copy link
Contributor

Choose a reason for hiding this comment

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

This func scheduledPlan was supposed to simply return the i.Spec.PlanExecution.PlanName. Now, scheduling a cleanup is already an ugly exception we need to make, but this method shouldn't update instance status.

// SetReadinessUnknownForDeploy sets an unknown state for Status.Conditions.Ready
// this will modify instance only when deploy, upgrade, update plan is running
func (i *Instance) SetReadinessUnknownForDeploy() {
if i.Spec.PlanExecution.PlanName == DeployPlanName || i.Spec.PlanExecution.PlanName == UpgradePlanName || i.Spec.PlanExecution.PlanName == UpdatePlanName {
Copy link
Contributor

Choose a reason for hiding this comment

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

This long if probably deserves a helper method of its own e.g. func IsDeployUpdateOrUpgradeScheduled or smth :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I am not sure :D I think long if vs long ugly name of method 🤷

pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/kubernetes/status/readiness.go Show resolved Hide resolved
pkg/kubernetes/status/readiness.go Outdated Show resolved Hide resolved
pkg/kubernetes/status/readiness.go Outdated Show resolved Hide resolved
@alenkacz alenkacz force-pushed the av/readiness branch 3 times, most recently from c5abe48 to 960385b Compare October 8, 2020 08:24
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

Almost there! Because I was just working on IsHealthy for #1707, I noticed something around readinessMessage that may need some changes.

pkg/controller/instance/instance_controller.go Outdated Show resolved Hide resolved
pkg/kubernetes/status/readiness.go Outdated Show resolved Hide resolved
pkg/apis/kudo/v1beta1/instance_types_helpers.go Outdated Show resolved Hide resolved
@@ -536,5 +563,8 @@ func scheduledPlan(i *kudoapi.Instance, ov *kudoapi.OperatorVersion) (string, ty
i.Spec.PlanExecution.Status = kudoapi.ExecutionNeverRun
}

if i.Spec.PlanExecution.PlanName == kudoapi.DeployPlanName || i.Spec.PlanExecution.PlanName == kudoapi.UpgradePlanName || i.Spec.PlanExecution.PlanName == kudoapi.UpdatePlanName {
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 not sure if we use these things somewhere else, but I wouldn't mind something like kudoapi.isDefaultPlan(planName) or similar...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah Aleksey wanted that as well I just don't know how to name it ... I am not sure default plan means something to me really. I don't want to do "IsDeployOrUpgradeOrUpdate" 🤷 so I ended up keeping this explicitly :/

@alenkacz alenkacz force-pushed the av/readiness branch 2 times, most recently from e45f8ac to 2a3e605 Compare October 8, 2020 10:57
@@ -536,5 +576,8 @@ func scheduledPlan(i *kudoapi.Instance, ov *kudoapi.OperatorVersion) (string, ty
i.Spec.PlanExecution.Status = kudoapi.ExecutionNeverRun
}

if i.Spec.PlanExecution.PlanName == kudoapi.DeployPlanName || i.Spec.PlanExecution.PlanName == kudoapi.UpgradePlanName || i.Spec.PlanExecution.PlanName == kudoapi.UpdatePlanName {
i.SetReadinessUnknown()
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, this "simple getter" (with an exception) shouldn't update Instance status as a side effect. Let's move this someplace else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how is this a getter if this method modifies Spec? :D

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant in this comment that this is an ugly but necessary side-effect that is at least about the plan name. Instance status modification is an even bigger one.

@alenkacz alenkacz force-pushed the av/readiness branch 2 times, most recently from 21e255d to c5a46b7 Compare October 8, 2020 11:55
Signed-off-by: Alena Varkockova <varkockova.a@gmail.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Copy link
Member

@nfnt nfnt left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@zen-dog zen-dog left a comment

Choose a reason for hiding this comment

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

One nit but otherwise lgtm 🚢

pkg/apis/kudo/v1beta1/instance_types_helpers.go Outdated Show resolved Hide resolved
Jan Schlicht and others added 4 commits October 8, 2020 16:26
Signed-off-by: Jan Schlicht <jan@d2iq.com>

Co-authored-by: Andreas Neumann <aneumann@mesosphere.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
Signed-off-by: Jan Schlicht <jan@d2iq.com>
@nfnt nfnt merged commit 7eefce1 into main Oct 9, 2020
@nfnt nfnt deleted the av/readiness branch October 9, 2020 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants