Create valkey resources using pgrator resources#331
Open
thokra-nav wants to merge 11 commits intomainfrom
Open
Create valkey resources using pgrator resources#331thokra-nav wants to merge 11 commits intomainfrom
thokra-nav wants to merge 11 commits intomainfrom
Conversation
9dcee7b to
136ed1d
Compare
Contributor
There was a problem hiding this comment.
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 dedicatedNaisValkeyWatcher. - 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 forwardoptsto the underlying cluster watcher (it always calls watcher.SystemAuthenticatedClient(ctx) without options). This makes options like WithImpersonatedClientGVR ineffective. Suggestion: passopts...through towatcher.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.
6b92d05 to
3642d4b
Compare
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>
ac1316e to
e6ac59e
Compare
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>
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.
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