[release/v25.1.x] operator: handle ServiceMonitorList's Items#920
Merged
chrisseto merged 1 commit intorelease/v25.1.xfrom Jun 16, 2025
Merged
[release/v25.1.x] operator: handle ServiceMonitorList's Items#920chrisseto merged 1 commit intorelease/v25.1.xfrom
ServiceMonitorList's Items#920chrisseto merged 1 commit intorelease/v25.1.xfrom
Conversation
Previously the lifecycle client would panic if > 0 ServiceMonitors were found
in `listResources` due to Items being `[]*T` instead of the standard `[]T`.
```
interface conversion: **v1.ServiceMonitor is not client.Object: missing method DeepCopyObject
github.com/go-logr/logr.Logger.Error
/root/go/pkg/mod/github.com/go-logr/logr@v1.4.2/logr.go:301
k8s.io/apimachinery/pkg/util/runtime.logPanic
/root/go/pkg/mod/k8s.io/apimachinery@v0.33.1/pkg/util/runtime/runtime.go:142
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile.func1
/root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:108
runtime.gopanic
/nix/store/5xvi25nqmbrg58aixp4zgczilfnp7pwg-go-1.24.3/share/go/src/runtime/panic.go:792
runtime.getitab
/nix/store/5xvi25nqmbrg58aixp4zgczilfnp7pwg-go-1.24.3/share/go/src/runtime/iface.go:55
runtime.typeAssert
/nix/store/5xvi25nqmbrg58aixp4zgczilfnp7pwg-go-1.24.3/share/go/src/runtime/iface.go:474
github.com/redpanda-data/redpanda-operator/operator/internal/lifecycle.(*ResourceClient[...]).listResources
/work/operator/internal/lifecycle/client.go:278
github.com/redpanda-data/redpanda-operator/operator/internal/lifecycle.(*ResourceClient[...]).listAllOwnedResources
/work/operator/internal/lifecycle/client.go:290
github.com/redpanda-data/redpanda-operator/operator/internal/lifecycle.(*ResourceClient[...]).SyncAll
/work/operator/internal/lifecycle/client.go:95
github.com/redpanda-data/redpanda-operator/operator/internal/controller/redpanda.(*RedpandaReconciler).reconcileResources
/work/operator/internal/controller/redpanda/redpanda_controller.go:315
github.com/redpanda-data/redpanda-operator/operator/internal/controller/redpanda.(*RedpandaReconciler).Reconcile
/work/operator/internal/controller/redpanda/redpanda_controller.go:208
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile
/root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:119
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler
/root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:334
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem
/root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:294
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2
/root/go/pkg/mod/sigs.k8s.io/controller-runtime@v0.20.4/pkg/internal/controller/controller.go:255
```
This commit implements `kube.Items` to provide a standard panic free way of
extracting the items from a Kubernetes object list. This method was opted for
as reproducing a panic would otherwise require installing Prometheus' CRDs into
our test environments for an issue that occurs 100% on the client side.
(cherry picked from commit 33fda60)
RafalKorepta
approved these changes
Jun 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
maintorelease/v25.1.x:ServiceMonitorList's ItemsQuestions ?
Please refer to the Backport tool documentation