refactor(utils): move ResolveClusterCRByUUID's lookup into a generic atlas/kube helper - #450
Draft
boddumanohar wants to merge 1 commit into
Draft
refactor(utils): move ResolveClusterCRByUUID's lookup into a generic atlas/kube helper#450boddumanohar wants to merge 1 commit into
boddumanohar wants to merge 1 commit into
Conversation
…atlas/kube helper Addresses review feedback on #441 (ResolveClusterCRByUUID): the linear by-key scan is generic enough to share, but atlas/kube can't depend on the operator's StorageCluster CRD type without creating a circular module dependency. Adds kube.FindByKey[T], a type-parameterized find-by-key helper with no knowledge of any concrete CRD, and has ResolveClusterCRByUUID list StorageClusters itself and call it with Status.UUID as the key.
boddumanohar
marked this pull request as draft
August 21, 2026 14:02
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.
Summary
Follow-up to review feedback from #441 (comment) on
ResolveClusterCRByUUID(operator/internal/utils/objects.go), deferred at the time ("let's do this separately").The reviewer asked to move the by-UUID lookup into
atlas/kubeas part of theResolverinterface. That interface (atlas-lib/kube/resolver.go) is deliberately generic — it only knows core Kubernetes types (PersistentVolume,VolumeAttachment,StorageClass) and has zero dependency on the operator's own CRD types.ResolveClusterCRByUUIDresolves the operator'sStorageClusterCRD specifically; moving that concrete lookup intoatlas/kubeas-is would requireatlas/kubeto importsimplyblock-operator/api/v1alpha1— a circular module dependency, since the operator already depends onatlasvia a localreplace.Instead, this pulls out the reusable mechanism — a generic find-by-key linear scan — into
atlas/kube, with no knowledge ofStorageCluster:atlas-lib/kube/find.go:FindByKey[T any](items []T, keyFn func(T) string, key string) (T, error), returningerrs.ErrNotFound(the package's existing convention) when nothing matches.operator/internal/utils/objects.go:ResolveClusterCRByUUIDnow listsStorageClusters itself (as before) and callskube.FindByKeywithStatus.UUIDas the key, wrapping a miss in the existingErrClusterNotFoundfor callers that check it (e.g.simplyblockstoragepool_controller.go).No behavior change — same lookup, same error semantics, shared scan logic.
Test plan
go test ./...in bothatlas-libandoperatormodules — full suite passesmake lintin both modules — 0 issuesTestFindByKeycovering found / not-found / empty-list cases🤖 Generated with Claude Code