-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Cluster controller and types for v1alpha2 #1177
Conversation
[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 |
b7cbb5d
to
10ed36f
Compare
// or if any resources linked to this cluster aren't yet deleted. | ||
func (r *ReconcileCluster) isDeleteReady(ctx context.Context, cluster *v1alpha2.Cluster) error { | ||
// TODO(vincepri): List and delete MachineDeployments, MachineSets, Machines, and | ||
// block deletion until they're all deleted. |
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.
We probably do not need to actively delete (just yet) and can likely just start with blocking deletion while any Machine* objects linked to this Cluster exist.
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.
Would a user need to delete these before deleting the Cluster?
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.
Yes, but technically that is no different than the state of the world today 😂
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.
// field, akin to component config. | ||
// +optional | ||
Value *runtime.RawExtension `json:"value,omitempty"` | ||
InfrastructureRef *corev1.ObjectReference `json:"infrastructureRef,omitempty"` |
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.
Looks like this field is finally considered optional and not mandatory and set at creation time as it was discussed in the data model change proposal. I personally like this more.
The collaboration model between cluster controller and infrastructure controller was simplified and adapted to this assumption.
The initial proposal, however, considered it optional and possibly set after the cluster object was created.
For the sake of having a documentation for the infrastructure provider implementers, should we amend the proposal to reflect we are considering this field optional and how clusterphase
Pending
consider this case?
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 Cluster is going to be in Pending
phase if the infrastructure reference doesn't exist. I think that's fine for providers/users that don't want to use the Cluster for Infrastructure
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.
This is one of the reasons I was thinking we didn't strictly need a cluster-wide phase at this time, given that we only have 1 boolean (infra ready, or not).
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.
I don't mind either way, if we want to remove it we can do it later on or I can make the changes in this PR if needed
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.
I think it's a good idea to keep it for consistency and it gives end users a better experience.
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.
As I said in the data model proposal, I don't have any strong opinion about either option, even when I see value in having a consistent approach across controllers (machine, cluster). If we are keeping it, I would like to update the data model accordingly.
@vincepri as we are removing the actuator interface, we should also remove the test actuator and Edit: I volunteer for helping with tests, if needed |
@vincepri I think this PR also fixes https://github.com/kubernetes-sigs/cluster-api/issues/158 |
/test pull-cluster-api-integration |
This should be ready for an in-depth review and serve as a starting point @detiber @pablochacin |
/assign @ncdc |
bdde5f6
to
7180218
Compare
return err | ||
} | ||
|
||
if cluster.Status.InfrastructureReady || !infraConfig.GetDeletionTimestamp().IsZero() { |
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.
Should we split this and move the infra ready check up above the call to r.reconcileExternal?
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.
This looks fine to me, if we return early above then we don't reconcile the errors. I think the Machine reconcileBootstrap
method needs to be fixed as well
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.
What flow are you thinking about? Cluster infraReady=true, but something possibly has changed to cause reconcileExternal to fail?
84eefa4
to
95df206
Compare
|
||
if cluster.Spec.InfrastructureRef != nil { | ||
_, err := external.Get(r.Client, cluster.Spec.InfrastructureRef, cluster.Namespace) | ||
if err != nil && !apierrors.IsNotFound(err) { |
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.
If you wanted, this might look a little cleaner:
switch {
case apierrors.IsNotFound(err):
// This is what we want - no need to requeue
case err != nil:
return errors.Wrapf(...)
default: // or case err == nil
return requeue
}
gvk := cluster.GroupVersionKind() | ||
if err := r.Client.Patch(ctx, cluster, patchCluster); err != nil { | ||
klog.Errorf("Error Patching Cluster %q in namespace %q: %v", cluster.Name, cluster.Namespace, err) | ||
if reterr != nil { |
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.
I don't think reterr can ever be non-nil here?
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.
This is flipped, should have been == nil
proceeds to drink more coffee
cluster.SetGroupVersionKind(gvk) | ||
if err := r.Client.Status().Patch(ctx, cluster, patchCluster); err != nil { | ||
klog.Errorf("Error Patching Cluster status %q in namespace %q: %v", cluster.Name, cluster.Namespace, err) | ||
if reterr != nil { |
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.
If you return early if the main patch failed, then if we made it this far, reterr should still be nil, right?
return err | ||
} | ||
|
||
if cluster.Status.InfrastructureReady || !infraConfig.GetDeletionTimestamp().IsZero() { |
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.
What flow are you thinking about? Cluster infraReady=true, but something possibly has changed to cause reconcileExternal to fail?
@@ -106,29 +90,52 @@ type NetworkRanges struct { | |||
type ClusterStatus struct { | |||
// APIEndpoint represents the endpoint to communicate with the IP. | |||
// +optional | |||
APIEndpoints []APIEndpoint `json:"apiEndpoints,omitempty"` | |||
APIEndpoint APIEndpoint `json:"apiEndpoint,omitempty"` |
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 move from multiple to single endpoints?
For providers that don't have native load-balancers this would be the ideal place to retrieve a list of endpoints to load balance across (via client-side load balancing for example).
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 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.
I don't think a change in the data model was in scope for #1137 (outside of externalizing it), nor was it highlighted in the PR summary or proposal body - This should have been a separate PR and elicited more discussion and/or highlighted as a change in the proposal body.
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.
Can you open an issue to follow-up? Or PR to the current proposal? The change is small enough to be a follow-up to this PR
e8948d5
to
4af32da
Compare
@ncdc Good to merge? |
@vincepri I won't likely have any more review time today. Feel free to ask others or I can come back to it tomorrow. |
Signed-off-by: Vince Prignano <[email protected]>
Signed-off-by: Vince Prignano <[email protected]>
/lgtm Can do additional fixes in follow-ups as needed. |
/hold cancel |
Signed-off-by: Vince Prignano [email protected]
What this PR does / why we need it:
This PR is an implementation following the proposal outlined in #1137
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #833
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
Release note: