Skip to content

Create valkey resources using pgrator resources#331

Open
thokra-nav wants to merge 11 commits intomainfrom
pgrator_valkey
Open

Create valkey resources using pgrator resources#331
thokra-nav wants to merge 11 commits intomainfrom
pgrator_valkey

Conversation

@thokra-nav
Copy link
Contributor

Some features are therefore removed or altered, but most tests are fairly unchanged.

Requires an update to liberator that's not merged yet: nais/liberator#306

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates Valkey provisioning and reconciliation in the API from Aiven aiven.io/v1alpha1 resources to nais.io/v1 Valkey resources (via pgrator/mapperator CRDs), while still listing/reading legacy Aiven Valkeys for compatibility.

Changes:

  • Create/Update/Delete Valkeys using github.com/nais/pgrator/pkg/api/v1 (nais.io/v1) and add a dedicated NaisValkeyWatcher.
  • Adjust Valkey conversion/mapping logic (tier/memory/maxMemoryPolicy) for the new CRD.
  • Update Kubernetes scheme + fake client mappings and bump dependencies (including adding pgrator API module).

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/persistence/valkey/queries.go Switch CRUD to nais.io/v1 Valkey CRD, merge legacy + new watchers in reads/lists
internal/persistence/valkey/models.go Add conversion from nais.io/v1 Valkey and adapt max memory policy parsing
internal/persistence/valkey/machines.go Remove tier+memory → plan lookup now that plan is no longer set in created resources
internal/persistence/valkey/dataloader.go Add nais.io/v1 GVR + NewNaisValkeyWatcher; add helper for NAIS dynamic client
internal/persistence/valkey/client.go Simplify client struct now that watcher isn’t stored on it
internal/kubernetes/watchers/watchers.go Register NaisValkeyWatcher in watcher setup
internal/kubernetes/watcher/watcher.go Extend SystemAuthenticatedClient signature to accept options
internal/kubernetes/utils.go Add helpers to convert to/from unstructured objects
internal/kubernetes/scheme.go Register pgrator API schemes
internal/kubernetes/fake/fake.go Register valkeys list kind for fake dynamic client
internal/cmd/api/http.go Wire NaisValkeyWatcher into Valkey loader context
integration_tests/valkey_crud.lua Update expected resources to nais.io/v1 Valkey CRD and remove Aiven ServiceIntegration assertions
go.mod / go.sum Add pgrator API module and bump several dependencies
Comments suppressed due to low confidence (1)

internal/kubernetes/watcher/watcher.go:316

  • SystemAuthenticatedClient now accepts opts ...ImpersonatedClientOption, but the implementation doesn’t forward opts to the underlying cluster watcher (it always calls watcher.SystemAuthenticatedClient(ctx) without options). This makes options like WithImpersonatedClientGVR ineffective. Suggestion: pass opts... through to watcher.SystemAuthenticatedClient(ctx, opts...).
func (w *Watcher[T]) SystemAuthenticatedClient(ctx context.Context, cluster string, opts ...ImpersonatedClientOption) (dynamic.NamespaceableResourceInterface, error) {
	for _, watcher := range w.watchers {
		if watcher.cluster == cluster {
			return watcher.SystemAuthenticatedClient(ctx)
		}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

thokra-nav and others added 4 commits February 13, 2026 10:55
Some features are therefore removed or altered, but most tests are
fairly unchanged.

Requires an update to liberator that's not merged yet: nais/liberator#306
Co-Authored-By: Trong Huu Nguyen <trong.huu.nguyen@nav.no>
thokra-nav and others added 2 commits February 13, 2026 11:18
Co-authored-by: Trong Huu Nguyen <trong.huu.nguyen@nav.no>
* Make claude do what I did with valkey for opensearch

* Fix checks

* Fix missing fix from other branch

* Change delete logic for OpenSearch instances

Co-Authored-By: Trong Huu Nguyen <trong.huu.nguyen@nav.no>

* Use correct client for CUD operations

Co-authored-by: Trong Huu Nguyen <trong.huu.nguyen@nav.no>

* Use Get function to reduce boilerplate

Co-authored-by: Trong Huu Nguyen <trong.huu.nguyen@nav.no>

* Remove unused arg

---------

Co-authored-by: Trong Huu Nguyen <trong.huu.nguyen@nav.no>
@thokra-nav thokra-nav marked this pull request as ready for review February 13, 2026 10:28
@thokra-nav thokra-nav requested a review from a team as a code owner February 13, 2026 10:28
thokra-nav and others added 5 commits February 13, 2026 12:01
Add a debug log

Co-authored-by: Trong Huu Nguyen <trong.huu.nguyen@nav.no>
Co-authored-by: Trong Huu Nguyen <trong.huu.nguyen@nav.no>
Co-authored-by: Trong Huu Nguyen <trong.huu.nguyen@nav.no>
Co-authored-by: Trong Huu Nguyen <trong.huu.nguyen@nav.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant