-
Notifications
You must be signed in to change notification settings - Fork 663
Add kagent db migrate CLI for out-of-band migrations #2168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bcdf9ae
Switch migrator to orchestrator and manage downstream migrations
iplay88keys fce442c
Merge remote-tracking branch 'origin/main' into iplay88keys/migration…
iplay88keys ac29518
Merge branch 'main' into iplay88keys/migrations-improvements-pt-3
EItanya 7f9019f
Fix wording
iplay88keys 820e97b
Fix compilation issue from merge
iplay88keys f08ea36
Updates based on review
iplay88keys 03bf283
add kagent db migrate CLI for out-of-band migrations
iplay88keys 51e21a2
Merge remote-tracking branch 'origin/main' into iplay88keys/migration…
iplay88keys 49c50c8
Address review comments
iplay88keys 62000cf
Merge remote-tracking branch 'origin/main' into iplay88keys/migration…
iplay88keys e163a02
Resolve vector track from cluster config with env override for db mig…
iplay88keys b459180
Clarify env var vs configmap key for vector track resolution
iplay88keys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Package db hosts the `kagent db` parent command and its subcommands. | ||
| // Currently only `migrate` is wired; future siblings attach here. | ||
| package db | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
| "github.com/spf13/pflag" | ||
|
|
||
| "github.com/kagent-dev/kagent/go/core/pkg/cli/db/migrate" | ||
| "github.com/kagent-dev/kagent/go/core/pkg/migrations" | ||
| ) | ||
|
|
||
| // NewCommand returns the `db` parent command with `migrate` attached. The | ||
| // given sources define the migration tracks the subcommands operate on, in | ||
| // orchestrator registration order. | ||
| func NewCommand(sources ...migrations.Source) *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "db", | ||
| Short: "Database operations (migrations, inspection)", | ||
| } | ||
| cmd.AddCommand(migrate.NewCommand(sources...)) | ||
|
|
||
| // Hide the root's API-oriented persistent flags from help across the | ||
| // entire `db` subtree. They target the kagent server / Kubernetes, | ||
| // but db commands talk to Postgres directly via --db-url. | ||
| // | ||
| // Hidden is a property of the flag itself (shared across the whole | ||
| // tree), so we can't flip it permanently. The HelpFunc override | ||
| // toggles it for the duration of the help render and restores it | ||
| // after. Children of `db` that don't set their own HelpFunc walk the | ||
| // parent chain and pick this one up. | ||
| cmd.SetHelpFunc(func(c *cobra.Command, args []string) { | ||
| for _, name := range []string{"config", "kagent-url", "namespace", "output-format", "timeout", "verbose"} { | ||
| if f := c.InheritedFlags().Lookup(name); f != nil { | ||
| f.Hidden = true | ||
| defer func(f *pflag.Flag) { f.Hidden = false }(f) | ||
| } | ||
| } | ||
| c.Root().HelpFunc()(c, args) | ||
| }) | ||
|
|
||
| return cmd | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we somehow read this from the live cluster rather than requiring information from the user. We can use this as a fallback of course
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I will look into that.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a way to look up the kagent's config. The only issue is that if the kubeconfig is pointing to a Kagent which is attached to a different postgres than you are connecting to via
--db-url, the looked-up value ofVECTOR_ENABLEDcould silently differ from what's in postgres. I can't detect a mismatch, but I can print it in the cli output as stderr: