Skip to content

Commit 2bbcc86

Browse files
committed
OCPBUGS-12988: controller: nrop: force degraded status if ExporterImage is set
ExporterImage is an escape hatch we had from day0 but which we never really leveraged. It made on the stable API and we can't deprecate it anytime soon, but we can at least narrow down the perimeter and make it obvious and loud it should not be used. Force the status to Degraded if the ExporterImage is set by the user. Signed-off-by: Francesco Romani <fromani@redhat.com>
1 parent c9b3f74 commit 2bbcc86

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

internal/controller/numaresourcesoperator_controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ func (r *NUMAResourcesOperatorReconciler) Reconcile(ctx context.Context, req ctr
189189
return r.degradeStatus(ctx, initialInstance, instance, tolerable.Reason, tolerable.Error)
190190
}
191191

192+
if step.Done() && instance.Spec.ExporterImage != "" {
193+
return r.degradeStatusf(ctx, initialInstance, instance, status.ConditionTypeCustomUserImage, "custom operand image set: %s", instance.Spec.ExporterImage)
194+
}
195+
192196
if err := r.Client.Status().Patch(ctx, instance, client.MergeFrom(initialInstance)); err != nil {
193197
klog.InfoS("Failed to update numaresources-operator status", "error", err)
194198
return ctrl.Result{}, err

internal/controller/numaresourcesoperator_controller_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,31 @@ var _ = Describe("Test NUMAResourcesOperator Reconcile", func() {
192192
})
193193
})
194194

195+
Context("with custom ExporterImage set", func() {
196+
It("should update the CR condition to degraded", func(ctx context.Context) {
197+
pn := "test"
198+
ng := nropv1.NodeGroup{
199+
PoolName: &pn,
200+
}
201+
nro := testobjs.NewNUMAResourcesOperator(objectnames.DefaultNUMAResourcesOperatorCrName, ng)
202+
nro.Spec.ExporterImage = "quay.io/custom/image:latest"
203+
204+
labSel := &metav1.LabelSelector{
205+
MatchLabels: map[string]string{pn: pn},
206+
}
207+
mcp := testobjs.NewMachineConfigPool(pn, labSel.MatchLabels, labSel, labSel)
208+
209+
reconciler, err := NewFakeNUMAResourcesOperatorReconciler(platf, defaultOCPVersion, nro, mcp)
210+
Expect(err).ToNot(HaveOccurred())
211+
212+
key := client.ObjectKeyFromObject(nro)
213+
Expect(reconciler.Reconcile(ctx, reconcile.Request{NamespacedName: key})).ToNot(CauseRequeue())
214+
215+
Expect(reconciler.Client.Get(ctx, key, nro)).ToNot(HaveOccurred())
216+
Expect(nro).To(BeDegradedWithReason(status.ConditionTypeCustomUserImage))
217+
})
218+
})
219+
195220
Context("with default RTE SELinux and PoolName set", func() {
196221
Context("with correct NRO and more than one NodeGroup", func() {
197222
var nro *nropv1.NUMAResourcesOperator

pkg/status/status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const (
5454

5555
const (
5656
ConditionTypeIncorrectNUMAResourcesOperatorResourceName = "IncorrectNUMAResourcesOperatorResourceName"
57+
ConditionTypeCustomUserImage = "CustomUserImage"
5758
)
5859

5960
const (

0 commit comments

Comments
 (0)