Skip to content

Commit

Permalink
Improve Cluster RemoteConnectionProbe condition
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Büringer [email protected]
  • Loading branch information
sbueringer committed Nov 13, 2024
1 parent 1cd1543 commit aa55734
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 40 deletions.
4 changes: 2 additions & 2 deletions api/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,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
7 changes: 3 additions & 4 deletions internal/controllers/cluster/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,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 @@ -901,10 +901,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 @@ -985,31 +981,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 @@ -1890,7 +1890,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 @@ -1923,10 +1923,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 aa55734

Please sign in to comment.