Skip to content
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

[release-0.18] Remove unnecessary code for updating DefaultCNIConfiguredCondition status #7136

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
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