Skip to content

Create valkey resources using pgrator resources - #331

Open
thokra-nav wants to merge 21 commits into
mainfrom
pgrator_valkey
Open

Create valkey resources using pgrator resources#331
thokra-nav wants to merge 21 commits into
mainfrom
pgrator_valkey

Conversation

@thokra-nav

Copy link
Copy Markdown
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread internal/persistence/valkey/queries.go Outdated
Comment thread internal/persistence/valkey/queries.go
@thokra-nav
thokra-nav force-pushed the pgrator_valkey branch 2 times, most recently from ac1316e to e6ac59e Compare February 13, 2026 09:55
@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
@tronghn

tronghn commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

TODO: må legge til støtte for nye felter fra CRDene og fjerne watchere på aiven-ressursene og bare bruke pgrator-ressursene i stedet

thokra-nav and others added 17 commits August 31, 2026 10:41
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>
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>
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>
christeredvartsen and others added 4 commits September 1, 2026 10:54
- Include label updates in shared update function pipeline for Valkey
  and
  OpenSearch
- Switch label update helpers to typed CRDs and return errors
  consistently
- Fix Valkey database comparison/update logic to avoid nil/pointer
  issues
- Return labels in Valkey model mapping
- Update Valkey integration test to check `nais.io/v1` and correct
  resource
  name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants