Skip to content

Commit

Permalink
Merge pull request #11417 from sbueringer/pr-improve-conneciton-probe
Browse files Browse the repository at this point in the history
🌱 Improve Cluster RemoteConnectionProbe condition
  • Loading branch information
k8s-ci-robot authored Nov 13, 2024
2 parents 7702621 + 156fd65 commit 5bd7ded
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 43 deletions.
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

0 comments on commit 5bd7ded

Please sign in to comment.