Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

🌱 Improve Cluster RemoteConnectionProbe condition #11417

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,10 @@ const (
ClusterRemoteConnectionProbeV1Beta2Condition = "RemoteConnectionProbe"

// ClusterRemoteConnectionProbeFailedV1Beta2Reason surfaces issues with the connection to the workload cluster.
ClusterRemoteConnectionProbeFailedV1Beta2Reason = "RemoteConnectionProbeFailed"
ClusterRemoteConnectionProbeFailedV1Beta2Reason = "ProbeFailed"

// ClusterRemoteConnectionProbeSucceededV1Beta2Reason is used to report a working connection with the workload cluster.
ClusterRemoteConnectionProbeSucceededV1Beta2Reason = "RemoteConnectionProbeSucceeded"
ClusterRemoteConnectionProbeSucceededV1Beta2Reason = "ProbeSucceeded"
)

// Cluster's ScalingUp condition and corresponding reasons that will be used in v1Beta2 API version.
Expand Down
10 changes: 3 additions & 7 deletions internal/controllers/cluster/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ const (
// deleteRequeueAfter is how long to wait before checking again to see if the cluster still has children during
// deletion.
deleteRequeueAfter = 5 * time.Second

// remoteConnectionProbeSucceededMessage is the message to be used when remote connection probe succeeded.
remoteConnectionProbeSucceededMessage = "Remote connection probe succeeded"
)

// Update permissions on /finalizers subresrouce is required on management clusters with 'OwnerReferencesPermissionEnforcement' plugin enabled.
Expand Down Expand Up @@ -203,10 +200,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (retRes ct
})
} else {
v1beta2conditions.Set(cluster, metav1.Condition{
Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.ClusterRemoteConnectionProbeSucceededV1Beta2Reason,
Message: remoteConnectionProbeSucceededMessage,
Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.ClusterRemoteConnectionProbeSucceededV1Beta2Reason,
})
}

Expand Down
29 changes: 0 additions & 29 deletions internal/controllers/cluster/cluster_controller_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -969,10 +969,6 @@ func setAvailableCondition(ctx context.Context, cluster *clusterv1.Cluster) {
overrideConditions = append(overrideConditions, *controlPlaneAvailableCondition)
}

if remoteConnectionProbeCondition := calculateRemoteConnectionProbeForSummary(cluster); remoteConnectionProbeCondition != nil {
overrideConditions = append(overrideConditions, *remoteConnectionProbeCondition)
}

if len(overrideConditions) > 0 {
summaryOpts = append(summaryOpts, overrideConditions)
}
Expand Down Expand Up @@ -1053,31 +1049,6 @@ func calculateControlPlaneAvailableForSummary(cluster *clusterv1.Cluster) *v1bet
}
}

func calculateRemoteConnectionProbeForSummary(cluster *clusterv1.Cluster) *v1beta2conditions.ConditionWithOwnerInfo {
remoteConnectionProbeCondition := v1beta2conditions.Get(cluster, clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition)
if remoteConnectionProbeCondition == nil {
return nil
}

message := remoteConnectionProbeCondition.Message
if remoteConnectionProbeCondition.Status == metav1.ConditionTrue && remoteConnectionProbeCondition.Message == remoteConnectionProbeSucceededMessage {
message = ""
}

return &v1beta2conditions.ConditionWithOwnerInfo{
OwnerResource: v1beta2conditions.ConditionOwnerInfo{
Kind: "Cluster",
Name: cluster.Name,
},
Condition: metav1.Condition{
Type: remoteConnectionProbeCondition.Type,
Status: remoteConnectionProbeCondition.Status,
Reason: remoteConnectionProbeCondition.Reason,
Message: message,
},
}
}

func aggregateUnhealthyMachines(machines collections.Machines) string {
if len(machines) == 0 {
return ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1980,7 +1980,7 @@ func TestSetAvailableCondition(t *testing.T) {
},
},
{
name: "Drops messages from InfraCluster and ControlPlane when using fallback to fields; drop message from RemoteConnectionProbe when true",
name: "Drops messages from InfraCluster and ControlPlane when using fallback to fields",
cluster: &clusterv1.Cluster{
ObjectMeta: metav1.ObjectMeta{
Name: "machine-test",
Expand Down Expand Up @@ -2013,10 +2013,9 @@ func TestSetAvailableCondition(t *testing.T) {
Reason: "Foo",
},
{
Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.ClusterRemoteConnectionProbeSucceededV1Beta2Reason,
Message: remoteConnectionProbeSucceededMessage,
Type: clusterv1.ClusterRemoteConnectionProbeV1Beta2Condition,
Status: metav1.ConditionTrue,
Reason: clusterv1.ClusterRemoteConnectionProbeSucceededV1Beta2Reason,
},
{
Type: clusterv1.ClusterDeletingV1Beta2Condition,
Expand Down