Skip to content

Commit ae9d77c

Browse files
joelanfordthetechnick
authored andcommitted
fixing broken tests after rebase
Signed-off-by: Joe Lanford <[email protected]>
1 parent 75e3040 commit ae9d77c

File tree

4 files changed

+76
-38
lines changed

4 files changed

+76
-38
lines changed

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ require (
4343
k8s.io/klog/v2 v2.130.1
4444
k8s.io/kubernetes v1.33.2
4545
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
46-
pkg.package-operator.run/boxcutter v0.4.0
46+
pkg.package-operator.run/boxcutter v0.5.1
4747
sigs.k8s.io/controller-runtime v0.21.0
4848
sigs.k8s.io/controller-tools v0.18.0
4949
sigs.k8s.io/crdify v0.4.1-0.20250613143457-398e4483fb58
@@ -97,7 +97,7 @@ require (
9797
github.com/docker/docker-credential-helpers v0.9.3 // indirect
9898
github.com/docker/go-connections v0.5.0 // indirect
9999
github.com/docker/go-units v0.5.0 // indirect
100-
github.com/emicklei/go-restful/v3 v3.12.2 // indirect
100+
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
101101
github.com/evanphx/json-patch v5.9.11+incompatible // indirect
102102
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
103103
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
@@ -111,7 +111,7 @@ require (
111111
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
112112
github.com/go-jose/go-jose/v4 v4.1.0 // indirect
113113
github.com/go-logr/stdr v1.2.2 // indirect
114-
github.com/go-openapi/jsonpointer v0.21.1 // indirect
114+
github.com/go-openapi/jsonpointer v0.21.2 // indirect
115115
github.com/go-openapi/jsonreference v0.21.0 // indirect
116116
github.com/go-openapi/swag v0.23.1 // indirect
117117
github.com/gobuffalo/flect v1.0.3 // indirect
@@ -230,8 +230,8 @@ require (
230230
google.golang.org/genproto/googleapis/api v0.0.0-20250603155806-513f23925822 // indirect
231231
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
232232
google.golang.org/grpc v1.73.0 // indirect
233-
google.golang.org/protobuf v1.36.6 // indirect
234-
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
233+
google.golang.org/protobuf v1.36.7 // indirect
234+
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
235235
gopkg.in/inf.v0 v0.9.1 // indirect
236236
gopkg.in/warnings.v0 v0.1.2 // indirect
237237
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQ
124124
github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw=
125125
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
126126
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
127-
github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU=
128-
github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
127+
github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes=
128+
github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
129129
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
130130
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
131131
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -167,8 +167,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
167167
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
168168
github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ=
169169
github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg=
170-
github.com/go-openapi/jsonpointer v0.21.1 h1:whnzv/pNXtK2FbX/W9yJfRmE2gsmkfahjMKB0fZvcic=
171-
github.com/go-openapi/jsonpointer v0.21.1/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk=
170+
github.com/go-openapi/jsonpointer v0.21.2 h1:AqQaNADVwq/VnkCmQg6ogE+M3FOsKTytwges0JdwVuA=
171+
github.com/go-openapi/jsonpointer v0.21.2/go.mod h1:50I1STOfbY1ycR8jGz8DaMeLCdXiI6aDteEdRNNzpdk=
172172
github.com/go-openapi/jsonreference v0.21.0 h1:Rs+Y7hSXT83Jacb7kFyjn4ijOuVGSvOdF2+tg1TRrwQ=
173173
github.com/go-openapi/jsonreference v0.21.0/go.mod h1:LmZmgsrTkVg9LG4EaHeY8cBDslNPMo06cago5JNLkm4=
174174
github.com/go-openapi/swag v0.23.1 h1:lpsStH0n2ittzTnbaSloVZLuB5+fvSY/+hnagBjSNZU=
@@ -710,13 +710,13 @@ google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2
710710
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
711711
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
712712
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
713-
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
714-
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
713+
google.golang.org/protobuf v1.36.7 h1:IgrO7UwFQGJdRNXH/sQux4R1Dj1WAKcLElzeeRaXV2A=
714+
google.golang.org/protobuf v1.36.7/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
715715
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
716716
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
717717
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
718-
gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4=
719-
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
718+
gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo=
719+
gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
720720
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
721721
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
722722
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
@@ -764,8 +764,8 @@ k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8
764764
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
765765
oras.land/oras-go/v2 v2.6.0 h1:X4ELRsiGkrbeox69+9tzTu492FMUu7zJQW6eJU+I2oc=
766766
oras.land/oras-go/v2 v2.6.0/go.mod h1:magiQDfG6H1O9APp+rOsvCPcW1GD2MM7vgnKY0Y+u1o=
767-
pkg.package-operator.run/boxcutter v0.4.0 h1:DNJEOpqgwIlzTgtUapiGvB+vUOcEKBBkeF1c0DIF/Ik=
768-
pkg.package-operator.run/boxcutter v0.4.0/go.mod h1:1lk3NOKdY5T5sQZdfp2yuUatLXgGv/C0qvG0vXGuR5s=
767+
pkg.package-operator.run/boxcutter v0.5.1 h1:oZ68bI8wQ5nUsn6VqFFYNKJpnHLrys9Uc36yeNgedKE=
768+
pkg.package-operator.run/boxcutter v0.5.1/go.mod h1:yJu14WhAywcr2rvt/MEfDCT14t8cTFdYGZWxdSMA5QY=
769769
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.33.0 h1:qPrZsv1cwQiFeieFlRqT627fVZ+tyfou/+S5S0H5ua0=
770770
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.33.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
771771
sigs.k8s.io/controller-runtime v0.21.0 h1:CYfjpEuicjUecRk+KAeyYh+ouUBn4llGyDYytIGcJS8=

internal/operator-controller/controllers/clusterextensionrevision_controller.go

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
9191
//
9292
tres, err := c.RevisionEngine.Teardown(ctx, *revision)
9393
if err != nil {
94-
return ctrl.Result{}, fmt.Errorf("revision teardown: %w", err)
94+
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
95+
Type: "Available",
96+
Status: metav1.ConditionFalse,
97+
Reason: "ReconcileFailure",
98+
Message: err.Error(),
99+
ObservedGeneration: rev.Generation,
100+
})
101+
return ctrl.Result{}, fmt.Errorf("revision teardown: %w", errors.Join(err, c.Client.Status().Update(ctx, rev)))
95102
}
96103

97104
l.Info("teardown report", "report", tres.String())
@@ -100,7 +107,14 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
100107
}
101108

102109
if err := c.TrackingCache.Free(ctx, rev); err != nil {
103-
return ctrl.Result{}, err
110+
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
111+
Type: "Available",
112+
Status: metav1.ConditionFalse,
113+
Reason: "ReconcileFailure",
114+
Message: err.Error(),
115+
ObservedGeneration: rev.Generation,
116+
})
117+
return ctrl.Result{}, fmt.Errorf("free cache informers: %w", errors.Join(err, c.Client.Status().Update(ctx, rev)))
104118
}
105119
return ctrl.Result{}, c.removeFinalizer(ctx, rev, clusterExtensionRevisionTeardownFinalizer)
106120
}
@@ -109,10 +123,24 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
109123
// Reconcile
110124
//
111125
if err := c.ensureFinalizer(ctx, rev, clusterExtensionRevisionTeardownFinalizer); err != nil {
112-
return ctrl.Result{}, err
126+
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
127+
Type: "Available",
128+
Status: metav1.ConditionFalse,
129+
Reason: "ReconcileFailure",
130+
Message: err.Error(),
131+
ObservedGeneration: rev.Generation,
132+
})
133+
return ctrl.Result{}, fmt.Errorf("ensure finalizer: %w", errors.Join(err, c.Client.Status().Update(ctx, rev)))
113134
}
114135
if err := c.establishWatch(ctx, rev, revision); err != nil {
115-
return ctrl.Result{}, err
136+
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
137+
Type: "Available",
138+
Status: metav1.ConditionFalse,
139+
Reason: "ReconcileFailure",
140+
Message: err.Error(),
141+
ObservedGeneration: rev.Generation,
142+
})
143+
return ctrl.Result{}, fmt.Errorf("establish watch: %w", errors.Join(err, c.Client.Status().Update(ctx, rev)))
116144
}
117145
rres, err := c.RevisionEngine.Reconcile(ctx, *revision, opts...)
118146
if err != nil {
@@ -333,25 +361,6 @@ func (c *ClusterExtensionRevisionReconciler) removeFinalizer(ctx context.Context
333361
return nil
334362
}
335363

336-
// getControllingClusterExtension checks the objects ownerreferences for a ClusterExtension
337-
// with the controller flag set to true.
338-
// Returns a ClusterExtension with metadata recovered from the OwnerRef or nil.
339-
func getControllingClusterExtension(obj client.Object) (*ocv1.ClusterExtension, bool) {
340-
for _, v := range obj.GetOwnerReferences() {
341-
if v.Controller != nil && *v.Controller &&
342-
v.APIVersion == ocv1.GroupVersion.String() &&
343-
v.Kind == "ClusterExtension" {
344-
return &ocv1.ClusterExtension{
345-
ObjectMeta: metav1.ObjectMeta{
346-
UID: v.UID,
347-
Name: v.Name,
348-
},
349-
}, true
350-
}
351-
}
352-
return nil, false
353-
}
354-
355364
func toBoxcutterRevision(rev *ocv1.ClusterExtensionRevision) (*boxcutter.Revision, []boxcutter.RevisionReconcileOption, []client.Object) {
356365
r := &boxcutter.Revision{
357366
Name: rev.Name,

internal/operator-controller/controllers/clusterextensionrevision_controller_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
1515
"k8s.io/apimachinery/pkg/runtime/schema"
1616
"k8s.io/apimachinery/pkg/types"
17+
"k8s.io/apimachinery/pkg/util/sets"
1718
"pkg.package-operator.run/boxcutter"
1819
"pkg.package-operator.run/boxcutter/machinery"
1920
machinerytypes "pkg.package-operator.run/boxcutter/machinery/types"
@@ -22,6 +23,9 @@ import (
2223
"sigs.k8s.io/controller-runtime/pkg/client"
2324
"sigs.k8s.io/controller-runtime/pkg/client/fake"
2425
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
26+
"sigs.k8s.io/controller-runtime/pkg/handler"
27+
"sigs.k8s.io/controller-runtime/pkg/predicate"
28+
"sigs.k8s.io/controller-runtime/pkg/source"
2529

2630
ocv1 "github.com/operator-framework/operator-controller/api/v1"
2731
"github.com/operator-framework/operator-controller/internal/operator-controller/controllers"
@@ -311,6 +315,7 @@ func Test_ClusterExtensionRevisionReconciler_Reconcile_RevisionProgression(t *te
311315
return tc.revisionResult, nil
312316
},
313317
},
318+
TrackingCache: &mockTrackingCache{},
314319
}).Reconcile(t.Context(), ctrl.Request{
315320
NamespacedName: types.NamespacedName{
316321
Name: clusterExtensionRevisionName,
@@ -426,6 +431,7 @@ func Test_ClusterExtensionRevisionReconciler_Reconcile_ValidationError_Retries(t
426431
return tc.revisionResult, nil
427432
},
428433
},
434+
TrackingCache: &mockTrackingCache{},
429435
}).Reconcile(t.Context(), ctrl.Request{
430436
NamespacedName: types.NamespacedName{
431437
Name: clusterExtensionRevisionName,
@@ -614,6 +620,7 @@ func Test_ClusterExtensionRevisionReconciler_Reconcile_Deletion(t *testing.T) {
614620
},
615621
teardown: tc.revisionEngineTeardownFn(t),
616622
},
623+
TrackingCache: &mockTrackingCache{},
617624
}).Reconcile(t.Context(), ctrl.Request{
618625
NamespacedName: types.NamespacedName{
619626
Name: clusterExtensionRevisionName,
@@ -830,3 +837,25 @@ func (m mockRevisionTeardownResult) GetGonePhaseNames() []string {
830837
func (m mockRevisionTeardownResult) String() string {
831838
return m.string
832839
}
840+
841+
type mockTrackingCache struct{}
842+
843+
func (m *mockTrackingCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error {
844+
panic("not implemented")
845+
}
846+
847+
func (m *mockTrackingCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error {
848+
panic("not implemented")
849+
}
850+
851+
func (m *mockTrackingCache) Source(handler handler.EventHandler, predicates ...predicate.Predicate) source.Source {
852+
panic("not implemented")
853+
}
854+
855+
func (m *mockTrackingCache) Watch(ctx context.Context, user client.Object, gvks sets.Set[schema.GroupVersionKind]) error {
856+
return nil
857+
}
858+
859+
func (m *mockTrackingCache) Free(ctx context.Context, user client.Object) error {
860+
return nil
861+
}

0 commit comments

Comments
 (0)