Skip to content

Commit

Permalink
Remove unnecessary code for updating DefaultCNIConfiguredCondition st…
Browse files Browse the repository at this point in the history
…atus (#7131)
  • Loading branch information
panktishah26 authored Dec 6, 2023
1 parent fec15e4 commit f3b82e0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 46 deletions.
18 changes: 17 additions & 1 deletion controllers/cluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,23 @@ func TestClusterReconcilerReconcileSelfManagedClusterConditions(t *testing.T) {
iam.EXPECT().EnsureCASecret(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil)
iam.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(controller.Result{}, nil)

providerReconciler.EXPECT().Reconcile(gomock.Any(), gomock.Any(), gomock.Any()).Times(1)
providerReconciler.EXPECT().Reconcile(gomock.Any(), gomock.Any(), gomock.Any()).Times(1).Do(
func(ctx context.Context, log logr.Logger, cluster *anywherev1.Cluster) {
kcpReadyCondition := conditions.Get(kcp, clusterv1.ReadyCondition)
if kcpReadyCondition == nil ||
(kcpReadyCondition != nil && kcpReadyCondition.Status == "False") {
conditions.MarkFalse(cluster, anywherev1.DefaultCNIConfiguredCondition, anywherev1.ControlPlaneNotReadyReason, clusterv1.ConditionSeverityInfo, "")
return
}

if tt.skipCNIUpgrade {
conditions.MarkFalse(cluster, anywherev1.DefaultCNIConfiguredCondition, anywherev1.SkipUpgradesForDefaultCNIConfiguredReason, clusterv1.ConditionSeverityWarning, "Configured to skip default Cilium CNI upgrades")
return
}

conditions.MarkTrue(cluster, anywherev1.DefaultCNIConfiguredCondition)
},
)
mhcReconciler.EXPECT().Reconcile(logCtx, gomock.AssignableToTypeOf(logr.Logger{}), sameName(config.Cluster)).Return(nil)

r := controllers.NewClusterReconciler(testClient, registry, iam, clusterValidator, mockPkgs, mhcReconciler)
Expand Down
15 changes: 0 additions & 15 deletions pkg/controller/clusters/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,6 @@ func UpdateClusterStatusForCNI(ctx context.Context, cluster *anywherev1.Cluster)
conditions.MarkFalse(cluster, anywherev1.DefaultCNIConfiguredCondition, anywherev1.ControlPlaneNotReadyReason, clusterv1.ConditionSeverityInfo, "")
return
}

// Self managed clusters do not use the CNI reconciler, so this status would never get resolved.
// TODO: Remove after self-managed clusters are created with the controller in the CLI
if cluster.IsSelfManaged() {
ciliumCfg := cluster.Spec.ClusterNetwork.CNIConfig.Cilium
// Though it may be installed initially to successfully create the cluster,
// if the CNI is configured to skip upgrades, we mark the condition as "False"
if ciliumCfg != nil && !ciliumCfg.IsManaged() {
conditions.MarkFalse(cluster, anywherev1.DefaultCNIConfiguredCondition, anywherev1.SkipUpgradesForDefaultCNIConfiguredReason, clusterv1.ConditionSeverityWarning, "Configured to skip default Cilium CNI upgrades")
return
}

// Otherwise, since the control plane is fully ready we can assume the CNI has been configured.
conditions.MarkTrue(cluster, anywherev1.DefaultCNIConfiguredCondition)
}
}

// updateConditionsForEtcdAndControlPlane updates the ControlPlaneReady condition if etcdadm cluster is not ready.
Expand Down
30 changes: 0 additions & 30 deletions pkg/controller/clusters/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,36 +1045,6 @@ func TestUpdateClusterStatusForCNI(t *testing.T) {
Status: "True",
},
},
{
name: "cilium is unmanaged",
skipUpgrade: ptr.Bool(true),
conditions: []anywherev1.Condition{
{
Type: anywherev1.ControlPlaneReadyCondition,
Status: "True",
},
},
wantCondition: &anywherev1.Condition{
Type: anywherev1.DefaultCNIConfiguredCondition,
Reason: anywherev1.SkipUpgradesForDefaultCNIConfiguredReason,
Status: "False",
Severity: clusterv1.ConditionSeverityWarning,
},
},
{
name: "cilium is managed",
skipUpgrade: ptr.Bool(false),
conditions: []anywherev1.Condition{
{
Type: anywherev1.ControlPlaneReadyCondition,
Status: "True",
},
},
wantCondition: &anywherev1.Condition{
Type: anywherev1.DefaultCNIConfiguredCondition,
Status: "True",
},
},
}

for _, tt := range tests {
Expand Down

0 comments on commit f3b82e0

Please sign in to comment.