-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🌱 Add conditions for deletion workflows #3527
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 conditions for deletion workflows #3527
Conversation
controllers/cluster_controller.go
Outdated
@@ -162,6 +154,28 @@ func (r *ClusterReconciler) Reconcile(req ctrl.Request) (_ ctrl.Result, reterr e | |||
return r.reconcile(ctx, cluster) | |||
} | |||
|
|||
func patchCluster(patchHelper *patch.Helper, ctx context.Context, cluster *clusterv1.Cluster, options ...patch.Option) error { |
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.
The Patch operation is becoming really verbose so I moved it to a separate func designed to be used also for issuing patches in the middle of the reconcile loop, if necessary
The same change applies to all the controllers
58c7e01
to
d7a925e
Compare
conditions.SetSummary(kcp, | ||
conditions.WithConditions( | ||
controlplanev1.MachinesSpecUpToDateCondition, | ||
controlplanev1.ResizedCondition, | ||
controlplanev1.MachinesReadyCondition, | ||
controlplanev1.AvailableCondition, | ||
controlplanev1.CertificatesAvailableCondition, | ||
), | ||
) | ||
|
||
// Patch the object, ignoring conflicts on the conditions owned by this controller. | ||
return patchHelper.Patch( | ||
ctx, | ||
kcp, | ||
patch.WithOwnedConditions{Conditions: []clusterv1.ConditionType{ | ||
clusterv1.ReadyCondition, | ||
controlplanev1.MachinesSpecUpToDateCondition, | ||
controlplanev1.ResizedCondition, | ||
controlplanev1.MachinesReadyCondition, | ||
controlplanev1.AvailableCondition, | ||
controlplanev1.CertificatesAvailableCondition, | ||
}}, | ||
) |
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.
Seems there is a lot of repetition here, is there a way we could have a conditions.Owned
method when doing the SetSummary
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.
There is a repetition between Summary and Owned conditions, but they are not the same.
However I agree there is a pattern that repeats across controllers, so this is probably something we can address within the context of #3517
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.
Why do we need owned conditions here? I guess this is actually going to be solved once we get server side apply in place
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.
Owned conditions are required to avoid reconcile conflicts that can happen due to stale reads or to patch issued in the middle of a reconcile loop.
With server-side apply some of these problems a going away, but I'm not sure all of them.
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.
Sounds good, let's revisit later, I'm not 100% sure this is the direction we want to go long term, but seems fine for now
/hold |
d7a925e
to
fc03fea
Compare
/hold cancel |
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.
Overall, this looks great, just a few minor questions/suggestions.
test/infrastructure/docker/controllers/dockermachine_controller.go
Outdated
Show resolved
Hide resolved
test/infrastructure/docker/controllers/dockermachine_controller.go
Outdated
Show resolved
Hide resolved
/milestone v0.3.9 |
cbe146a
to
cc8e664
Compare
lgtm pending squash |
cc8e664
to
f6441cb
Compare
/test pull-cluster-api-e2e |
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.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: vincepri 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 |
/milestone v0.3.9 |
c4427be
to
061583b
Compare
squashed commits |
/test pull-cluster-api-test |
/assign @CecileRobertMichon |
/lgtm |
What this PR does / why we need it:
This PR adds conditions for providing evidence of the delete workflow for CAPI* and CAPD
*experimental objects are not included in this PR
Which issue(s) this PR fixes:
Fixes #3383