Skip to content
Open
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
2 changes: 2 additions & 0 deletions pkg/controllers/cloud_config_sync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ func (r *CloudConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
klog.Infof("Initializing minimal config for platform %s", platformType)
minimalConfig := getMinimalConfigForPlatform(platformType)
sourceCM.Data = map[string]string{defaultConfigKey: minimalConfig}
} else {
return ctrl.Result{}, fmt.Errorf("cloud-config source configmap %s/%s not found", openshiftUnmanagedCMKey.Namespace, openshiftUnmanagedCMKey.Name)
}
} else if err != nil {
klog.Errorf("unable to get cloud-config for sync: %v", err)
Expand Down
30 changes: 27 additions & 3 deletions pkg/controllers/cloud_config_sync_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,31 @@ var _ = Describe("Cloud config sync reconciler", func() {
Expect(degradedCond.Status).To(Equal(configv1.ConditionTrue))
})

It("should treat a missing source configmap as transient until it reappears", func() {
Expect(cl.Delete(ctx, makeInfraCloudConfig(configv1.AWSPlatformType))).To(Succeed())

infraResource := makeInfrastructureResource(configv1.AWSPlatformType)
Expect(cl.Create(ctx, infraResource)).To(Succeed())

infraResource.Status = makeInfraStatus(infraResource.Spec.PlatformSpec.Type)
Expect(cl.Status().Update(ctx, infraResource.DeepCopy())).To(Succeed())

_, err := reconciler.Reconcile(context.TODO(), ctrl.Request{})
Expect(err).To(HaveOccurred())

co := &configv1.ClusterOperator{}
Expect(cl.Get(ctx, client.ObjectKey{Name: clusterOperatorName}, co)).To(MatchError(apierrors.IsNotFound, "IsNotFound"))

Expect(cl.Create(ctx, makeInfraCloudConfig(configv1.AWSPlatformType))).To(Succeed())

_, err = reconciler.Reconcile(context.TODO(), ctrl.Request{})
Expect(err).NotTo(HaveOccurred())

Expect(cl.Get(ctx, client.ObjectKey{Name: clusterOperatorName}, co)).To(Succeed())
Expect(v1helpers.IsStatusConditionTrue(co.Status.Conditions, cloudConfigControllerDegradedCondition)).To(BeFalse())
Expect(v1helpers.IsStatusConditionTrue(co.Status.Conditions, cloudConfigControllerAvailableCondition)).To(BeTrue())
})

It("should continue with reconcile when feature gates are available", func() {
reconciler.FeatureGateAccess = featuregates.NewHardcodedFeatureGateAccessForTesting(
[]configv1.FeatureGateName{"CloudControllerManagerWebhook", "ChocobombVanilla", "ChocobombStrawberry"},
Expand Down Expand Up @@ -604,9 +629,8 @@ var _ = Describe("Cloud config sync reconciler", func() {
Expect(cl.Status().Update(ctx, infraResource.DeepCopy())).To(Succeed())
_, err := reconciler.Reconcile(context.TODO(), ctrl.Request{})
Expect(err).To(BeNil())
allCMs := &corev1.ConfigMapList{}
Expect(cl.List(ctx, allCMs, &client.ListOptions{Namespace: targetNamespaceName})).To(Succeed())
Expect(len(allCMs.Items)).To(BeZero())
Expect(cl.Get(ctx, client.ObjectKey{Namespace: targetNamespaceName, Name: syncedCloudConfigMapName}, &corev1.ConfigMap{})).
To(MatchError(apierrors.IsNotFound, "IsNotFound"))
})
})

Expand Down